Repository navigation
Changing the unexpected default behavior for URL + params
#3636
Replies: 1 comment
|
In 0.28.1, the constructor's import httpx
url = httpx.URL("https://httpbin.org/get?name=stub")
url = url.copy_merge_params({"language": "python"})
assert str(url) == "https://httpbin.org/get?name=stub&language=python"
# Send that URL directly, without passing a second params= argument.
# response = httpx.get(url)This also keeps the original URL immutable. If an incoming key already exists, the incoming value replaces that key's previous values; unrelated keys remain. For example, merging That gives you the intended behavior without an additional query-string library. It is a workaround using the existing API, not a claim that the default behavior or the linked issue has changed. HTTPX 0.28.1 URL implementation defines |
Uh oh!
There was an error while loading. Please reload this page.
With
httpx==0.28.1'sURLthere is a footgun behavior where theparamsarg will clobber any params in theurlstring:This was also recently reported as a bug here: #3621
Why is silent clobbering the default behavior? Imo this behavior is both unexpected and hard to debug
All reactions