mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-01 09:02:57 +01:00
's/ /\t/'
This commit is contained in:
parent
58ca755f40
commit
303692b5ed
@ -1158,15 +1158,15 @@ class HEADRedirectHandler(urllib2.HTTPRedirectHandler):
|
|||||||
"""
|
"""
|
||||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||||
if code in (301, 302, 303, 307):
|
if code in (301, 302, 303, 307):
|
||||||
newurl = newurl.replace(' ', '%20')
|
newurl = newurl.replace(' ', '%20')
|
||||||
newheaders = dict((k,v) for k,v in req.headers.items()
|
newheaders = dict((k,v) for k,v in req.headers.items()
|
||||||
if k.lower() not in ("content-length", "content-type"))
|
if k.lower() not in ("content-length", "content-type"))
|
||||||
return HeadRequest(newurl,
|
return HeadRequest(newurl,
|
||||||
headers=newheaders,
|
headers=newheaders,
|
||||||
origin_req_host=req.get_origin_req_host(),
|
origin_req_host=req.get_origin_req_host(),
|
||||||
unverifiable=True)
|
unverifiable=True)
|
||||||
else:
|
else:
|
||||||
raise urllib2.HTTPError(req.get_full_url(), code, msg, headers, fp)
|
raise urllib2.HTTPError(req.get_full_url(), code, msg, headers, fp)
|
||||||
|
|
||||||
class HTTPMethodFallback(urllib2.BaseHandler):
|
class HTTPMethodFallback(urllib2.BaseHandler):
|
||||||
"""
|
"""
|
||||||
@ -1177,17 +1177,17 @@ def http_error_405(self, req, fp, code, msg, headers):
|
|||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
newheaders = dict((k,v) for k,v in req.headers.items()
|
newheaders = dict((k,v) for k,v in req.headers.items()
|
||||||
if k.lower() not in ("content-length", "content-type"))
|
if k.lower() not in ("content-length", "content-type"))
|
||||||
return self.parent.open(urllib2.Request(req.get_full_url(),
|
return self.parent.open(urllib2.Request(req.get_full_url(),
|
||||||
headers=newheaders,
|
headers=newheaders,
|
||||||
origin_req_host=req.get_origin_req_host(),
|
origin_req_host=req.get_origin_req_host(),
|
||||||
unverifiable=True))
|
unverifiable=True))
|
||||||
|
|
||||||
# Build our opener
|
# Build our opener
|
||||||
opener = urllib2.OpenerDirector()
|
opener = urllib2.OpenerDirector()
|
||||||
for handler in [urllib2.HTTPHandler, urllib2.HTTPDefaultErrorHandler,
|
for handler in [urllib2.HTTPHandler, urllib2.HTTPDefaultErrorHandler,
|
||||||
HTTPMethodFallback, HEADRedirectHandler,
|
HTTPMethodFallback, HEADRedirectHandler,
|
||||||
urllib2.HTTPErrorProcessor, urllib2.HTTPSHandler]:
|
urllib2.HTTPErrorProcessor, urllib2.HTTPSHandler]:
|
||||||
opener.add_handler(handler())
|
opener.add_handler(handler())
|
||||||
|
|
||||||
response = opener.open(HeadRequest(url))
|
response = opener.open(HeadRequest(url))
|
||||||
|
Loading…
Reference in New Issue
Block a user