aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorbashonly <88596187+bashonly@users.noreply.github.com>2023-07-20 08:23:30 -0500
committerGitHub <noreply@github.com>2023-07-20 13:23:30 +0000
commit71baa490ebd3655746430f208a9b605d120cd315 (patch)
tree79f2b2b60ff47405e26474b71ad45d6a04f9ddce /test
parent613dbce177d34ffc31053e8e01acf4bb107bcd1e (diff)
downloadhypervideo-pre-71baa490ebd3655746430f208a9b605d120cd315.tar.lz
hypervideo-pre-71baa490ebd3655746430f208a9b605d120cd315.tar.xz
hypervideo-pre-71baa490ebd3655746430f208a9b605d120cd315.zip
[networking] Fix POST requests with zero-length payloads (#7648)
Bugfix for 227bf1a33be7b89cd7d44ad046844c4ccba104f4 Authored by: bashonly
Diffstat (limited to 'test')
-rw-r--r--test/test_networking.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_networking.py b/test/test_networking.py
index b60ed283b..3cf587a63 100644
--- a/test/test_networking.py
+++ b/test/test_networking.py
@@ -1280,6 +1280,17 @@ class TestRequest:
req.data = b'test3'
assert req.headers.get('Content-Type') == 'application/x-www-form-urlencoded'
+ def test_update_req(self):
+ req = Request('http://example.com')
+ assert req.data is None
+ assert req.method == 'GET'
+ assert 'Content-Type' not in req.headers
+ # Test that zero-byte payloads will be sent
+ req.update(data=b'')
+ assert req.data == b''
+ assert req.method == 'POST'
+ assert req.headers.get('Content-Type') == 'application/x-www-form-urlencoded'
+
def test_proxies(self):
req = Request(url='http://example.com', proxies={'http': 'http://127.0.0.1:8080'})
assert req.proxies == {'http': 'http://127.0.0.1:8080'}