From 8273c96bbc166c6a01668057d838a747fe75a99d Mon Sep 17 00:00:00 2001 From: heheer Date: Thu, 10 Oct 2024 11:47:45 +0800 Subject: [PATCH] fix: form-data not display in http node log (#2868) * fix: fix form-data not display in http node log * fix --- .../core/workflow/dispatch/tools/http468.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/service/core/workflow/dispatch/tools/http468.ts b/packages/service/core/workflow/dispatch/tools/http468.ts index ac977e001..baf65faf0 100644 --- a/packages/service/core/workflow/dispatch/tools/http468.ts +++ b/packages/service/core/workflow/dispatch/tools/http468.ts @@ -184,6 +184,21 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise = (() => { + if (requestBody instanceof FormData || requestBody instanceof URLSearchParams) { + return Object.fromEntries(requestBody); + } else if (typeof requestBody === 'string') { + try { + return JSON.parse(requestBody); + } catch { + return { content: requestBody }; + } + } else if (typeof requestBody === 'object' && requestBody !== null) { + return requestBody; + } + return {}; + })(); + try { const { formatResponse, rawResponse } = await (async () => { const systemPluginCb = await getSystemPluginCb(); @@ -225,7 +240,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise 0 ? params : undefined, - body: Object.keys(requestBody).length > 0 ? requestBody : undefined, + body: Object.keys(formattedRequestBody).length > 0 ? formattedRequestBody : undefined, headers: Object.keys(headers).length > 0 ? headers : undefined, httpResult: rawResponse }, @@ -241,7 +256,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise 0 ? params : undefined, - body: Object.keys(requestBody).length > 0 ? requestBody : undefined, + body: Object.keys(formattedRequestBody).length > 0 ? formattedRequestBody : undefined, headers: Object.keys(headers).length > 0 ? headers : undefined, httpResult: { error: formatHttpError(error) } },