Skip to content

Commit

Permalink
stop execution after read content-length error
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
  • Loading branch information
fjogeleit committed Oct 6, 2024
1 parent c54053f commit bf78da1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
15 changes: 8 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down Expand Up @@ -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']

Expand All @@ -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}` }))
}
}

/**
Expand Down
15 changes: 8 additions & 7 deletions src/httpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down Expand Up @@ -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']

Expand All @@ -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}` }))
}
}

/**
Expand Down

0 comments on commit bf78da1

Please sign in to comment.