1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-04 22:28:14 -04:00

Implement --add-header without modifying std_headers

Closes #2526, #1614
This commit is contained in:
pukkandan
2022-01-29 03:25:35 +05:30
parent e48b3875ec
commit 8b7539d27c
10 changed files with 28 additions and 29 deletions

View File

@@ -1372,7 +1372,7 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
if url != url_escaped:
req = update_Request(req, url=url_escaped)
for h, v in std_headers.items():
for h, v in self._params.get('http_headers', std_headers).items():
# Capitalize is needed because of Python bug 2275: http://bugs.python.org/issue2275
# The dict keys are capitalized because of this bug by urllib
if h.capitalize() not in req.headers:
@@ -5436,3 +5436,8 @@ class WebSocketsWrapper():
has_websockets = bool(compat_websockets)
def merge_headers(*dicts):
"""Merge dicts of network headers case insensitively, prioritizing the latter ones"""
return {k.capitalize(): v for k, v in itertools.chain.from_iterable(map(dict.items, dicts))}