diff options
author | Sergey M․ <dstftw@gmail.com> | 2016-07-03 02:21:32 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2016-07-03 02:21:32 +0700 |
commit | 95cf60e826e38ed1d46743c02549bf0bd187a0bb (patch) | |
tree | 566c20dd44fa9e9a68b276cc96802de6cbedafa5 /youtube_dl/utils.py | |
parent | 6b03e1e25d05ddb3dbd577b045e44fa9eb05bdc0 (diff) |
[utils] Add PUTRequest
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 2b61e6966..495878a0e 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1625,6 +1625,11 @@ class HEADRequest(compat_urllib_request.Request): return 'HEAD' +class PUTRequest(compat_urllib_request.Request): + def get_method(self): + return 'PUT' + + def int_or_none(v, scale=1, default=None, get_attr=None, invscale=1): if get_attr: if v is not None: @@ -1920,14 +1925,18 @@ def update_Request(req, url=None, data=None, headers={}, query={}): req_headers.update(headers) req_data = data or req.data req_url = update_url_query(url or req.get_full_url(), query) - req_type = HEADRequest if req.get_method() == 'HEAD' else compat_urllib_request.Request + req_get_method = req.get_method() + if req_get_method == 'HEAD': + req_type = HEADRequest + elif req_get_method == 'PUT': + req_type = PUTRequest + else: + req_type = compat_urllib_request.Request new_req = req_type( req_url, data=req_data, headers=req_headers, origin_req_host=req.origin_req_host, unverifiable=req.unverifiable) if hasattr(req, 'timeout'): new_req.timeout = req.timeout - if req.get_method() == 'PUT': - new_req.get_method = lambda : 'PUT' return new_req |