bug 548320 (winnt 5.1/6.1 have trouble pinging the graph server) use HTTP instead of HTTPConnection p=anodelman r=bhearsum

git-svn-id: svn://10.0.0.236/trunk@259818 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
anodelman%mozilla.com 2010-02-26 18:33:32 +00:00
parent 0c83972816
commit 91e2c1c29f
2 changed files with 24 additions and 15 deletions

View File

@ -6,24 +6,33 @@
# This recipe is covered under the Python license: http://www.python.org/license
import httplib, mimetypes, urllib2
import socket
from socket import error, herror, gaierror, timeout
socket.setdefaulttimeout(None)
import urlparse
def link_exists(host, selector):
"""
Check to see if the given host exists and is reachable
"""
url = "http://" + host + selector
host, path = urlparse.urlsplit(url)[1:3]
found = 0
msg = "ping"
try:
site = urllib2.urlopen("http://" + host + selector)
meta = site.info()
except urllib2.HTTPError, e:
print "FAIL: graph server HTTPError"
print "FAIL: " + str(e)
return 0
except urllib2.URLError, e:
print "FAIL: graph server URLError"
print "FAIL: " + str(e)
return 0
return 1
h = httplib.HTTP(host) ## Make HTTPConnection Object
h.putrequest('HEAD', selector)
h.putheader('content-type', "text/plain")
h.putheader('content-length', str(len(msg)))
h.putheader('Host', host)
h.endheaders()
h.send(msg)
errcode, errmsg, headers = h.getreply()
if errcode == 200:
found = 1
else:
print "FAIL: graph server Status %d %s : %s" % (errcode, errmsg, url)
except Exception, e:
print "FAIL: graph server ", e.__class__, e, url
return found
def post_multipart(host, selector, fields, files):
"""

View File

@ -45,7 +45,7 @@ import urllib
import os
import string
import socket
socket.setdefaulttimeout(480)
#socket.setdefaulttimeout(480)
import getopt
import re