Skip to content

fix: skip request body for GET and HEAD requests#6350

Open
zongmingzhi wants to merge 2 commits into
apache:masterfrom
zongmingzhi:fix/httpclient-get-head-body
Open

fix: skip request body for GET and HEAD requests#6350
zongmingzhi wants to merge 2 commits into
apache:masterfrom
zongmingzhi:fix/httpclient-get-head-body

Conversation

@zongmingzhi
Copy link
Copy Markdown
Contributor

Description

This PR prevents the HTTP client plugins from forwarding request bodies for GET and HEAD requests.

Sending a body for GET or HEAD may cause Reactor Netty or WebClient to emit unexpected transfer encoding headers, which can break compatibility with some upstream servers.

Changes

  • Add shared request-body eligibility logic in AbstractHttpClientPlugin.
  • Reuse the shared logic in NettyHttpClientPlugin.
  • Reuse the shared logic in WebClientPlugin.
  • Keep request body forwarding unchanged for non-GET/HEAD methods.

Tests

  • ./mvnw -pl shenyu-plugin/shenyu-plugin-httpclient -am -DskipTests validate
  • ./mvnw -pl shenyu-plugin/shenyu-plugin-httpclient -am test

Checklist

  • I have read the contribution guidelines.
  • I submit test cases (unit or integration tests) that back your changes.
  • My local test passed ./mvnw -pl shenyu-plugin/shenyu-plugin-httpclient -am test.

宗杰 and others added 2 commits May 31, 2026 22:55
GET and HEAD requests should not forward a request body through the HTTP client plugins. Sending a body can cause Reactor Netty or WebClient to emit unexpected transfer encoding headers, which may break compatibility with upstream servers.

Add shared request-body eligibility logic in AbstractHttpClientPlugin and reuse it from both NettyHttpClientPlugin and WebClientPlugin.
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