Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
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. WebClientPlugincallsDataBufferUtils.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 masterDebug 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
Activity
github-actions commentedon Jul 31, 2026
👋 Hello @Aias00
A new issue has been opened by @Aias00:
Please review when you have time. Thank you! 🙏
hengyuss commentedon Aug 2, 2026
/assign
Aias00 commentedon Aug 2, 2026
Follow-up verification note (2026-08-02 audit) — severity/accuracy clarification.
The buffering of non-binary request bodies is intentional:
WebClientPlugin.java:79-83streams byte-type bodies (outputMessage.writeWith(body)) but joins everything else viaDataBufferUtils.join(body), with the inline comment "fix chinese garbled code". So the buffering itself is a deliberate tradeoff, not a bug.The genuine defect here is narrower and worth keeping the issue for: the no-arg
DataBufferUtils.join(body)enforces no size limit —shenyu.httpclient.maxInMemorySizeis not applied on this path. A large non-binary request body is fully buffered into heap with no cap, which is a real memory exposure under thewebClientstrategy (thenettystrategy streams vianettyOutbound.send).Suggested reframing: keep the issue open but scope it to "apply
maxInMemorySizeto theDataBufferUtils.join(body)path" rather than "stop buffering non-binary bodies".renxf0319 commentedon Aug 19, 2026
可否将MULTIPART_FORM_DATA 加入到MediaTypeUtils 的白名单?
Aias00 commentedon Aug 19, 2026
@hengyuss
hengyuss commentedon Aug 19, 2026
好的,我看一下