Merge "Refactor http_connect() to use http_connect_raw()"

This commit is contained in:
Jenkins 2012-11-16 19:52:30 +00:00 committed by Gerrit Code Review
commit ac91ab9e9d
1 changed files with 2 additions and 15 deletions

View File

@ -126,27 +126,14 @@ def http_connect(ipaddr, port, device, partition, method, path,
:param ssl: set True if SSL should be used (default: False)
:returns: HTTPConnection object
"""
if not port:
port = 443 if ssl else 80
if ssl:
conn = HTTPSConnection('%s:%s' % (ipaddr, port))
else:
conn = BufferedHTTPConnection('%s:%s' % (ipaddr, port))
if isinstance(path, unicode):
try:
path = path.encode("utf-8")
except UnicodeError:
pass # what should I do?
path = quote('/' + device + '/' + str(partition) + path)
if query_string:
path += '?' + query_string
conn.path = path
conn.putrequest(method, path, skip_host=(headers and 'Host' in headers))
if headers:
for header, value in headers.iteritems():
conn.putheader(header, str(value))
conn.endheaders()
return conn
return http_connect_raw(
ipaddr, port, method, path, headers, query_string, ssl)
def http_connect_raw(ipaddr, port, method, path, headers=None,