Skip to content

Conversation

@luis-guideti
Copy link

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

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

…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.
@luis-guideti luis-guideti requested a review from a team as a code owner January 28, 2026 19:34
@netlify
Copy link

netlify bot commented Jan 28, 2026

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 57a7f9b

@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

⚠️ No Changeset found

Latest commit: 57a7f9b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@luis-guideti
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant