New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reverting #2354 #2712
Comments
I had no idea why we were merging 'params' with queries passed into strings in this manner. >>> httpx.get('http://example.com?test', params={'test1': None}).request.url
URL('http://example.com?test=&test1=') but expected URL('http://example.com?test&test1=') or URL('http://example.com?testtest1=') or even better URL('http://example.com?test1=') Params means we want an acceptable format "key=val&", but when we combine this with the string supplied into the uri, I don't believe there is a server that will recognize such a format. Overriding queries passed into the string if they are not in "key=value" format is much more expected behavior, in my opinion. For example >>> httpx.get('http://example.com?test', params={'test1': None}).request.uri # overriding because query is not 'key=value' format
URL('http://example.com?test1=')
>>> httpx.get('http://example.com?test=value', params={'test1': None}).request.uri
URL('http://example.com?test=value&test1=') # keep queries since they are in 'key=value' format. @tomchristie Please reopen this issue if you find this behavior weird, or convert it to discussion if it appears to you to be fine. |
There are two different aspects you're highlighting here... There's "why do we merge query params, rather than replace them..." which we can narrow down a bit... >>> httpx.Request('GET', 'http://example.com?a=1', params={'b': '2'})
<Request('GET', 'http://example.com?a=1&b=2')> I'd agree that I don't think we have the most intuitive behaviour here. I'll raise a ticket for this. (EDIT: done #2713) There's also "how do we handle |
According to RFC 3986 Section-3.4 Query
These query parameters are 100% correct.
RFC 3986 Query:
Furthermore, Rfc7230 Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing has no query constraints and supports RFC 3986 syntax, which allows such strange queries.
RFC 7230
So when our uri is 'http://example.com?test' with params={'key':'value'} we should either override "?test" or raise an exception because merging these two formats does not make sense.
The text was updated successfully, but these errors were encountered: