Aias00 opened a new issue, #7818: URL: https://github.com/apache/shenyu/issues/7818
### Is there an existing issue for this? - [x] I searched open and closed issues for headerMaxSize and header-name size accounting; no matching report was found. - #7816 concerns request BODY size and unknown Content-Length. This report concerns how headerMaxSize accounts for request HEADERS. ### Current Behavior Divide's `headerMaxSize` sums only header VALUE bytes, omitting names and serialized header-field overhead. A header section can exceed the configured rule limit while its values remain below it, and the request is forwarded. A standalone probe against the current built DividePlugin, actual rule cache and upstream cache produced: ```text longName=true headerLimit=128 valueBytes=9 headerBytes=225 forwarded=1 longName=false headerLimit=128 valueBytes=209 headerBytes=224 forwarded=0 ``` The first request contains `Host: 127.0.0.1` and an empty-valued custom header whose name is `X-` followed by 200 ASCII `N` characters. The second uses a short custom header name and a 200-byte value. `headerBytes` counts HTTP/1.1 field names, `: `, values, CRLF and the final CRLF; it does not include the request line. The oversized-name case is permitted solely because the implementation examines values. ### Expected Behavior The rule-level headerMaxSize should have a documented size definition and enforce the complete intended header size consistently. If it is intended to mean only header values, that limitation needs to be explicit in configuration/API semantics rather than appearing to be a total request-header limit. ### Reproduction 1. Configure a divide rule with `headerMaxSize=128`, no body restriction, and any valid upstream. 2. Invoke it with a GET containing the Host field and the long empty-valued header described above. 3. Observe that the divide chain forwards the request although its header fields exceed 128 bytes. 4. Compare with the same approximate total size using a short name and a long value; this request is rejected by the rule. The reproduction invoked the actual DividePlugin.doExecute using Spring MockServerWebExchange, a populated DividePluginDataHandler cache, a populated UpstreamCacheManager and a recording downstream chain. It ran outside the deployed gateway process. A complete raw HTTP end-to-end test has not been performed for this report. ### Code Evidence [DividePlugin.java:77–87](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-divide/src/main/java/org/apache/shenyu/plugin/divide/DividePlugin.java#L77-L87): ```java long headerSize = exchange.getRequest().getHeaders().values() .stream() .flatMap(Collection::stream) .mapToLong(header -> header.getBytes(StandardCharsets.UTF_8).length) .sum(); ``` Header names are never read by this calculation. An independent parser/ingress upper bound, such as an 8 KiB Netty limit, does not enforce a smaller rule-specific value of 128 bytes; the example header is well below that outer limit. ### Suggested Fix / Coverage Define the byte-accounting contract and include field names and applicable per-value/header-line overhead. Cover an empty-valued long name, several long names with short values, multi-valued headers, exact-limit and over-limit cases. Keep parser-level protection independent from rule-level policy. ### Environment Apache ShenYu `2.7.2-SNAPSHOT`, master `04f7c2e8b7d282f14510157a9ab0bfaab538ecac`; Java 17; divide HTTP proxy path. Priority P2 / Medium. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
