mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-08 01:13:15 +00:00
[utils] HTTPHeaderDict: Handle byte values
This commit is contained in:
parent
de20687ee6
commit
3f7965105d
|
@ -2344,6 +2344,8 @@ def test_traverse_obj(self):
|
|||
|
||||
def test_http_header_dict(self):
|
||||
headers = HTTPHeaderDict()
|
||||
headers['ytdl-test'] = b'0'
|
||||
self.assertEqual(list(headers.items()), [('Ytdl-Test', '0')])
|
||||
headers['ytdl-test'] = 1
|
||||
self.assertEqual(list(headers.items()), [('Ytdl-Test', '1')])
|
||||
headers['Ytdl-test'] = '2'
|
||||
|
|
|
@ -65,6 +65,8 @@ def __init__(self, *args, **kwargs):
|
|||
self.update(kwargs)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if isinstance(value, bytes):
|
||||
value = value.decode('latin-1')
|
||||
super().__setitem__(key.title(), str(value))
|
||||
|
||||
def __getitem__(self, key):
|
||||
|
|
Loading…
Reference in a new issue