Fixed Python 2.7 compatibility problem
This commit is contained in:
parent
00e81e256c
commit
4ef6644e26
@ -8,3 +8,5 @@ swift (x.x.x)
|
||||
(X-Trans-ID). Setting the transaction id has moved from the proxy server to
|
||||
the catch_errors middleware. Additionally, the internal header has changed
|
||||
from X-CF-Trans-ID to X-Trans-ID.
|
||||
|
||||
* Fixed Python 2.7 httplib compatibility problem.
|
||||
|
@ -131,7 +131,7 @@ def http_connect(ipaddr, port, device, partition, method, path,
|
||||
conn.putrequest(method, path)
|
||||
if headers:
|
||||
for header, value in headers.iteritems():
|
||||
conn.putheader(header, value)
|
||||
conn.putheader(header, str(value))
|
||||
conn.endheaders()
|
||||
return conn
|
||||
|
||||
@ -164,6 +164,6 @@ def http_connect_raw(ipaddr, port, method, path, headers=None,
|
||||
conn.putrequest(method, path)
|
||||
if headers:
|
||||
for header, value in headers.iteritems():
|
||||
conn.putheader(header, value)
|
||||
conn.putheader(header, str(value))
|
||||
conn.endheaders()
|
||||
return conn
|
||||
|
@ -68,6 +68,31 @@ class TestBufferedHTTP(unittest.TestCase):
|
||||
if err:
|
||||
raise Exception(err)
|
||||
|
||||
def test_nonstr_header_values(self):
|
||||
|
||||
class MockHTTPSConnection(object):
|
||||
|
||||
def __init__(self, hostport):
|
||||
pass
|
||||
|
||||
def putrequest(self, method, path):
|
||||
pass
|
||||
|
||||
def putheader(self, header, *values):
|
||||
# Essentially what Python 2.7 does that caused us problems.
|
||||
'\r\n\t'.join(values)
|
||||
|
||||
def endheaders(self):
|
||||
pass
|
||||
|
||||
bufferedhttp.HTTPSConnection = MockHTTPSConnection
|
||||
bufferedhttp.http_connect('127.0.0.1', 8080, 'sda', 1, 'GET', '/',
|
||||
headers={'x-one': '1', 'x-two': 2, 'x-three': 3.0,
|
||||
'x-four': {'crazy': 'value'}}, ssl=True)
|
||||
bufferedhttp.http_connect_raw('127.0.0.1', 8080, 'GET', '/',
|
||||
headers={'x-one': '1', 'x-two': 2, 'x-three': 3.0,
|
||||
'x-four': {'crazy': 'value'}}, ssl=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user