Handle redirects that include a fragment
This commit is contained in:
parent
31fd864970
commit
addf767d19
|
@ -140,6 +140,8 @@ class HtmlProcessor:
|
||||||
attribute = self.attribute.lower()
|
attribute = self.attribute.lower()
|
||||||
# TODO: handle more attributes
|
# TODO: handle more attributes
|
||||||
if tag == b'a' and attribute == b'href' or tag == b'img' and attribute == b'src':
|
if tag == b'a' and attribute == b'href' or tag == b'img' and attribute == b'src':
|
||||||
|
# TODO: entities
|
||||||
|
# TODO: keep leading whitespace already in there
|
||||||
if self.value.strip().lower().startswith(b'https://'):
|
if self.value.strip().lower().startswith(b'https://'):
|
||||||
# Space is to keep the response size constant
|
# Space is to keep the response size constant
|
||||||
return b' http://' + self.value.strip()[len(b'https://'):]
|
return b' http://' + self.value.strip()[len(b'https://'):]
|
||||||
|
@ -441,7 +443,7 @@ def proxy(sock, host):
|
||||||
if destination_url.startswith(b'https://'):
|
if destination_url.startswith(b'https://'):
|
||||||
destination_url = b'http://' + destination_url[len(b'https://'):]
|
destination_url = b'http://' + destination_url[len(b'https://'):]
|
||||||
|
|
||||||
if destination_url != url:
|
if destination_url.split(b'#')[0] != url:
|
||||||
rewritten_response.extend(b'Location: ')
|
rewritten_response.extend(b'Location: ')
|
||||||
rewritten_response.extend(destination_url)
|
rewritten_response.extend(destination_url)
|
||||||
rewritten_response.extend(b'\r\n')
|
rewritten_response.extend(b'\r\n')
|
||||||
|
|
Loading…
Reference in New Issue