From 69d919d3c4e62607536bd009dcbb1458d45bf03b Mon Sep 17 00:00:00 2001 From: HelloZeroNet Date: Wed, 16 Mar 2016 22:07:11 +0100 Subject: [PATCH] Handle http redirects --- src/util/helper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/helper.py b/src/util/helper.py index 9e0e76d4..e0f53eaa 100644 --- a/src/util/helper.py +++ b/src/util/helper.py @@ -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