brbzull0 commented on code in PR #13032: URL: https://github.com/apache/trafficserver/pull/13032#discussion_r4269731727
########## tests/gold_tests/traffic_ctl/jsonrpc_error_stub.py: ########## @@ -0,0 +1,81 @@ +''' +A stand-in JSONRPC node for traffic_ctl tests. It answers every request with +the reply configured for its method, so a test can show traffic_ctl server +errors that no real handler produces. A method configured with a list of +replies gets them in turn, starting over after the last one. +''' +# 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 json +import os +import socket + +METHOD_NOT_FOUND = {'error': {'code': -32601, 'message': 'Method not found'}} + + +def read_request(conn: socket.socket) -> dict | None: + data = b'' + while True: + chunk = conn.recv(65536) + if not chunk: + return None + data += chunk + try: + return json.loads(data) Review Comment: No change. traffic_ctl sends one request per connection: `RPCClient::invoke` connects, sends, reads the reply and disconnects. A second JSON value never arrives on the same connection. -- 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]
