about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2015-11-29 12:58:29 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2015-11-29 12:58:29 +0800
commit992fc9d6e124b910ff3d720e252ef9aad99b2a8b (patch)
treefd93801f6d2ce781505f393b5c8cc8b90c90f2a0
parent0424ec307bb920a2a7c217a741241f3d2af84efa (diff)
downloadyoutube-dl-992fc9d6e124b910ff3d720e252ef9aad99b2a8b.tar.gz
youtube-dl-992fc9d6e124b910ff3d720e252ef9aad99b2a8b.tar.xz
youtube-dl-992fc9d6e124b910ff3d720e252ef9aad99b2a8b.zip
[utils] Refactor handle_youtubedl_headers for future extension
-rw-r--r--youtube_dl/utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index c43e9e3a1..d0606b4bc 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -664,12 +664,13 @@ def _create_http_connection(ydl_handler, http_class, is_https, *args, **kwargs):
 
 
 def handle_youtubedl_headers(headers):
-    if 'Youtubedl-no-compression' in headers:
-        filtered_headers = dict((k, v) for k, v in headers.items() if k.lower() != 'accept-encoding')
+    filtered_headers = headers
+
+    if 'Youtubedl-no-compression' in filtered_headers:
+        filtered_headers = dict((k, v) for k, v in filtered_headers.items() if k.lower() != 'accept-encoding')
         del filtered_headers['Youtubedl-no-compression']
-        return filtered_headers
 
-    return headers
+    return filtered_headers
 
 
 class YoutubeDLHandler(compat_urllib_request.HTTPHandler):