ducaale / xh

Friendly and fast tool for sending HTTP requests
MIT License
5.51k stars 98 forks source link

Encoded query strings are double encoded #384

Open nickpending opened 2 days ago

nickpending commented 2 days ago

Using a query string with URL encoding results in xh double encoding the string.

b%61r becomes b%2561r

❯ xhs test.example.com "foo==b%61r" --offline
GET /?foo=b%2561r HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Host: test.example.com
User-Agent: xh/0.22.2

I'm not sure if this is intended or not, but if it is, it would be nice to have an option to suppress encoding.

ducaale commented 4 hours ago

This is inline with HTTPie and also cURL's --data-urlencode <name=content> option.

You can opt out of the encoding by having the query as part of the URL:

$ xhs "test.example.com?foo==b%61r" --offline
GET /?foo==b%61r HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Host: test.example.com
User-Agent: xh/0.22.0