]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Add test for request params behavior changes (#3364) (#3440)
authorElaina <GreyElaina@outlook.com>
Tue, 3 Dec 2024 16:12:27 +0000 (00:12 +0800)
committerGitHub <noreply@github.com>
Tue, 3 Dec 2024 16:12:27 +0000 (16:12 +0000)
Co-authored-by: Tom Christie <tom@tomchristie.com>
CHANGELOG.md
tests/models/test_requests.py

index bc3fa411f849dd8e004a151dea1074cd696d3b88..060013b0f3cb930eeb721543ebf5218c75ebee4b 100644 (file)
@@ -28,6 +28,7 @@ Our revised [SSL documentation](docs/advanced/ssl.md) covers how to implement th
 * Ensure `certifi` and `httpcore` are only imported if required. (#3377)
 * Treat `socks5h` as a valid proxy scheme. (#3178)
 * Cleanup `Request()` method signature in line with `client.request()` and `httpx.request()`. (#3378)
+* Bugfix: When passing `params={}`, always strictly update rather than merge with an existing querystring. (#3364)
 
 ## 0.27.2 (27th August, 2024)
 
index d2a458d57e5386939ed95cb61ba256ef77b14edf..b31fe007be25bab60f90491af07e83c819cac5a6 100644 (file)
@@ -226,3 +226,16 @@ def test_request_generator_content_picklable():
     request.read()
     pickle_request = pickle.loads(pickle.dumps(request))
     assert pickle_request.content == b"test 123"
+
+
+def test_request_params():
+    request = httpx.Request("GET", "http://example.com", params={})
+    assert str(request.url) == "http://example.com"
+
+    request = httpx.Request(
+        "GET", "http://example.com?c=3", params={"a": "1", "b": "2"}
+    )
+    assert str(request.url) == "http://example.com?a=1&b=2"
+
+    request = httpx.Request("GET", "http://example.com?a=1", params={})
+    assert str(request.url) == "http://example.com"