You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The characters slash ("/") and question mark ("?") may represent data
within the query component. Beware that some older, erroneous
implementations may not handle such data correctly when it is used as
the base URI for relative references (Section 5.1), apparently
because they fail to distinguish query data from path data when
looking for hierarchical separators. However, as query components
are often used to carry identifying information in the form of
"key=value" pairs and one frequently used value is a reference to
another URI, it is sometimes better for usability to avoid percent-
encoding those characters.
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.
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' formatURL('http://example.com?test1=')
>>>httpx.get('http://example.com?test=value', params={'test1': None}).request.uriURL('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.
Activity
karpetrosyan commentedon May 21, 2023
There are several helpful links related to this issue.
The initial issue that represents this problem: #2331
The pull request that 'fixed' the #2331: #2354
karpetrosyan commentedon May 21, 2023
I had no idea why we were merging 'params' with queries passed into strings in this manner.
but expected
or
or even better
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
@tomchristie Please reopen this issue if you find this behavior weird, or convert it to discussion if it appears to you to be fine.
lovelydinosaur commentedon May 22, 2023
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...
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
?a=vs?astyle empty query parameters". This is more complex but might also deserve a ticket.