Skip to content

CXF-8746: Support forcing GET method on 301/302 redirects#2952

Open
gnodet wants to merge 1 commit intomainfrom
fix/force-get-on-redirect
Open

CXF-8746: Support forcing GET method on 301/302 redirects#2952
gnodet wants to merge 1 commit intomainfrom
fix/force-get-on-redirect

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 12, 2026

Summary

  • Adds http.redirect.force.GET property to HTTPConduit that changes the request method from POST to GET on 301 (Moved Permanently) and 302 (Found) redirects
  • Per RFC 7231 Sections 6.4.2/6.4.3, user agents have historically changed POST to GET on these redirects. This property enables that behavior when set to true
  • Minimal change: sets Message.HTTP_REQUEST_METHOD on the outMessage before retransmit(), which naturally flows through setupConnection() and skips body output for GET

Usage

WebClient wc = WebClient.create(address);
WebClient.getConfig(wc).getRequestContext().put("http.redirect.force.GET", "true");
WebClient.getConfig(wc).getHttpConduit().getClient().setAutoRedirect(true);

Or via Spring/Blueprint configuration:

<http-conf:conduit name="*.http-conduit">
    <http-conf:client AutoRedirect="true"/>
</http-conf:conduit>

With the context property http.redirect.force.GET set to true.

Context

Supersedes #977 with a cleaner, non-API-breaking approach. The original PR threaded a boolean forceGET parameter through abstract method signatures across multiple transport implementations (URLConnection, HC5, Netty), which was overly invasive. This implementation requires changes only in HTTPConduit.java and follows the same pattern as existing http.redirect.* properties.

Test plan

  • Existing HTTPConduitURLEasyMockTest redirect tests pass
  • CI verification

🤖 Generated with Claude Code

Add http.redirect.force.GET property to HTTPConduit that, when enabled,
changes the request method from POST to GET on 301/302 redirects per
RFC 7231 Sections 6.4.2/6.4.3 historical behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant