webhook-tester icon indicating copy to clipboard operation
webhook-tester copied to clipboard

Query params cause 404

Open namuller30 opened this issue 1 year ago • 4 comments

When I make a request to a session and pass in query params a 404 is returned. I would expect them to be stored as part of the request and a 200 returned.

curl "https://127.0.0.1:8080/e808f6fc-ac62-46bc-a031-1da6302a5912?foo=bar"
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>Error 404 - Not found</title>

  <style>
    body {
      background-color: #222;
      color: #aaa;
      font-family: 'Hack', monospace;
    }

    #error_text {
      position: absolute;
      top: 50%;
      left: 0;
      right: 0;
      text-align: center;
      margin-top: -35px;
      height: 30px;
      font-size: 2em;
    }
  </style>
</head>
<body>

<div id="error_text">Error 404: Not found</div>

<script>
  'use strict';

  const setCharAt = function (str, index, chr) {
    return (index > str.length - 1)
      ? str
      : str.substr(0, index) + chr + str.substr(index + 1);
  };

  const $errorText = document.getElementById('error_text');
  const text = $errorText.innerText;

  let progress = 0;

  const scrambleInterval = window.setInterval(() => {
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=+<>,./?[{()}]!@#$%^&*~`\|'.split('');
    let message = text;

    for (let i = 0; i < text.length; i++) {
      if (i >= progress) {
        message = setCharAt(message, i, characters[Math.round(Math.random() * (characters.length - 1))]);
      }
    }

    $errorText.innerText = message;
  }, 800 / 60);

  window.setTimeout(() => {
    let revealInterval = window.setInterval(() => {
      if (progress < text.length) {
        progress++;
      } else {
        clearInterval(revealInterval);
        clearInterval(scrambleInterval);
      }
    }, 70);
  }, 500);
</script>
</body>
</html>

namuller30 avatar Sep 26 '23 14:09 namuller30

Also appear to be having the same issue - is there a chance of a fix @tarampampam ?

gareth-johnstone avatar May 08 '24 22:05 gareth-johnstone

Unfortunately, my regular workload is quite heavy, and any free time I have is dedicated to another one of my open-source projects (after all, there are only 24 hours in a day!). So, while I'd love to address this issue when I have the time, if someone else is able to submit a pull request with the fix, I'd be more than happy to review and merge it as soon as possible

tarampampam avatar May 10 '24 15:05 tarampampam

No worries, i know how projects can just take over!

I'll have a crack at a fix and pr!

gareth-johnstone avatar May 10 '24 16:05 gareth-johnstone

Based on a little digging around, I think this line might the reason query strings are producing a 404!

https://github.com/tarampampam/webhook-tester/blob/92bd37197c5128ec03db8294469137456a6a2542/internal/http/fileserver/handler.go#L25

path.Clean(x) strips query strings - I'm not sure how the code will behave once query strings are allowed - as it looks like its doing some kind of lookup here

Still trying to get this building on Windows 11 to test it :)

Could also be wildly incorrect here, only used Go Lang twice in my life 😂😂

gareth-johnstone avatar May 10 '24 22:05 gareth-johnstone