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 0fe1138

@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 0fe1138

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
openapi-fetch Minor
openapi-react-query Major

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

@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.

@drwpow
Copy link
Contributor

drwpow commented Feb 8, 2026

This looks great, thank you! Can you add a changeset (see comment)?

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.

2 participants