Skip to content
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

fix(openapi-fetch): prevent body parsing for HEAD requests regardless of Content-Length #2205

Merged
merged 2 commits into from
Mar 18, 2025

Conversation

live-small
Copy link
Contributor

Changes

How to Review

  • Check that the condition now properly skips body parsing for HEAD requests
  • Verify the new test case ensures HEAD requests with non-zero Content-Length are handled correctly

Checklist

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

@live-small live-small requested a review from a team as a code owner March 17, 2025 13:15
Copy link

netlify bot commented Mar 17, 2025

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit dabe0b5

Copy link

changeset-bot bot commented Mar 17, 2025

🦋 Changeset detected

Latest commit: dabe0b5

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

This PR includes changesets to release 3 packages
Name Type
openapi-fetch Patch
openapi-react-query Patch
swr-openapi Patch

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

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Just add a patch changeset (see GitHub comment) so we can create a release from this PR

@@ -13,4 +13,16 @@ describe("HEAD", () => {
await client.HEAD("/resources/{id}", { params: { path: { id: 123 } } });
expect(method).toBe("HEAD");
});

test("handles HEAD requests with non-zero Content-Length without parsing the body", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test!

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@drwpow drwpow merged commit 4966560 into openapi-ts:main Mar 18, 2025
8 checks passed
@openapi-ts-bot openapi-ts-bot mentioned this pull request Mar 18, 2025
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.

HEAD method with non-zero Content-Length triggers JSON parsing error
2 participants