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

fix(FetchResponse): add parseRawHeaders static method #698

Merged
merged 1 commit into from
Jan 4, 2025

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Jan 4, 2025

This will help with creating Fetch API Headers from raw HTTP headers list in Node.js.

import { FetchResponse } from '@mswjs/interceptors'

http.request('/foo', (response) => {
  const headers = FetchResponse.parseRawHeaders(response.rawHeaders)
})

Note: The reason we don't expose something like FetchResponse.toWeb(r: http.IncomingMessage) is because at its current state FetchResponse is not bound to Node.js and can be used anywhere (a general-purpose util).

@kettanaito kettanaito merged commit 1691679 into main Jan 4, 2025
2 checks passed
@kettanaito kettanaito deleted the fix/fetch-response-parse-raw-headers branch January 4, 2025 18:51
@kettanaito
Copy link
Member Author

Released: v0.37.5 🎉

This has been released in v0.37.5!

Make sure to always update to the latest version (npm i @mswjs/interceptors@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

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.

1 participant