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


##########
src/proxy/http/HttpTransact.cc:
##########
@@ -6945,10 +6947,12 @@ HttpTransact::is_request_retryable(State *s)
     return false;
   }
 
-  // If safe requests are  retryable, it should be safe to retry safe requests 
irrespective of bytes sent or connection state
-  // according to RFC the following methods are safe 
(https://tools.ietf.org/html/rfc7231#section-4.2.1)
+  // Safe methods (RFC 9110, section 9.2.1) can be retried irrespective of 
bytes sent or connection state. QUERY
+  // (draft-ietf-httpbis-safe-method-w-body) is safe too, but its content has 
already been sent and cannot be replayed
+  // here, so once its request has gone out it is treated like an unsafe 
method. A buffered QUERY can still be retried
+  // when the origin reports it was not processed, see 
HttpSM::prepare_for_origin_retry.
   // Otherwise, if there was no error establishing the connection (and we sent 
bytes)-- we cannot retry
-  if (!HttpTransactHeaders::is_method_safe(s->method) && s->current.state != 
CONNECTION_ERROR &&
+  if ((!HttpTransactHeaders::is_method_safe(s->method) || s->method == 
HTTP_WKSIDX_QUERY) && s->current.state != CONNECTION_ERROR &&
       s->state_machine->server_request_hdr_bytes > 0) {
     return false;
   }

Review Comment:
   The comment says QUERY is treated as unsafe “once its request has gone out” 
because its *content* has been sent and can’t be replayed, but the guard uses 
`server_request_hdr_bytes > 0` (headers only). This will also block retries in 
cases where headers were sent but the request body was not (or not fully) 
transmitted. Consider keying the QUERY special-case on body bytes sent / 
request content send completion (and/or an explicit “request body 
replayable/buffered” signal) rather than header bytes, so the condition matches 
the stated semantics.



##########
tests/gold_tests/query/replay/query-remap-acl.replay.yaml:
##########
@@ -0,0 +1,90 @@
+#  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.
+
+meta:
+  version: "1.0"
+
+autest:
+  description: 'Verify a remap.config ACL can deny the QUERY method'
+
+  server:
+    name: 'server'
+
+  client:
+    name: 'client'
+
+  ats:
+    name: 'ts'
+    process_config:
+      enable_cache: false
+    records_config:
+      proxy.config.diags.debug.enabled: 1
+      proxy.config.diags.debug.tags: 'url_rewrite|ip_allow'
+    remap_config:
+      - 'map http://example.com/ http://127.0.0.1:{SERVER_HTTP_PORT}/ 
@action=deny @method=QUERY'
+
+sessions:
+- transactions:
+
+  - client-request:
+      method: QUERY
+      url: /denied
+      version: '1.1'
+      headers:
+        fields:
+        - [Host, example.com]
+        - [Content-Type, application/sql]
+        - [Content-Length, "8"]
+        - [uuid, remap-acl-denied]
+      content:
+        data: "select-a"
+
+    proxy-request:
+      expect: absent
+
+    server-response:
+      status: 200
+      reason: OK
+      headers:
+        fields:
+        - [Content-Length, "0"]
+

Review Comment:
   This transaction asserts `proxy-request: expect: absent` (origin should 
never be contacted) but still defines a `server-response`. If the replay 
harness ignores `server-response` when the proxy-request is absent, consider 
removing the `server-response` block to make the test intent clearer and avoid 
implying origin involvement in an ACL-denied flow. (If the harness requires it, 
a brief comment explaining that would also help.)



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