Skip to content
Permalink
Browse files
fix: update content-length header for next page (#1404)
The content-length header only gets updated at request object
initialization, so make sure we update it here after we modified the
body.

Fixes #1403

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
schweikert and parthea committed Jun 8, 2021
1 parent a0af9b1 commit 8019f2f96abc6a4375873becb2f17b399f738654
Showing with 6 additions and 0 deletions.
  1. +3 鈭0 googleapiclient/discovery.py
  2. +3 鈭0 tests/test_discovery.py
@@ -1283,6 +1283,9 @@ def methodNext(self, previous_request, previous_response):
body = model.deserialize(request.body)
body[pageTokenName] = nextPageToken
request.body = model.serialize(body)
request.body_size = len(request.body)
if "content-length" in request.headers:
del request.headers["content-length"]
logger.debug("Next page request body: %s %s" % (methodName, body))

return request
@@ -2172,6 +2172,9 @@ def test_next_successful_with_next_page_token_in_body(self):
next_request = logging.entries().list_next(request, {"nextPageToken": "123abc"})
body = JsonModel().deserialize(next_request.body)
self.assertEqual(body["pageToken"], "123abc")
# The body is changed, make sure that body_length is changed too (see
# github #1403)
self.assertEqual(next_request.body_size, len(next_request.body))

def test_next_with_method_with_no_properties(self):
self.http = HttpMock(datafile("latitude.json"), {"status": "200"})

0 comments on commit 8019f2f

Please sign in to comment.