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

feat!: Headers should be Headers - #653

Merged
danielbankhead merged 26 commits into
mainfrom
headers-as-headers
Oct 29, 2024
Merged

danielbankhead merged 26 commits into
mainfrom
headers-as-headers

Conversation

@danielbankhead

@danielbankhead danielbankhead commented Oct 9, 2024 •

Copy link
Copy Markdown
Contributor

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 October 9, 2024 20:19
@generated-files-bot

Copy link
Copy Markdown

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 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

sofisl commented Oct 29, 2024

Copy link
Copy Markdown
Contributor

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.

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

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