Skip to content

Commit

Permalink
Improvement for issue newsapps#178 in beeswithmachineguns, no helpful…
Browse files Browse the repository at this point in the history
… information printed for _sting request failures, and is a fatal error. Modified to be non-fatal, prints error to stderr. This is not ideal, urllib.errors does not seem to exist on python2, was unable to find a way to catch HTTPError or URLERror specifically, so had to go with overly-broad exception catching
  • Loading branch information
FliesLikeABrick committed Nov 28, 2017
1 parent 92c218a commit fb60ca8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions beeswithmachineguns/bees.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,17 @@ def _sting(params):
for key, value in list(dict_headers.items()):
request.add_header(key, value)

if url.lower().startswith("https://") and hasattr(ssl, '_create_unverified_context'):
context = ssl._create_unverified_context()
response = urlopen(request, context=context)
else:
response = urlopen(request)

response.read()
try:
if url.lower().startswith("https://") and hasattr(ssl, '_create_unverified_context'):
context = ssl._create_unverified_context()
response = urlopen(request, context=context)
else:
response = urlopen(request)
response.read()
except Exception as e:
sys.stderr.write("HTTP Error received while stinging URL: %s\n" % str(e))
sys.stderr.write(" Stinging may have resulted in uninteded results, proceeding...\n")
return None


def _attack(params):
Expand Down

0 comments on commit fb60ca8

Please sign in to comment.