Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket errors with --connect option #11

Closed
PatrikFehrenbach opened this issue Jun 30, 2016 · 1 comment
Closed

Socket errors with --connect option #11

PatrikFehrenbach opened this issue Jun 30, 2016 · 1 comment

Comments

@PatrikFehrenbach
Copy link

Hey guys!

There are several errors when using the --connect page due to the non existence of error handling in the head_request class.

To avoid connection timeouts i have added a two seconds timeout for each domain, and i have additionally passed every exception occuring (there will be at leas two errors at the current script:

  1. ConnectionRefusedError
  2. ConnectionTimedoutError

I have changed the code a bit as a suggestion, for the usability i'd handle the exceptions accordingly and maybe set the timeout as an argument for the user :-)

def head_request(url):
try:
conn = http.client.HTTPConnection(url,timeout=2)
conn.request("HEAD", "/")
except:
return []
resp = conn.getresponse()
conn.close()

best

Patrik

@mschwager
Copy link
Owner

Hey!

Thanks for the feedback! I added some of your suggestions here: 1f69dd0

Feel free to add additional suggestions if you have them :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants