Refactor http_connect() to use http_connect_raw()
Change-Id: I889c5eecf860cc947763c5d79148419f9741a2c2 Signed-off-by: Peter Portante <peter.portante@redhat.com>
This commit is contained in:
parent
c85d2ace93
commit
259aafb6f0
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user