mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-07-04 04:52:49 -05:00
[utils] Fix update_Request() with empty data (not None)
This commit is contained in:
@ -41,6 +41,7 @@ from youtube_dl.compat import (
|
||||
|
||||
from youtube_dl.utils import (
|
||||
sanitized_Request,
|
||||
update_Request,
|
||||
urlencode_postdata,
|
||||
)
|
||||
|
||||
@ -395,6 +396,18 @@ class TestHTTP(unittest.TestCase):
|
||||
headers = ydl.urlopen(r).read().decode('utf-8')
|
||||
self.assertIn('Content-Type: application/x-www-form-urlencoded', headers)
|
||||
|
||||
def test_update_req(self):
|
||||
req = sanitized_Request('http://example.com')
|
||||
assert req.data is None
|
||||
assert req.get_method() == 'GET'
|
||||
assert not req.has_header('Content-Type')
|
||||
# Test that zero-byte payloads will be sent
|
||||
req = update_Request(req, data=b'')
|
||||
assert req.data == b''
|
||||
assert req.get_method() == 'POST'
|
||||
# yt-dl expects data to be encoded and Content-Type to be added by sender
|
||||
# assert req.get_header('Content-Type') == 'application/x-www-form-urlencoded'
|
||||
|
||||
def test_cookiejar(self):
|
||||
with FakeYDL() as ydl:
|
||||
ydl.cookiejar.set_cookie(compat_http_cookiejar_Cookie(
|
||||
|
Reference in New Issue
Block a user