Replace dict.iteritems() with dict.items()
dict.iteritems() has been removed in Python 3. In Python 2, dict.items() creates a temporary list, but Samuel Merritt wrote: "The size of the data is small enough that we don't need to worry about the memory consumption; it's all just HTTP headers." Change-Id: Iac427b8bbd032e4a1efb2bdc84a3968217eb6ddf
This commit is contained in:
parent
100419c0b3
commit
701faf0d16
@ -105,7 +105,7 @@ def quote(value, safe='/'):
|
||||
|
||||
def validate_headers(headers):
|
||||
if headers:
|
||||
for key, raw_value in headers.iteritems():
|
||||
for key, raw_value in headers.items():
|
||||
value = str(encode_utf8(raw_value))
|
||||
|
||||
if '\n' in value:
|
||||
@ -179,7 +179,7 @@ class HTTPConnection:
|
||||
def request(self, method, full_path, data=None, headers={}, files=None):
|
||||
""" Encode url and header, then call requests.request """
|
||||
headers = dict((encode_utf8(x), encode_utf8(y)) for x, y in
|
||||
headers.iteritems())
|
||||
headers.items())
|
||||
url = encode_utf8("%s://%s%s" % (
|
||||
self.parsed_url.scheme,
|
||||
self.parsed_url.netloc,
|
||||
@ -911,7 +911,7 @@ def put_object(url, token=None, container=None, name=None, contents=None,
|
||||
if content_length is not None:
|
||||
headers['Content-Length'] = str(content_length)
|
||||
else:
|
||||
for n, v in headers.iteritems():
|
||||
for n, v in headers.items():
|
||||
if n.lower() == 'content-length':
|
||||
content_length = int(v)
|
||||
if content_type is not None:
|
||||
|
@ -168,7 +168,7 @@ class MockHttpResponse():
|
||||
self.status = 200
|
||||
# This simulate previous httplib implementation that would do a
|
||||
# putrequest() and then use putheader() to send header.
|
||||
for k, v in kwarg['headers'].iteritems():
|
||||
for k, v in kwarg['headers'].items():
|
||||
self.buffer.append('%s: %s' % (k, v))
|
||||
return self.fake_response()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user