Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gcloud/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ def _make_request(self, method, url, data=None, content_type=None,
else:
content_length = 0

headers['Content-Length'] = content_length
# NOTE: str is intended, bytes are sufficient for headers.
headers['Content-Length'] = str(content_length)

if content_type:
headers['Content-Type'] = content_type
Expand Down
8 changes: 4 additions & 4 deletions gcloud/storage/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test__make_request_GET_normal(self):
self.assertEqual(http._requests, [])
EXPECTED_HEADERS = [
('Accept-Encoding', 'gzip'),
('Content-Length', 0),
('Content-Length', '0'),
]
solo_request, = batch._requests
self.assertEqual(solo_request[0], 'GET')
Expand All @@ -140,7 +140,7 @@ def test__make_request_POST_normal(self):
self.assertEqual(http._requests, [])
EXPECTED_HEADERS = [
('Accept-Encoding', 'gzip'),
('Content-Length', 10),
('Content-Length', '10'),
]
solo_request, = batch._requests
self.assertEqual(solo_request[0], 'POST')
Expand All @@ -165,7 +165,7 @@ def test__make_request_PATCH_normal(self):
self.assertEqual(http._requests, [])
EXPECTED_HEADERS = [
('Accept-Encoding', 'gzip'),
('Content-Length', 10),
('Content-Length', '10'),
]
solo_request, = batch._requests
self.assertEqual(solo_request[0], 'PATCH')
Expand All @@ -190,7 +190,7 @@ def test__make_request_DELETE_normal(self):
self.assertEqual(http._requests, [])
EXPECTED_HEADERS = [
('Accept-Encoding', 'gzip'),
('Content-Length', 0),
('Content-Length', '0'),
]
solo_request, = batch._requests
self.assertEqual(solo_request[0], 'DELETE')
Expand Down
14 changes: 7 additions & 7 deletions gcloud/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test__make_request_no_data_no_content_type_no_headers(self):
self.assertEqual(http._called_with['body'], None)
expected_headers = {
'Accept-Encoding': 'gzip',
'Content-Length': 0,
'Content-Length': '0',
'User-Agent': conn.USER_AGENT,
}
self.assertEqual(http._called_with['headers'], expected_headers)
Expand All @@ -181,7 +181,7 @@ def test__make_request_w_data_no_extra_headers(self):
self.assertEqual(http._called_with['body'], {})
expected_headers = {
'Accept-Encoding': 'gzip',
'Content-Length': 0,
'Content-Length': '0',
'Content-Type': 'application/json',
'User-Agent': conn.USER_AGENT,
}
Expand All @@ -200,7 +200,7 @@ def test__make_request_w_extra_headers(self):
self.assertEqual(http._called_with['body'], None)
expected_headers = {
'Accept-Encoding': 'gzip',
'Content-Length': 0,
'Content-Length': '0',
'X-Foo': 'foo',
'User-Agent': conn.USER_AGENT,
}
Expand All @@ -225,7 +225,7 @@ def test_api_request_defaults(self):
self.assertEqual(http._called_with['body'], None)
expected_headers = {
'Accept-Encoding': 'gzip',
'Content-Length': 0,
'Content-Length': '0',
'User-Agent': conn.USER_AGENT,
}
self.assertEqual(http._called_with['headers'], expected_headers)
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_api_request_w_query_params(self):
self.assertEqual(http._called_with['body'], None)
expected_headers = {
'Accept-Encoding': 'gzip',
'Content-Length': 0,
'Content-Length': '0',
'User-Agent': conn.USER_AGENT,
}
self.assertEqual(http._called_with['headers'], expected_headers)
Expand All @@ -301,7 +301,7 @@ def test_api_request_w_data(self):
self.assertEqual(http._called_with['body'], DATAJ)
expected_headers = {
'Accept-Encoding': 'gzip',
'Content-Length': len(DATAJ),
'Content-Length': str(len(DATAJ)),
'Content-Type': 'application/json',
'User-Agent': conn.USER_AGENT,
}
Expand Down Expand Up @@ -345,7 +345,7 @@ def test_api_request_non_binary_response(self):
self.assertEqual(http._called_with['body'], None)
expected_headers = {
'Accept-Encoding': 'gzip',
'Content-Length': 0,
'Content-Length': '0',
'User-Agent': conn.USER_AGENT,
}
self.assertEqual(http._called_with['headers'], expected_headers)
Expand Down