aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-09-29 06:15:46 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2014-09-29 06:15:46 +0200
commit989b4b2b86588c011314200c0d30db965f79105e (patch)
tree2b48a1d30e172636c814582908bc58d62be535f1 /youtube_dl/utils.py
parent2a7b4681c6628e2a17b9b980333af1011e482058 (diff)
downloadyoutube-dl-989b4b2b86588c011314200c0d30db965f79105e.tar.xz
[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).
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 9f49507c1..950cd1a7a 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -799,6 +799,12 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
del req.headers['User-agent']
req.headers['User-agent'] = 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
def http_response(self, req, resp):