News for hackers. Stuff that matters.
Re:Show HN: A simple echo server for testing HTTP clients by tyilo on Sunday May 21, 2023 @08:57AM (#36020433)
The url generated isn't valid according to curl:

    curl -v 'https://echoserver.dev/server?query={"headers":[["foo","bar"]],"body":{"type":"text","data":"asdasdasadsasdasd"},"status":200}'
    curl: (3) nested brace in URL position 48:
    https://echoserver.dev/server?query={"headers":[["foo","bar"]],"body":{"type":"text","data":"asdasdasadsasdasd"},"status":200}

It also sends a lot of extra headers:

CF-Cache-Status: DYNAMIC CF-Ray: 7cacf9735d5c7373-CPH Connection: keep-alive Date: Sun, 21 May 2023 12:55:33 GMT Server: cloudflare Set-Cookie: __cf_bm=cAVNRtth0_6tpGLa8p2wbe6EuPRO2ZKITru5y9_GYgE-1684673733-0-AUMvqDbcxAHGRLPD2ghFL+6yJ0RKm0kGPtzsiU4jFChGrB02xtkPe8I2OX6+kFApwcWiEI1p+mFNA+esRO58cVI=; path=/; expires=Sun, 21-May-23 13:25:33 GMT; domain=.echoserver.dev; HttpOnly; Secure; SameSite=None Set-Cookie: _cfuvid=wP9ezST2Ks4reP.MMtYKTxisnCjBHSGc65SDqhRDdCU-1684673733888-0-604800000; path=/; domain=.echoserver.dev; HttpOnly; Secure; SameSite=None Transfer-Encoding: chunked Vary: Accept-Encoding alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400 x-render-origin-server: Render

Re:Show HN: A simple echo server for testing HTTP clients by afn on Sunday May 21, 2023 @09:25AM (#36020631)
By default, curl interprets braces and square brackets to expand into multiple URLs (similarly to bash and other shells). You can disable this, and use literal braces & brackets in URLs, by passing ‘-g’ (‘--globoff’).
Re:Show HN: A simple echo server for testing HTTP clients by layer8 on Sunday May 21, 2023 @01:21PM (#36022979)
Braces and square brackets (as well as double quotes) are not allowed unencoded in query strings, see the definition of pchar in https://datatracker.ietf.org/doc/html/rfc3986#section-3.4.
Re:Show HN: A simple echo server for testing HTTP clients by __s__ on Sunday May 21, 2023 @02:46PM (#36023679)
That's true. Although it will make the URL longer, I have decided to use encodeURIComponent to escape characters and avoid potential bugs.
Re:Show HN: A simple echo server for testing HTTP clients by joeframbach on Sunday May 21, 2023 @09:52AM (#36020858)
Based on this user's post history, I doubt you'll get a response. And seeing that the post was obviously written by chatgpt, I doubt they'll even be back to read your post.
Re:Show HN: A simple echo server for testing HTTP clients by __s__ on Sunday May 21, 2023 @11:01AM (#36021677)
I didn't test it with curl because I was assuming it would be used on the frontend, but as afn mentioned, I think it should work correctly if you add -g as shown below: curl -g -v 'https://echoserver.dev/server?query={"headers":[["foo","bar"...}'

Also, I am using render.com for hosting, and render.com uses Cloudflare internally, so it seems that related headers are also included. However, I believe this should not be a problem for testing purposes.