Skip to content

Commit

Permalink
[utils] Advertise optional supported Content-Encodings
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkf committed Aug 1, 2023
1 parent e4178b5 commit 2efc8de
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions youtube_dl/utils.py
Expand Up @@ -1678,9 +1678,7 @@ def random_user_agent():

std_headers = {
'User-Agent': random_user_agent(),
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-us,en;q=0.5',
}

Expand Down Expand Up @@ -2724,6 +2722,13 @@ def http_request(self, req):
if h.capitalize() not in req.headers:
req.add_header(h, v)

# Similarly, 'Accept-encoding'
if 'Accept-encoding' not in req.headers:
req.add_header(
'Accept-Encoding', join_nonempty(
'gzip', 'deflate', brotli and 'br', ncompress and 'compress',
delim=', '))

req.headers = handle_youtubedl_headers(req.headers)

if sys.version_info < (2, 7):
Expand Down

0 comments on commit 2efc8de

Please sign in to comment.