Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 20, 2025. It is now read-only.
This repository was archived by the owner on Jul 20, 2025. It is now read-only.

fetch wrapper adds a Content-Type header alongside a lowercased content-type header from the requestΒ #15

@maxnachlinger

Description

@maxnachlinger

Stating the obvious here, but HTTP headers are not case sensitive :) These lines are great in that any headers specified in the request override the ones calculated in serializeBody.

gotOpts.headers = {
  ...bodyHeaders,
  ...(request.headers as object)
};

The problem occurs when the headers specified in the request don't match the casing, e.g.:

const bodyHeaders = { 'Content-Type': 'application/octet-stream' };
const request = { headers: { 'content-type': 'application/json' } };
{ ...bodyHeaders, ...request.headers }
/*
Results in:
{
  'Content-Type': 'application/octet-stream',
  'content-type': 'application/json'
}
*/

I'll be happy to submit a PR for this. IMHO the easiest way out is to lowercase the headers sent back from serializeBody and lowercase the headers sent in the request.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions