Is there an existing issue for this?
Current Behavior
When shenyu.httpclient.strategy=webClient is enabled, WebClientPlugin aggregates most non-binary request bodies before writing them upstream:
if (MediaTypeUtils.isByteType(mediaType)) {
return outputMessage.writeWith(body);
}
// fix chinese garbled code
return outputMessage.writeWith(DataBufferUtils.join(body));
MediaTypeUtils.isByteType(...) only treats a small set of streaming/binary media types as pass-through, such as SSE, multipart mixed, image types, NDJSON, PDF, and octet-stream. Common API request types like JSON, XML, text, and application/x-www-form-urlencoded go through DataBufferUtils.join(body).
That means the WebClient HTTP strategy changes proxy semantics from streaming to full request-body buffering for ordinary API traffic. Large JSON/XML/form uploads are accumulated in gateway memory before the upstream request is sent.
This differs from the Netty strategy, which streams the request body directly:
return nettyOutbound.send(body.map(dataBuffer -> ((NettyDataBuffer) dataBuffer).getNativeBuffer()));
The configured WebClient codec limit (shenyu.httpclient.maxInMemorySize) does not appear to bound this explicit DataBufferUtils.join(body) call.
Expected Behavior
The WebClient strategy should preserve streaming/backpressure semantics for proxied request bodies, or it should enforce a clear configured size limit before aggregating.
Switching from netty to webClient should not silently make normal JSON/XML/form requests memory-proportional in the gateway.
Steps To Reproduce
- Start ShenYu with
shenyu.httpclient.strategy=webClient.
- Proxy a large
application/json, text/plain, XML, or form request through an HTTP route.
WebClientPlugin calls DataBufferUtils.join(body) and aggregates the full request body before writing it upstream.
- Memory usage grows with request body size, and the upstream does not receive a streaming body as it does under the Netty strategy.
Environment
ShenYu version(s): current master
Debug logs
No response
Anything else?
Relevant current-master files:
shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/WebClientPlugin.java
shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/NettyHttpClientPlugin.java
shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/utils/MediaTypeUtils.java
shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientPluginConfiguration.java
Is there an existing issue for this?
Current Behavior
When
shenyu.httpclient.strategy=webClientis enabled,WebClientPluginaggregates most non-binary request bodies before writing them upstream:MediaTypeUtils.isByteType(...)only treats a small set of streaming/binary media types as pass-through, such as SSE, multipart mixed, image types, NDJSON, PDF, and octet-stream. Common API request types like JSON, XML, text, andapplication/x-www-form-urlencodedgo throughDataBufferUtils.join(body).That means the WebClient HTTP strategy changes proxy semantics from streaming to full request-body buffering for ordinary API traffic. Large JSON/XML/form uploads are accumulated in gateway memory before the upstream request is sent.
This differs from the Netty strategy, which streams the request body directly:
The configured WebClient codec limit (
shenyu.httpclient.maxInMemorySize) does not appear to bound this explicitDataBufferUtils.join(body)call.Expected Behavior
The WebClient strategy should preserve streaming/backpressure semantics for proxied request bodies, or it should enforce a clear configured size limit before aggregating.
Switching from
nettytowebClientshould not silently make normal JSON/XML/form requests memory-proportional in the gateway.Steps To Reproduce
shenyu.httpclient.strategy=webClient.application/json,text/plain, XML, or form request through an HTTP route.WebClientPlugincallsDataBufferUtils.join(body)and aggregates the full request body before writing it upstream.Environment
Debug logs
No response
Anything else?
Relevant current-master files:
shenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/WebClientPlugin.javashenyu-plugin/shenyu-plugin-httpclient/src/main/java/org/apache/shenyu/plugin/httpclient/NettyHttpClientPlugin.javashenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/utils/MediaTypeUtils.javashenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientPluginConfiguration.java