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: include existing headers in prepare request #309

Merged
merged 5 commits into from
Mar 2, 2022
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
1 change: 1 addition & 0 deletions google/resumable_media/_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ def _prepare_request(self):
self._update_checksum(start_byte, payload)

headers = {
**self._headers,
_CONTENT_TYPE_HEADER: self._content_type,
_helpers.CONTENT_RANGE_HEADER: content_range,
}
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/test__upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,16 +617,15 @@ def test__prepare_request_success(self):
assert headers == expected_headers

def test__prepare_request_success_with_headers(self):
headers = {"cannot": "touch this"}
headers = {"keep": "this"}
new_headers = self._prepare_request_helper(headers)
assert new_headers is not headers
expected_headers = {
"keep": "this",
"content-range": "bytes 0-32/33",
"content-type": BASIC_CONTENT,
}
assert new_headers == expected_headers
# Make sure the ``_headers`` are not incorporated.
assert "cannot" not in new_headers

@pytest.mark.parametrize("checksum", ["md5", "crc32c"])
def test__prepare_request_with_checksum(self, checksum):
Expand Down