Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update content-length header for next page requests #1404

Merged
merged 2 commits into from Jun 8, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions googleapiclient/discovery.py
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/test_discovery.py
Expand Up @@ -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"})
Expand Down