-
-
Notifications
You must be signed in to change notification settings - Fork 615
Do not treat Content-Length=0 as empty when Transfer-Encoding is chunked #2572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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
|
🦋 Changeset detectedLatest commit: 0fe1138 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
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)