Handle http redirects

This commit is contained in:
HelloZeroNet 2016-03-16 22:07:11 +01:00
parent eea55f8f16
commit 69d919d3c4

View file

@ -129,6 +129,9 @@ def httpRequest(url, as_file=False):
conn.sock = ssl.wrap_socket(sock, conn.key_file, conn.cert_file)
conn.request("GET", request)
response = conn.getresponse()
if response.status in [301, 302, 303, 307, 308]:
logging.info("Redirect to: %s" % response.getheader('Location'))
response = httpRequest(response.getheader('Location'))
if as_file:
import cStringIO as StringIO