浏览代码

[YoutubeDL] Do not loose request method information

Sergey M․ 10 年之前
父节点
当前提交
931bc3c3a7
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      youtube_dl/YoutubeDL.py

+ 3 - 1
youtube_dl/YoutubeDL.py

@@ -49,6 +49,7 @@ from .utils import (
     ExtractorError,
     format_bytes,
     formatSeconds,
+    HEADRequest,
     locked_file,
     make_HTTPS_handler,
     MaxDownloadsReached,
@@ -1720,7 +1721,8 @@ class YoutubeDL(object):
             if req_is_string:
                 req = url_escaped
             else:
-                req = compat_urllib_request.Request(
+                req_type = HEADRequest if req.get_method() == 'HEAD' else compat_urllib_request.Request
+                req = req_type(
                     url_escaped, data=req.data, headers=req.headers,
                     origin_req_host=req.origin_req_host, unverifiable=req.unverifiable)