From bf78da14118941f7e940279dd58f67e863cbeff6 Mon Sep 17 00:00:00 2001 From: Frank Jogeleit Date: Sun, 6 Oct 2024 15:52:01 +0200 Subject: [PATCH] stop execution after read content-length error Signed-off-by: Frank Jogeleit --- dist/index.js | 15 ++++++++------- src/httpClient.js | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/dist/index.js b/dist/index.js index 532b964..7740429 100644 --- a/dist/index.js +++ b/dist/index.js @@ -27559,11 +27559,17 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti if (Object.keys(filesJson).length > 0) { try { data = convertToFormData(dataJson, filesJson) - instanceConfig = await updateConfig(instanceConfig, data, actions) } catch(error) { actions.setFailed(JSON.stringify({ message: `Unable to convert Data and Files into FormData: ${error.message}`, data: dataJson, files: filesJson })) return } + + try { + instanceConfig = await updateConfig(instanceConfig, data) + } catch(error) { + actions.setFailed(JSON.stringify({ message: `Unable to read Content-Length: ${error.message}` })) + return + } } } @@ -27645,12 +27651,10 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti /** * @param {{ baseURL: string; timeout: number; headers: { [name: string]: string } }} instanceConfig * @param {FormData} formData - * @param {*} actions * * @returns {Promise<{ baseURL: string; timeout: number; headers: { [name: string]: string } }>} */ -const updateConfig = async (instanceConfig, formData, actions) => { - try { +const updateConfig = async (instanceConfig, formData) => { const formHeaders = formData.getHeaders() const contentType = formHeaders['content-type'] @@ -27665,9 +27669,6 @@ const updateConfig = async (instanceConfig, formData, actions) => { 'Content-Type': contentType } } - } catch(error) { - actions.setFailed(JSON.stringify({ message: `Unable to read Content-Length: ${error.message}` })) - } } /** diff --git a/src/httpClient.js b/src/httpClient.js index f91cf78..223e72b 100644 --- a/src/httpClient.js +++ b/src/httpClient.js @@ -53,11 +53,17 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti if (Object.keys(filesJson).length > 0) { try { data = convertToFormData(dataJson, filesJson) - instanceConfig = await updateConfig(instanceConfig, data, actions) } catch(error) { actions.setFailed(JSON.stringify({ message: `Unable to convert Data and Files into FormData: ${error.message}`, data: dataJson, files: filesJson })) return } + + try { + instanceConfig = await updateConfig(instanceConfig, data) + } catch(error) { + actions.setFailed(JSON.stringify({ message: `Unable to read Content-Length: ${error.message}` })) + return + } } } @@ -139,12 +145,10 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti /** * @param {{ baseURL: string; timeout: number; headers: { [name: string]: string } }} instanceConfig * @param {FormData} formData - * @param {*} actions * * @returns {Promise<{ baseURL: string; timeout: number; headers: { [name: string]: string } }>} */ -const updateConfig = async (instanceConfig, formData, actions) => { - try { +const updateConfig = async (instanceConfig, formData) => { const formHeaders = formData.getHeaders() const contentType = formHeaders['content-type'] @@ -159,9 +163,6 @@ const updateConfig = async (instanceConfig, formData, actions) => { 'Content-Type': contentType } } - } catch(error) { - actions.setFailed(JSON.stringify({ message: `Unable to read Content-Length: ${error.message}` })) - } } /**