mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 17:22:31 +01:00
[utils] Prevent override of custom headers.
The dict of headers of request objects in urllib has its keys always capitalized. This causes the lookup to fail and overwrite the header. If for example a Extractor tries to add a "User-Agent" header the internal representation in the request object is "User-agent". The header is therefore clobbered by the "User-Agent" in std_headers, because the strings are not equal.
This commit is contained in:
parent
a5fb718c50
commit
3d5f7a3947
@ -611,7 +611,9 @@ def addinfourl_wrapper(stream, headers, url, code):
|
|||||||
|
|
||||||
def http_request(self, req):
|
def http_request(self, req):
|
||||||
for h, v in std_headers.items():
|
for h, v in std_headers.items():
|
||||||
if h not in req.headers:
|
# 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:
|
||||||
req.add_header(h, v)
|
req.add_header(h, v)
|
||||||
if 'Youtubedl-no-compression' in req.headers:
|
if 'Youtubedl-no-compression' in req.headers:
|
||||||
if 'Accept-encoding' in req.headers:
|
if 'Accept-encoding' in req.headers:
|
||||||
|
Loading…
Reference in New Issue
Block a user