Skip to content

Commit

Permalink
Disable redirects in WebUtils.is_url_reachable() (avoid too many redi…
Browse files Browse the repository at this point in the history
…rects issue)
  • Loading branch information
koutto authored and cyrinux committed Jul 26, 2019
1 parent 773a7e4 commit fbfe100
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/utils/WebUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ def is_valid_url(url):
def is_url_reachable(url):
"""Check if an URL is reachable"""
try:
http = urllib3.PoolManager(cert_reqs='CERT_NONE', timeout=10.0, retries=2)
r = http.request('GET', url, headers={'User-Agent': USER_AGENT})
return (True, r.status, r.getheaders())
# http = urllib3.PoolManager(cert_reqs='CERT_NONE', timeout=10.0, retries=2)
# r = http.request('GET', url, headers={'User-Agent': USER_AGENT})
# return (True, r.status, r.getheaders())
r = requests.get(url, verify=False, allow_redirects=False)
return (True, r.status_code, r.headers)
except Exception as e:
#print(e)
print(e)
return (False, None, None)


Expand Down

0 comments on commit fbfe100

Please sign in to comment.