Skip to content

Commit

Permalink
fix: include existing headers in prepare request (#309)
Browse files Browse the repository at this point in the history
* include existing headers in prepare request

* change a test, is this ok?

* make wording make sense
  • Loading branch information
Aaron Gabriel Neyer authored Mar 2, 2022
1 parent 446e5d0 commit 010680b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit 010680b

Please sign in to comment.