From 0e6b01928eef3e456d4162b7c32fa3d09f4c9874 Mon Sep 17 00:00:00 2001 From: Wu Clan Date: Mon, 11 Mar 2024 19:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=B7=E6=B1=82=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=88=B0=E5=93=8D=E5=BA=94=E5=85=83=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=20(#164)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加请求数据到响应元数据 * ruff format --- httpfpt/common/send_request.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/httpfpt/common/send_request.py b/httpfpt/common/send_request.py index 8d25c51..9315384 100644 --- a/httpfpt/common/send_request.py +++ b/httpfpt/common/send_request.py @@ -51,6 +51,7 @@ def init_response_metadata(self) -> dict: 'stat': { 'execute_time': None, }, + 'request': None, } return response_metadata @@ -201,14 +202,16 @@ def send_request( 'params': parsed_data['params'], 'headers': parsed_data['headers'], 'cookies': parsed_data['cookies'], - 'data': parsed_data['body'], + 'body': parsed_data['body'], 'files': parsed_data['files'], } if parsed_data['body_type'] == BodyType.JSON or parsed_data['body_type'] == BodyType.GraphQL: - request_data_parsed.update({'json': request_data_parsed.pop('data')}) + request_data_parsed.update({'json': request_data_parsed.pop('body')}) elif parsed_data['body_type'] == BodyType.binary: if request_engin == EnginType.httpx: - request_data_parsed.update({'content': request_data_parsed.pop('data')}) + request_data_parsed.update({'content': request_data_parsed.pop('body')}) + else: + request_data_parsed.update({'data': request_data_parsed.pop('body')}) # 发送请求 response_data = self.init_response_metadata @@ -234,6 +237,7 @@ def send_request( response_data['json'] = json_data response_data['content'] = response.content.decode('utf-8') response_data['text'] = response.text + response_data['request'] = request_data_parsed # 日志记录响应数据 teardown = parsed_data['teardown']