Prerequisites
Environment check
Node.js version
v25.6.1
Reproduction repository
https://github.com/brianhelba/msw-content-length-repro
Reproduction steps
npm install && npm test
Current behavior
request.headers.get('Content-Length') is null in the handler. The Content-Length header is normally calculated by the HTTP transport layer when sending the request, but @mswjs/interceptors intercepts before that point, so the header is never set.
This breaks server-side libraries that validate Content-Length before processing POST bodies.
Expected behavior
When using msw/node, intercepted requests should include a calculated Content-Length header, since handlers simulate server-side processing where this header would always be present. The Content-Length for a string body is straightforward to compute.
Note that MSW already calculates Content-Length on responses (added in v2.2.0 via #1996). The same treatment for request headers would be consistent.
Prerequisites
Environment check
mswversionNode.js version
v25.6.1
Reproduction repository
https://github.com/brianhelba/msw-content-length-repro
Reproduction steps
npm install && npm test
Current behavior
request.headers.get('Content-Length')isnullin the handler. TheContent-Lengthheader is normally calculated by the HTTP transport layer when sending the request, but@mswjs/interceptorsintercepts before that point, so the header is never set.This breaks server-side libraries that validate
Content-Lengthbefore processing POST bodies.Expected behavior
When using
msw/node, intercepted requests should include a calculatedContent-Lengthheader, since handlers simulate server-side processing where this header would always be present. TheContent-Lengthfor a string body is straightforward to compute.Note that MSW already calculates
Content-Lengthon responses (added in v2.2.0 via #1996). The same treatment for request headers would be consistent.