How can I check if a req has a body without trying to parse it in the first place? #1348
|
Do you know if something like |
Answered by
kettanaito
Jul 22, 2022
Replies: 1 comment 4 replies
|
Hi, @jjoselv. When handling requests on the web the only way you can check for a body without reading it is by reading the Strictly speaking, this is not an MSW-related question. Is there a particular use case you're trying to achieve with the library? If so, please share it, alongside your attempts to do so (code/reproduction repo). |
4 replies
Answer selected by
kettanaito
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, @jjoselv.
When handling requests on the web the only way you can check for a body without reading it is by reading the
Content-Lengthheader sent in the response. All the other APIs require you to read the body. It makes sense, as body may be represented as a stream, and you have to read that stream to know if there's anything there at all.Strictly speaking, this is not an MSW-related question. Is there a particular use case you're trying to achieve with the library? If so, please share it, alongside your attempts to do so (code/reproduction repo).