tools.web: Avoid explicit redirection loop

This commit is contained in:
nemunaire 2014-07-25 12:52:10 +02:00
parent 6976846e23
commit d575c0d6d3

View File

@ -114,7 +114,7 @@ def getURLContent(url, timeout=15):
if res.status == http.client.OK or res.status == http.client.SEE_OTHER:
return data.decode(charset)
elif res.status == http.client.FOUND or res.status == http.client.MOVED_PERMANENTLY:
elif (res.status == http.client.FOUND or res.status == http.client.MOVED_PERMANENTLY) and res.getheader("Location") != url:
return getURLContent(res.getheader("Location"), timeout)
else:
return None