Skip to content

Avoid converting empty GET bodies to POST#3463

Open
hutiefang76 wants to merge 1 commit into
OpenFeign:masterfrom
hutiefang76:codex/feign-2872-empty-get-body
Open

Avoid converting empty GET bodies to POST#3463
hutiefang76 wants to merge 1 commit into
OpenFeign:masterfrom
hutiefang76:codex/feign-2872-empty-get-body

Conversation

@hutiefang76

Copy link
Copy Markdown

Fixes #2872.

When the default client sends a GET request with a non-null but empty body, HttpURLConnection treats setDoOutput(true) as a signal that output will be written. That can silently turn the request into POST before it reaches the server.

This keeps the existing behavior for non-empty bodies and for methods that normally send bodies, but skips writing an empty body for GET requests so the method stays GET.

Validation:

  • Added a regression test that sends a direct GET request with new byte[0] as the body and verifies MockWebServer receives GET.
  • Confirmed the new test failed before the fix with expected: "GET" but was: "POST".
  • JAVA_HOME=$(/usr/libexec/java_home -v 26) ./mvnw -pl core test
  • git diff --check

Signed-off-by: hutiefang <hutiefang@qq.com>
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.

Unexpected behavior: GET converted to POST without body when @RequestParam is missing in OpenFeign

1 participant