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

feat!: Headers should be Headers #653

Merged
merged 26 commits into from
Oct 29, 2024
Merged

feat!: Headers should be Headers #653

merged 26 commits into from
Oct 29, 2024

Conversation

danielbankhead
Copy link
Contributor

@danielbankhead danielbankhead commented Oct 9, 2024

Headers should be Headers:

  • Creates consistency throughout the client libraries; no need to check properties for different casing for generic {} objects
    • Example: The "Content-Type" to use is ambiguous here and can lead to problems that are difficult to debug:
      const headers: {
        'content-type': 'application/json',
        'Content-Type': 'text/xml',
      };
  • Creates an alignment with Request#headers
  • Clients or intermediates/middleware can easily append to an existing header or create it if it does exist, like so:
const headers = new Headers();

// creates, if not exist, or appends to an existing header
headers.append('x-goog-api-client', 'abc');

Migration Guide

Simply pass non-Headers into Headers.

old:

const headers = {"my-headers": "value"};

new:

const headers = new Headers({"my-headers": "value"});

Background

🦕

@danielbankhead danielbankhead requested a review from a team as a code owner October 9, 2024 20:19
Copy link

Warning: This pull request is touching the following templated files:

@product-auto-label product-auto-label bot added the size: xl Pull request size is extra large. label Oct 9, 2024
@danielbankhead danielbankhead added do not merge Indicates a pull request not ready for merge, due to either quality or timing. next major: breaking change this is a change that we should wait to bundle into the next major version labels Oct 9, 2024
@danielbankhead danielbankhead removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 25, 2024
@danielbankhead danielbankhead requested a review from a team as a code owner October 25, 2024 18:24
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: xl Pull request size is extra large. labels Oct 25, 2024
@sofisl
Copy link
Contributor

sofisl commented Oct 29, 2024

This, along with #600 and #621 are going to cause breaking changes in auth + google-api-nodejs-client (and any other dependents). Since we don't have that level of integration tests, I'd strongly recommend releasing an experimental version of this library manually once you've merged all the breaking changes (but without merging the actual new release) and seeing what breaks in auth and GANC. That way you can preview breaking tests and any other changes, and you can revert anything if necessary before we release a new version of gaxios. In the future though, we would ideally just have these tests connected.

@danielbankhead danielbankhead merged commit de28c24 into main Oct 29, 2024
14 checks passed
@danielbankhead danielbankhead deleted the headers-as-headers branch October 29, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next major: breaking change this is a change that we should wait to bundle into the next major version size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

case sensitivity of headers should not matter
3 participants