Set "Content-Length" header for response(...).emtpy()
#56
Labels
feature
Improvements or additions to the public API
response(...).emtpy()
#56
openapi-fetch
skips parsing the response body when the status code is204
or the content-length header is 0 (Source Code). For other status codes (like201
), request handlers have to explicitly set the content-length header when creating empty responses to avoid JSON parsing errors in openapi-fetch.When using
HttpResponse.json()
orHttpResponse.text()
MSW calculates the content-length. Otherwise, the header is not calculated implicitly for every response.For a better developer experience we should set the content-length header implicitly as well, when empty responses are created. This avoids confusing problems when using
response(201).empty()
.The text was updated successfully, but these errors were encountered: