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:
@@ -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))}
|
||||
|
Reference in New Issue
Block a user