]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[utils] Use update_Request in http_request
authorSergey M․ <dstftw@gmail.com>
Thu, 31 Mar 2016 16:55:49 +0000 (22:55 +0600)
committerSergey M․ <dstftw@gmail.com>
Thu, 31 Mar 2016 16:55:49 +0000 (22:55 +0600)
youtube_dl/utils.py

index 4532b737be1bb564097079a4baedef0c02932bb4..5c4ab2748cc94c9e3c10d29e994546d67ada4aea 100644 (file)
@@ -778,12 +778,7 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
 
         # Substitute URL if any change after escaping
         if url != url_escaped:
-            req_type = HEADRequest if req.get_method() == 'HEAD' else compat_urllib_request.Request
-            new_req = req_type(
-                url_escaped, data=req.data, headers=req.headers,
-                origin_req_host=req.origin_req_host, unverifiable=req.unverifiable)
-            new_req.timeout = req.timeout
-            req = new_req
+            req = update_Request(req, url=url_escaped)
 
         for h, v in std_headers.items():
             # Capitalize is needed because of Python bug 2275: http://bugs.python.org/issue2275