Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

feat: Add x-goog-api-client header to rest clients - #888

Merged
vam-google merged 6 commits into
googleapis:masterfrom
vam-google:master
May 20, 2021
Merged

feat: Add x-goog-api-client header to rest clients#888
vam-google merged 6 commits into
googleapis:masterfrom
vam-google:master

Conversation

@vam-google

@vam-googlevam-google commented May 17, 2021

Copy link
Copy Markdown
Contributor

Also add Content-Type: application/json header.

This PR depends on googleapis/python-api-core#189, and assumes that google-api-core version 1.27.0 has been already released (which was not the case on the moment of creation of this PR).

Also add `Content-Type: application/json` header
@vam-google
vam-google requested a review from a teamMay 17, 2021 09:50
@google-clagoogle-claBot added the cla: yes This human has signed the Contributor License Agreement. label May 17, 2021
@codecov

codecovBot commented May 17, 2021

Copy link
Copy Markdown

Codecov Report

Merging #888 (870124f) into master (7c185e8) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@## master #888 +/- ##
=========================================
Coverage 100.00% 100.00% =========================================
Files 26 27 +1 Lines 1608 1697 +89 Branches 328 347 +19 =========================================
+ Hits 1608 1697 +89 
Impacted FilesCoverage Δ
gapic/samplegen_utils/types.py100.00% <ø> (ø)
gapic/samplegen_utils/utils.py100.00% <ø> (ø)
gapic/utils/case.py100.00% <ø> (ø)
gapic/utils/reserved_names.py100.00% <ø> (ø)
gapic/generator/generator.py100.00% <100.00%> (ø)
gapic/samplegen/samplegen.py100.00% <100.00%> (ø)
gapic/schema/api.py100.00% <100.00%> (ø)
gapic/schema/metadata.py100.00% <100.00%> (ø)
gapic/schema/wrappers.py100.00% <100.00%> (ø)
gapic/utils/__init__.py100.00% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce558ac...870124f. Read the comment docs.


# Send the request
headers = dict(metadata)
headers['Content-Type'] = 'application/json'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naive question: this is not x-goog-api-client. Where does the name content-type come from? Is there documentation somewhere describing it?

@vam-googlevam-googleMay 18, 2021

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Content-Type header is a part of HTTP standard: https://datatracker.ietf.org/doc/html/rfc2616#section-14.17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@software-dov See also the internal REGAPIC gRPC transcoding design doc, where we call this out explicitly (relatively recent addition, since we found some RPCs fail without it)

@vam-google

Copy link
Copy Markdown
ContributorAuthor

@busunkim96 PTAL

@busunkim96busunkim96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I suspect the coverage drop is from the clauses I added to keep compatibility with older google-auth and google-api-core versions in 89d6f35#diff-f7a16a65f061822bcc73b8296f4dc837353d379d8d9cc5307982cb6941442835.

@busunkim96

Copy link
Copy Markdown
Contributor

Opened PR to remove code / tests for google-api-core < 1.26.0. See #893

Once that is merged updating this branch should resolve the coverage issues.

@busunkim96

Copy link
Copy Markdown
Contributor

@vam-google CI is now passing.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@vam-google@busunkim96@software-dov@vchudnov-g