Skip to content

Commit

Permalink
fix: better handling of errors in examples/web_vulnerability_scanner/…
Browse files Browse the repository at this point in the history
…http-req.py
  • Loading branch information
evilsocket committed Jul 2, 2024
1 parent fb6caff commit 98bf1e5
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions examples/web_vulnerability_scanner/http-req.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@

# print(f"{url}{path}\n")

r = requests.get(f"{url}{path}", headers=headers, timeout=15)

if r.raw.status == 200:
print(f"HTTP/{r.raw.version/10} {r.raw.status} {r.raw.reason}")
for k, v in r.raw.headers.items():
print(f"{k}: {v}")
print(r.text)

else:
print(f"{main} : {r.raw.reason}")
try:
r = requests.get(f"{url}{path}", headers=headers, timeout=15)
if r.raw.status == 200:
print(f"HTTP/{r.raw.version/10} {r.raw.status} {r.raw.reason}")
for k, v in r.raw.headers.items():
print(f"{k}: {v}")
print(r.text)

else:
print(f"{main} : {r.raw.reason}")
except Exception as e:
print(f"ERROR for '{url}{path}': {e}")

0 comments on commit 98bf1e5

Please sign in to comment.