Copilot commented on code in PR #13820:
URL: https://github.com/apache/trafficserver/pull/13820#discussion_r4250123792
##########
src/proxy/http2/Http2ConnectionState.cc:
##########
@@ -2714,7 +2714,8 @@ Http2ConnectionState::send_headers_frame(Http2Stream
*stream)
// explicit zero length and no end stream flag, causing the request to
// fail. We emulate chromium behaviour here prevent such RSTs.
Transfer-encoding
// implies there’s a body, regardless of whether it is chunked or not.
- bool content_method = method == HTTP_WKSIDX_POST || method ==
HTTP_WKSIDX_PUSH || method == HTTP_WKSIDX_PUT;
+ bool content_method =
+ method == HTTP_WKSIDX_POST || method == HTTP_WKSIDX_PUSH || method ==
HTTP_WKSIDX_PUT || method == HTTP_WKSIDX_QUERY;
Review Comment:
The “content-carrying methods” list is now updated in multiple places in
this PR (HTTP/2 handling, request validity checks, etc.). To reduce the risk of
future omissions when adding methods, consider centralizing this check behind a
shared helper (e.g., a `HttpTransactHeaders` predicate) and using it
consistently instead of repeating method lists.
##########
tests/gold_tests/autest-site/ats_replay.test.ext:
##########
@@ -159,9 +159,14 @@ def configure_ats(obj: 'TestRun', server: 'Process',
ats_config: dict, dns: Opti
# Configure logging.yaml if specified.
logging_yaml = ats_config.get('logging_yaml')
- if logging_yaml != None:
+ if logging_yaml is not None:
ts.Disk.logging_yaml.AddLines(yaml.dump(logging_yaml).split('\n'))
+ # Configure ip_allow.yaml if specified.
+ ip_allow_yaml = ats_config.get('ip_allow_yaml')
+ if ip_allow_yaml is not None:
+ ts.Disk.ip_allow_yaml.AddLines(yaml.dump(ip_allow_yaml).split('\n'))
Review Comment:
`yaml.dump()` can emit Python-specific tags and can vary output across
PyYAML versions, which can make tests brittle. For generated config files like
`ip_allow.yaml`, prefer `yaml.safe_dump(...)` (and, if needed, explicit dump
options like `sort_keys=False`) to keep output stable and strictly YAML.
##########
tests/gold_tests/query/query_retry_origin.py:
##########
@@ -0,0 +1,77 @@
+'''
+An origin that closes the first connection after reading the request, without
+responding, and answers every later request with a 200.
+'''
+# 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 argparse
+import socket
+import sys
+
+
+def read_request(conn: socket.socket) -> tuple[str, bytes]:
+ data = bytearray()
+ while b'\r\n\r\n' not in data:
+ chunk = conn.recv(4096)
+ if not chunk:
+ return '', b''
+ data += chunk
+ head, _, body = data.partition(b'\r\n\r\n')
+ lines = head.decode('latin-1').split('\r\n')
+ method = lines[0].split(' ')[0]
+ length = 0
+ for line in lines[1:]:
+ name, _, value = line.partition(':')
+ if name.strip().lower() == 'content-length':
+ length = int(value.strip())
+ while len(body) < length:
+ chunk = conn.recv(4096)
+ if not chunk:
+ break
+ body += chunk
+ return method, bytes(body[:length])
Review Comment:
The test origin can hang indefinitely on `accept()`/`recv()` if ATS (or a
failing test) opens a connection but never finishes sending headers/body. This
can stall CI runs. Consider setting reasonable socket timeouts (e.g., on the
accepted `conn`, and optionally on the listener) and handling `socket.timeout`
by closing the connection / emitting a diagnostic.
##########
tests/gold_tests/query/query_retry_origin.py:
##########
@@ -0,0 +1,77 @@
+'''
+An origin that closes the first connection after reading the request, without
+responding, and answers every later request with a 200.
+'''
+# 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 argparse
+import socket
+import sys
+
+
+def read_request(conn: socket.socket) -> tuple[str, bytes]:
+ data = bytearray()
+ while b'\r\n\r\n' not in data:
+ chunk = conn.recv(4096)
+ if not chunk:
+ return '', b''
+ data += chunk
+ head, _, body = data.partition(b'\r\n\r\n')
+ lines = head.decode('latin-1').split('\r\n')
+ method = lines[0].split(' ')[0]
+ length = 0
+ for line in lines[1:]:
+ name, _, value = line.partition(':')
+ if name.strip().lower() == 'content-length':
+ length = int(value.strip())
+ while len(body) < length:
+ chunk = conn.recv(4096)
+ if not chunk:
+ break
+ body += chunk
+ return method, bytes(body[:length])
+
+
+def main() -> int:
+ parser = argparse.ArgumentParser()
+ parser.add_argument('port', type=int)
+ args = parser.parse_args()
+
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as listener:
+ listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ listener.bind(('127.0.0.1', args.port))
+ listener.listen()
+ attempt = 0
+ while True:
+ conn, _ = listener.accept()
+ with conn:
+ method, body = read_request(conn)
Review Comment:
The test origin can hang indefinitely on `accept()`/`recv()` if ATS (or a
failing test) opens a connection but never finishes sending headers/body. This
can stall CI runs. Consider setting reasonable socket timeouts (e.g., on the
accepted `conn`, and optionally on the listener) and handling `socket.timeout`
by closing the connection / emitting a diagnostic.
--
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]