From faf1a9187b1bb8fe9bbf31245ee69a313f297f4b Mon Sep 17 00:00:00 2001 From: Lawrence-lkq <252777329@qq.com> Date: Wed, 14 Aug 2024 10:30:13 +0800 Subject: [PATCH] fix:api_test curl --- .../apigateway/apis/web/api_test/views.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dashboard/apigateway/apigateway/apis/web/api_test/views.py b/src/dashboard/apigateway/apigateway/apis/web/api_test/views.py index 45dbc795a..152934a26 100644 --- a/src/dashboard/apigateway/apigateway/apis/web/api_test/views.py +++ b/src/dashboard/apigateway/apigateway/apis/web/api_test/views.py @@ -162,17 +162,21 @@ def post(self, request, *args, **kwargs): ) def _get_response_data(self, response, headers_without_sensitive=Dict[str, Any], verify=False): + # 去掉 curl 字符串的换行 + original_curl = to_curl( + response.request, + verify=verify, + headers=headers_without_sensitive, + ) + modified_curl = original_curl.replace("\n", "") + return { "status_code": response.status_code, "proxy_time": round(convert_second_to_epoch_millisecond(response.elapsed.total_seconds())), "size": "{:.2f}".format(len(response.content) / 1024), "body": response.text, "headers": dict(response.headers), - "curl": to_curl( - response.request, - verify=verify, - headers=headers_without_sensitive, - ), + "curl": modified_curl, } def _get_authorization_from_cookies(self) -> Dict[str, str]: