浏览代码

[utils] Let request headers override standard headers

What was I thinking when writing this?
Philipp Hagemeister 11 年之前
父节点
当前提交
33ac271ba7
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      youtube_dl/utils.py

+ 3 - 4
youtube_dl/utils.py

@@ -766,10 +766,9 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
         return ret
         return ret
 
 
     def http_request(self, req):
     def http_request(self, req):
-        for h,v in std_headers.items():
-            if h in req.headers:
-                del req.headers[h]
-            req.add_header(h, v)
+        for h, v in std_headers.items():
+            if h not in req.headers:
+                req.add_header(h, v)
         if 'Youtubedl-no-compression' in req.headers:
         if 'Youtubedl-no-compression' in req.headers:
             if 'Accept-encoding' in req.headers:
             if 'Accept-encoding' in req.headers:
                 del req.headers['Accept-encoding']
                 del req.headers['Accept-encoding']