Copilot commented on code in PR #13820:
URL: https://github.com/apache/trafficserver/pull/13820#discussion_r4259005128


##########
src/proxy/http/HttpTransact.cc:
##########
@@ -5819,9 +5819,9 @@ HttpTransact::check_request_validity(State *s, HTTPHdr 
*incoming_hdr)
       return RequestError_t::UNACCEPTABLE_TE_REQUIRED;
     }
 
-    // Require Content-Length/Transfer-Encoding for POST/PUSH/PUT
+    // Require Content-Length/Transfer-Encoding for POST/PUSH/PUT/QUERY
     if ((scheme == URL_WKSIDX_HTTP || scheme == URL_WKSIDX_HTTPS) &&
-        (method == HTTP_WKSIDX_POST || method == HTTP_WKSIDX_PUSH || method == 
HTTP_WKSIDX_PUT) &&
+        (method == HTTP_WKSIDX_POST || method == HTTP_WKSIDX_PUSH || method == 
HTTP_WKSIDX_PUT || method == HTTP_WKSIDX_QUERY) &&

Review Comment:
   The set of ‘content-carrying’ methods is now duplicated across multiple call 
sites (e.g., request validity checks here, HTTP/2 header framing logic, 
`Expect: 100-continue` handling, and server-session privacy decisions). This 
increases the risk of future inconsistencies when additional methods are 
added/changed. Consider factoring this into a single helper (e.g., 
`HttpTransactHeaders::method_allows_request_body()` / 
`is_method_content_carrying()`) and reusing it across these code paths.



##########
tests/gold_tests/query/query-retry.test.py:
##########
@@ -0,0 +1,79 @@
+'''
+Verify QUERY is not retried once its request, content included, has been sent
+to an origin that then closes the connection, whether or not request buffering
+is enabled.
+'''
+#  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.
+
+import re
+import sys
+
+from ports import get_port
+
+Test.Summary = '''
+Verify QUERY is not retried once its request, content included, has been sent
+to an origin that then closes the connection, whether or not request buffering
+is enabled.
+'''
+
+Test.ContinueOnFail = True
+
+BODY = 'SELECT * FROM t WHERE a'
+
+
+def add_scenario(name: str, method: str, buffering: bool) -> None:
+    tr = Test.AddTestRun(f'{method} after the origin closes, request buffering 
{"enabled" if buffering else "disabled"}')
+    tr.Setup.Copy('query_retry_origin.py')
+
+    server = Test.Processes.Process(f'origin-{name}')
+    server_port = get_port(server, 'http_port')
+    server.Command = f'{sys.executable} 
{tr.RunDirectory}/query_retry_origin.py {server_port}'
+    server.Ready = When.PortOpen(server_port)
+
+    ts = Test.MakeATSProcess(f'ts-{name}')
+    ts.Disk.records_config.update(
+        {
+            'proxy.config.http.request_buffer_enabled': 1 if buffering else 0,
+            'proxy.config.http.connect_attempts_max_retries': 3,
+            'proxy.config.diags.debug.enabled': 1,
+            'proxy.config.diags.debug.tags': 'http_trans',
+        })
+    ts.Disk.remap_config.AddLine(f'map / http://127.0.0.1:{server_port}/')
+
+    content = f"-H 'Content-Type: application/sql' --data-binary '{BODY}' " if 
method == 'QUERY' else ''
+    tr.Processes.Default.StartBefore(server)
+    tr.Processes.Default.StartBefore(ts)
+    tr.Processes.Default.Command = (
+        f"curl -s -o /dev/null -w '%{{http_code}}\\n' -X {method} 
{content}http://127.0.0.1:{ts.Variables.port}/search";)

Review Comment:
   Building a shell command by interpolating request body content into single 
quotes is brittle (e.g., if `BODY` ever contains a `'`, newlines, or other 
shell-significant characters). To make the test more robust, consider passing 
the payload via stdin or a temporary file (e.g., `--data-binary @-` or `@file`) 
and avoiding direct body interpolation in the command string.



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

Reply via email to