httpx.URL's percent encoding may be too strict #2863
Unanswered
luizcdc
asked this question in
Potential Issue
Replies: 3 comments 1 reply
|
I have an issue that is also related to the way that
I am not really bothered by the fact that slashes get URL-encoded (unlike https://github.com/encode/httpx/issues/2864) In short, I do not think that the Here is the unit test that shows my issue: import httpx
def test_httpx_url():
url = "http://host/path?sub_url=https://other?a%3Db%26c%3Dd"
httpx_url = httpx.URL(url)
assert httpx_url.params.get("sub_url") == "https://other?a=b&c=d" |
0 replies
|
I'm seeing this issue with servers that treat For example if I have a URL with the following query parameter |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, folks.
I work on a project that uses aiohttp and httpx interchangeably, as we've recently started migrating from aiohttp to httpx. I've found a bug this week which only happens when using httpx, which is as follows:
After sending a request (with redirects enabled) that returns a 302 Redirect, the Location header returns as:
Location: '?codg_juizado=8116;;16�%20Juizado%20Esp.C�vel%20e%20das%20Rel.Consumo%20da%20Capital'On aiohttp and on every actual browser I've tested (Chrome, Firefox, Edge), the request redirects to
'?codg_juizado=8116;;16%C3%AF%C2%BF%C2%BD%20Juizado%20Esp.C%C3%AF%C2%BF%C2%BDvel%20e%20das%20Rel.Consumo%20da%20Capital'Meanwhile, on httpx the already url-encoded '%20' is re-encoded to %2520:
'?codg_juizado=8116;;16%C3%AF%C2%BF%C2%BD%2520Juizado%2520Esp.C%C3%AF%C2%BF%C2%BDvel%2520e%2520das%2520Rel.Consumo%2520da%2520Capital'This breaks the redirect and the request fails.
aiohttp's behavior is explained by its use of yarl.URL. Yarl uses a callable
yarl._quoting_py._Quoterto percent-encode urls. Its_requoteparameter is set to True by default._requote=Trueestablishes that if a '%' is followed by two 0-9A-F (hexadecimal) chars, it should be left as is.I couldn't establish which library's behavior follows the standard the closest, but aiohttp behaves exactly like the browsers and it actually succeds on reaching the webpage.
I apologize but I wasn't able to provide a reproducible test case, as the page on which this happened requires authentication.
I'd love to get some opinions on this. Maybe we could have a "requote" parameter on httpx.URL's constructor?
All reactions