Skip to content

docs: document that SimpleClientHttpRequestFactory is not suitable for WebMVC gateway#4196

Open
won-seoop wants to merge 1 commit into
spring-cloud:mainfrom
won-seoop:doc-webmvc-unsuitable-http-client
Open

docs: document that SimpleClientHttpRequestFactory is not suitable for WebMVC gateway#4196
won-seoop wants to merge 1 commit into
spring-cloud:mainfrom
won-seoop:doc-webmvc-unsuitable-http-client

Conversation

@won-seoop

Copy link
Copy Markdown

Problem

When using Spring Cloud Gateway Server MVC with the default SimpleClientHttpRequestFactory (backed by java.net.HttpURLConnection), upstream 4xx/5xx responses are not forwarded correctly — the gateway returns HTTP 500 instead of the actual error status. This happens because URLConnection throws a java.io.IOException for non-2xx responses instead of making the response body available.

This was identified in #3451 and documented as a known limitation by the team:

"We can use this issue to document that SimpleClientHttpRequestFactory (and URLConnection which it uses) is not suitable for the WebMVC gateway server."

Changes

Add a new http-client.adoc page under spring-cloud-gateway-server-webmvc/:

  • IMPORTANT warning explaining why SimpleClientHttpRequestFactory/URLConnection is not suitable
  • How to configure a suitable factory via spring.http.clients.imperative.factory (values: jdk, okhttp, apache)
  • NOTE that OkHttp / Apache HttpComponents are auto-detected when available, so the warning only applies to minimal setups
  • Cross-references to TLS/SSL docs and Spring Boot RestClient docs

Also adds the new page to nav.adoc.

Closes #3451

🤖 Generated with Claude Code

…r WebMVC gateway

Add a new http-client.adoc page for the WebMVC gateway documenting:
- An IMPORTANT warning that SimpleClientHttpRequestFactory (URLConnection)
  cannot correctly forward 4xx/5xx responses and causes HTTP 500 errors
- How to configure a suitable HTTP client factory via
  spring.http.clients.imperative.factory (jdk, okhttp, or apache)
- Add the new page to nav.adoc

The root cause: URLConnection throws IOException for error status codes,
preventing the gateway from reading and forwarding the upstream error body.
Any of JDK HttpClient, OkHttp, or Apache HttpComponents handle this correctly.

Closes spring-cloud#3451

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@spencergibb

Copy link
Copy Markdown
Member

SimpleClientHttpRequestFactory is not the default with Gateway Server WebMVC, JdkClientHttpRequestFactoryBuilder is.


Use one of the following supported implementations:

=== JDK HttpClient (recommended, no extra dependency)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does not need to be done as it is the default

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.

Document that SimpleClientHttpRequestFactory (and URLConnection which it uses) is not suitable for the WebMVC gateway server.

3 participants