mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.99k stars 522 forks source link

fix(HttpResponse): skip setting "Content-Length" if it is already set #2228

Closed kettanaito closed 3 months ago

kettanaito commented 3 months ago

When upgrading @mswjs/interceptors to 0.33 (in https://github.com/mswjs/msw/pull/2011), I've noticed a failing mocked binary response test: it was listing the Content-Length header value twice

Content-Length: 1044, 1044

[!WARNING] This indicates a deeper issue, as .set() on Headers instance must not join values. Something goes off here. Raw Headers from Undici behaved correctly on that branch.

We don't have any check if the Content-Length response header has already been set on HttpResponse.arrayBuffer(), which means MSW will disregard your custom Content-Length, which is a bug.

kettanaito commented 3 months ago

Released: v2.3.5 🎉

This has been released in v2.3.5!

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


Predictable release automation by @ossjs/release.