Implement --add-header without modifying std_headers
Closes #2526, #1614
This commit is contained in:
parent
e48b3875ec
commit
8b7539d27c
10 changed files with 28 additions and 29 deletions
|
|
@ -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))}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue