Skip to content

Commit d465d1e

Browse files
authored
fix: use lowercase x-goog-api-client header (#18064)
Use lowercase 'x-goog-api-client' header key to ensure compatibility with google-auth library's metric tracking. BUG=b/477154133 TAG=agy CONV=2f25336d-e8f9-413f-8292-73b7a55c1d81
1 parent 3fe1e21 commit d465d1e

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/google-cloud-core/google/cloud/_http/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
DEFAULT_USER_AGENT = "gcloud-python/{0}".format(version.__version__)
5050
"""The user agent for google-cloud-python requests."""
5151

52-
CLIENT_INFO_HEADER = "X-Goog-API-Client"
52+
CLIENT_INFO_HEADER = "x-goog-api-client"
5353
CLIENT_INFO_TEMPLATE = "gl-python/" + platform.python_version() + " gccl/{}"
5454

5555
_USER_AGENT_ALL_CAPS_DEPRECATED = """\

packages/google-cloud-storage/google/cloud/storage/_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def _get_default_headers(
767767
"Accept": "application/json",
768768
"Accept-Encoding": "gzip, deflate",
769769
"User-Agent": user_agent,
770-
"X-Goog-API-Client": x_goog_api_client,
770+
"x-goog-api-client": x_goog_api_client,
771771
"content-type": content_type,
772772
"x-upload-content-type": x_upload_content_type or content_type,
773773
}

packages/google-cloud-storage/tests/unit/test_blob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2688,7 +2688,7 @@ def test__get_upload_arguments(self):
26882688
**custom_headers,
26892689
}
26902690
self.assertEqual(
2691-
headers["X-Goog-API-Client"],
2691+
headers["x-goog-api-client"],
26922692
f"{client._connection.user_agent} {GCCL_INVOCATION_TEST_CONST} gccl-gcs-cmd/{COMMAND}",
26932693
)
26942694
self.assertEqual(headers, expected_headers)

packages/google-cloud-storage/tests/unit/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,8 +2169,8 @@ def test_download_blob_have_different_uuid(self):
21692169
client.download_blob_to_file(blob, file_obj)
21702170

21712171
self.assertNotEqual(
2172-
blob._do_download.call_args_list[0][0][3]["X-Goog-API-Client"],
2173-
blob._do_download.call_args_list[1][0][3]["X-Goog-API-Client"],
2172+
blob._do_download.call_args_list[0][0][3]["x-goog-api-client"],
2173+
blob._do_download.call_args_list[1][0][3]["x-goog-api-client"],
21742174
)
21752175

21762176
def test_list_blobs_w_defaults_w_bucket_obj(self):

packages/google-cloud-storage/tests/unit/test_transfer_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ def test_upload_chunks_concurrently_with_metadata_and_encryption():
12181218
"Accept": "application/json",
12191219
"Accept-Encoding": "gzip, deflate",
12201220
"User-Agent": "agent",
1221-
"X-Goog-API-Client": f"agent gccl-invocation-id/{invocation_id} gccl-gcs-cmd/tm.upload_sharded",
1221+
"x-goog-api-client": f"agent gccl-invocation-id/{invocation_id} gccl-gcs-cmd/tm.upload_sharded",
12221222
"content-type": FAKE_CONTENT_TYPE,
12231223
"x-upload-content-type": FAKE_CONTENT_TYPE,
12241224
"X-Goog-Encryption-Algorithm": "AES256",

0 commit comments

Comments
 (0)