1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-03 08:35:32 +00:00

[networking] Fix POST requests with zero-length payloads (#7648)

Bugfix for 227bf1a33b

Authored by: bashonly
This commit is contained in:
bashonly
2023-07-20 08:23:30 -05:00
committed by GitHub
parent 613dbce177
commit 71baa490eb
4 changed files with 14 additions and 3 deletions

View File

@ -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'}