Skip to content

Allow all HeadersInit values for StreamingTextResponse and toTextStreamResponse#1763

Closed
sshader wants to merge 2 commits intovercel:mainfrom
sshader:sshader-fix-headers-spread
Closed

Allow all HeadersInit values for StreamingTextResponse and toTextStreamResponse#1763
sshader wants to merge 2 commits intovercel:mainfrom
sshader:sshader-fix-headers-spread

Conversation

@sshader
Copy link
Copy Markdown
Contributor

@sshader sshader commented May 30, 2024

headers in ResponseInit has type HeadersInit which can be a Headers instance, a Record, or an array of tuples.

Spreading init?.headers only works if it is a Record and drops the headers if the other formats are used.

Example of this behavior:

const initHeaders = [["init", "foo"]] // or new Headers({ init: "foo" })
const response = new Response(null, { headers: {...initHeaders, extra: "bar"} });
console.log(response.headers.get("init")) // null, but expected foo
console.log(response.headers.get("extra")) // "bar"

@lgrammel
Copy link
Copy Markdown
Collaborator

Thanks! I'll build on this in a separate PR

@lgrammel
Copy link
Copy Markdown
Collaborator

superseeded by #1766

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants