Do not treat Content-Length=0 as empty when Transfer-Encoding is chunked#2572
Do not treat Content-Length=0 as empty when Transfer-Encoding is chunked#2572luis-guideti wants to merge 3 commits intoopenapi-ts:mainfrom
Conversation
…on-chunked responses Some HTTP servers incorrectly send `Content-Length: 0` together with `Transfer-Encoding: chunked`. According to RFC 7230, chunked transfer encoding overrides Content-Length and the body may still contain data. Previously, the client treated any response with Content-Length=0 as having an empty body, which caused valid chunked responses to be discarded. This change only treats Content-Length=0 as empty when the response is not chunked, preserving correct behavior for misconfigured servers.
👷 Deploy request for openapi-ts pending review.Visit the deploys page to approve it
|
|
|
This also improves compatibility with CapacitorJS — the @capacitor/http plugin can send both Content-Length: 0 and Transfer-Encoding: chunked, and with this change those responses work as expected. |
|
This looks great, thank you! Can you add a changeset (see comment)? |
Some HTTP servers incorrectly send both:
Content-Length: 0
Transfer-Encoding: chunked
Per RFC 7230, Transfer-Encoding: chunked takes precedence and the body may still contain data. Our previous logic treated any Content-Length=0 response as empty, causing valid responses from misconfigured servers to be incorrectly ignored.
This change updates the empty-body detection logic to only treat Content-Length=0 as empty when the response is not chunked.
Changes
What does this PR change? Link to any related issue(s).
How to Review
How can a reviewer review your changes? What should be kept in mind for this review?
Checklist
docs/updated (if necessary)pnpm run update:examplesrun (only applicable for openapi-typescript)