diff options
author | James Taylor <user234683@users.noreply.github.com> | 2019-02-16 14:26:03 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2019-02-16 14:26:03 -0800 |
commit | 74658f184bc9d7c6cc17ff092eb26a14ffe6213c (patch) | |
tree | c7513ef88364a8752b996ce0ee86d65eaf76caa4 /youtube | |
parent | 7f9e91da7ac895ed6952e8fb9e7137f23a2250e2 (diff) | |
download | yt-local-74658f184bc9d7c6cc17ff092eb26a14ffe6213c.tar.lz yt-local-74658f184bc9d7c6cc17ff092eb26a14ffe6213c.tar.xz yt-local-74658f184bc9d7c6cc17ff092eb26a14ffe6213c.zip |
fetch_url: Ensure urllib never leaks python version
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/common.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/youtube/common.py b/youtube/common.py index df8280d..cb963ce 100644 --- a/youtube/common.py +++ b/youtube/common.py @@ -182,7 +182,12 @@ def fetch_url(url, headers=(), timeout=15, report_text=None, data=None, cookieja ''' headers = dict(headers) # Note: Calling dict() on a dict will make a copy headers['Accept-Encoding'] = 'gzip, br' - + + # prevent python version being leaked by urllib if User-Agent isn't provided + # (urllib will use ex. Python-urllib/3.6 otherwise) + if 'User-Agent' not in headers and 'user-agent' not in headers and 'User-agent' not in headers: + headers['User-Agent'] = 'Python-urllib' + if data is not None: if isinstance(data, str): data = data.encode('ascii') |