mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-11-16 10:32:40 +09:00
[utils:YoutubeDLHandler] Work around brain-dead Python 2.6 httplib
In 2.6, the httplib sends fragments! Remove those (fixes generic_26 on 2.6).
This commit is contained in:
parent
2a7b4681c6
commit
989b4b2b86
@ -799,6 +799,12 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
|
|||||||
del req.headers['User-agent']
|
del req.headers['User-agent']
|
||||||
req.headers['User-agent'] = req.headers['Youtubedl-user-agent']
|
req.headers['User-agent'] = req.headers['Youtubedl-user-agent']
|
||||||
del req.headers['Youtubedl-user-agent']
|
del req.headers['Youtubedl-user-agent']
|
||||||
|
|
||||||
|
if sys.version_info < (2, 7) and '#' in req.get_full_url():
|
||||||
|
# Python 2.6 is brain-dead when it comes to fragments
|
||||||
|
req._Request__original = req._Request__original.partition('#')[0]
|
||||||
|
req._Request__r_type = req._Request__r_type.partition('#')[0]
|
||||||
|
|
||||||
return req
|
return req
|
||||||
|
|
||||||
def http_response(self, req, resp):
|
def http_response(self, req, resp):
|
||||||
|
Loading…
Reference in New Issue
Block a user