Copilot commented on code in PR #61903:
URL: https://github.com/apache/doris/pull/61903#discussion_r3010418627


##########
regression-test/suites/http_p0/test_large_http_header.groovy:
##########
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_large_http_header", "p0") {
+    def feHost = context.config.feHttpAddress
+    def (host, port) = feHost.split(":")
+
+    // Test with large HTTP header (100KB)
+    def largeHeaderValue = "x" * (100 * 1024)
+
+    def url = "http://${host}:${port}/api/health";
+

Review Comment:
   This test always targets `http://...` without considering 
`context.config.otherConfigs['enableTLS']`. In TLS-enabled runs the FE may 
redirect to HTTPS, and `HttpURLConnection` will follow redirects but fail SSL 
validation unless the suite configures trust/key stores (as other HTTP suites 
do). Consider selecting the protocol based on `enableTLS` and using the 
regression framework's HTTP/TLS helper to configure SSL context when needed.



##########
fe/fe-core/src/main/java/org/apache/doris/httpv2/config/WebServerFactoryCustomizerConfig.java:
##########
@@ -33,6 +33,21 @@
 public class WebServerFactoryCustomizerConfig implements 
WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> {
     @Override
     public void customize(ConfigurableJettyWebServerFactory factory) {
+
+        // Set HTTP header size for all connectors
+        factory.addServerCustomizers(server -> {
+            for (org.eclipse.jetty.server.Connector connector : 
server.getConnectors()) {
+                if (connector instanceof ServerConnector) {
+                    ServerConnector serverConnector = (ServerConnector) 
connector;
+                    HttpConnectionFactory httpFactory =
+                            
serverConnector.getConnectionFactory(HttpConnectionFactory.class);
+                    if (httpFactory != null) {
+                        HttpConfiguration httpConfig = 
httpFactory.getHttpConfiguration();
+                        
httpConfig.setRequestHeaderSize(Config.jetty_server_max_http_header_size);
+                    }
+                }
+            }
+        });

Review Comment:
   When `Config.enable_https` is true, a new HTTP `ServerConnector` is added 
later (in the second `addServerCustomizers` block) with its own 
`HttpConfiguration`. The earlier customizer that iterates 
`server.getConnectors()` won't configure this newly-added connector, so the 
HTTP connector may still use Jetty's default request header size and continue 
to reject large headers. Apply `Config.jetty_server_max_http_header_size` to 
the `HttpConfiguration` created for the extra connector (or run the sizing pass 
after all connectors are added).



##########
regression-test/suites/http_p0/test_large_http_header.groovy:
##########
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_large_http_header", "p0") {
+    def feHost = context.config.feHttpAddress
+    def (host, port) = feHost.split(":")
+
+    // Test with large HTTP header (100KB)
+    def largeHeaderValue = "x" * (100 * 1024)
+
+    def url = "http://${host}:${port}/api/health";
+
+    try {
+        def connection = new URL(url).openConnection()
+        connection.setRequestMethod("GET")
+        connection.setRequestProperty("X-Large-Header", largeHeaderValue)
+        connection.setConnectTimeout(5000)
+        connection.setReadTimeout(5000)
+
+        def responseCode = connection.getResponseCode()
+
+        // Should not return 431 (Request Header Fields Too Large)
+        assertTrue(responseCode != 431, "Should not return 431 error with 
large header")

Review Comment:
   The assertion only checks `responseCode != 431`, so the test can pass even 
if the endpoint returns an unexpected status (e.g., 404/500) unrelated to 
header sizing. Tighten the assertion to ensure the request is actually 
processed successfully (or explicitly allow the small set of expected statuses 
for `/api/health`, such as 200/503 when not ready) while still verifying it 
doesn't fail with 431.
   ```suggestion
           assertTrue(responseCode != 431, "Should not return 431 error with 
large header")
           // And should return a valid health-check status (200 OK or 503 when 
not ready)
           assertTrue(responseCode == 200 || responseCode == 503,
                   "Unexpected response code ${responseCode} for /api/health, 
expected 200 or 503")
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to