def check_web_server(host, port, path):
h = httplib.HTTPConnection(host, port)
h.request('GET',path)
resp = h.getresponse()
print 'HTTP Response:'
print ' status =', resp.status
print ' reason =', resp.reason
print 'HTTP Headers:'
for hdr in resp.getheaders():
print ' %s: %s' % hdr
I called this function like this check_web_server('www.python.org',80,'/')
but it gave me this error
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
You can see the code clearly here http://pastebin.com/V9KpGkvw
I have searched here in Stackoverflow but I didnt find any relevant questions sorry I am new to site ,if I Did anything wrong.
As
ping
works, buttelnet
to port80
does not, the HTTP port80
is closed on your machine. I assume that your browser's HTTP connection goes through a proxy (as browsing works, how else would you read stackoverflow?). You need to add some code to your python program, that handles the proxy, like described here:Using an HTTP PROXY - Python