mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Issue #2776: fixed small issue when handling an URL with double slash
after a 302 response in the case of not going through a proxy.
This commit is contained in:
parent
5b02ef3e1b
commit
eb90b788f4
3 changed files with 38 additions and 3 deletions
|
@ -255,6 +255,9 @@ class Request:
|
|||
self.host, self.type = host, type
|
||||
self.__r_host = self.__original
|
||||
|
||||
def has_proxy(self):
|
||||
return self.__r_host == self.__original
|
||||
|
||||
def get_origin_req_host(self):
|
||||
return self.origin_req_host
|
||||
|
||||
|
@ -1045,10 +1048,13 @@ class AbstractHTTPHandler(BaseHandler):
|
|||
request.add_unredirected_header(
|
||||
'Content-length', '%d' % len(data))
|
||||
|
||||
scheme, sel = splittype(request.get_selector())
|
||||
sel_host, sel_path = splithost(sel)
|
||||
sel_host = host
|
||||
if request.has_proxy():
|
||||
scheme, sel = splittype(request.get_selector())
|
||||
sel_host, sel_path = splithost(sel)
|
||||
|
||||
if not request.has_header('Host'):
|
||||
request.add_unredirected_header('Host', sel_host or host)
|
||||
request.add_unredirected_header('Host', sel_host)
|
||||
for name, value in self.parent.addheaders:
|
||||
name = name.capitalize()
|
||||
if not request.has_header(name):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue