mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-11-24 12:50:56 -05:00
stop execution after read content-length error
Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
This commit is contained in:
parent
c54053fb4a
commit
bf78da1411
2 changed files with 16 additions and 14 deletions
15
dist/index.js
vendored
15
dist/index.js
vendored
|
@ -27559,11 +27559,17 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
||||||
if (Object.keys(filesJson).length > 0) {
|
if (Object.keys(filesJson).length > 0) {
|
||||||
try {
|
try {
|
||||||
data = convertToFormData(dataJson, filesJson)
|
data = convertToFormData(dataJson, filesJson)
|
||||||
instanceConfig = await updateConfig(instanceConfig, data, actions)
|
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
actions.setFailed(JSON.stringify({ message: `Unable to convert Data and Files into FormData: ${error.message}`, data: dataJson, files: filesJson }))
|
actions.setFailed(JSON.stringify({ message: `Unable to convert Data and Files into FormData: ${error.message}`, data: dataJson, files: filesJson }))
|
||||||
return
|
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 {{ baseURL: string; timeout: number; headers: { [name: string]: string } }} instanceConfig
|
||||||
* @param {FormData} formData
|
* @param {FormData} formData
|
||||||
* @param {*} actions
|
|
||||||
*
|
*
|
||||||
* @returns {Promise<{ baseURL: string; timeout: number; headers: { [name: string]: string } }>}
|
* @returns {Promise<{ baseURL: string; timeout: number; headers: { [name: string]: string } }>}
|
||||||
*/
|
*/
|
||||||
const updateConfig = async (instanceConfig, formData, actions) => {
|
const updateConfig = async (instanceConfig, formData) => {
|
||||||
try {
|
|
||||||
const formHeaders = formData.getHeaders()
|
const formHeaders = formData.getHeaders()
|
||||||
const contentType = formHeaders['content-type']
|
const contentType = formHeaders['content-type']
|
||||||
|
|
||||||
|
@ -27665,9 +27669,6 @@ const updateConfig = async (instanceConfig, formData, actions) => {
|
||||||
'Content-Type': contentType
|
'Content-Type': contentType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(error) {
|
|
||||||
actions.setFailed(JSON.stringify({ message: `Unable to read Content-Length: ${error.message}` }))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,11 +53,17 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
||||||
if (Object.keys(filesJson).length > 0) {
|
if (Object.keys(filesJson).length > 0) {
|
||||||
try {
|
try {
|
||||||
data = convertToFormData(dataJson, filesJson)
|
data = convertToFormData(dataJson, filesJson)
|
||||||
instanceConfig = await updateConfig(instanceConfig, data, actions)
|
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
actions.setFailed(JSON.stringify({ message: `Unable to convert Data and Files into FormData: ${error.message}`, data: dataJson, files: filesJson }))
|
actions.setFailed(JSON.stringify({ message: `Unable to convert Data and Files into FormData: ${error.message}`, data: dataJson, files: filesJson }))
|
||||||
return
|
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 {{ baseURL: string; timeout: number; headers: { [name: string]: string } }} instanceConfig
|
||||||
* @param {FormData} formData
|
* @param {FormData} formData
|
||||||
* @param {*} actions
|
|
||||||
*
|
*
|
||||||
* @returns {Promise<{ baseURL: string; timeout: number; headers: { [name: string]: string } }>}
|
* @returns {Promise<{ baseURL: string; timeout: number; headers: { [name: string]: string } }>}
|
||||||
*/
|
*/
|
||||||
const updateConfig = async (instanceConfig, formData, actions) => {
|
const updateConfig = async (instanceConfig, formData) => {
|
||||||
try {
|
|
||||||
const formHeaders = formData.getHeaders()
|
const formHeaders = formData.getHeaders()
|
||||||
const contentType = formHeaders['content-type']
|
const contentType = formHeaders['content-type']
|
||||||
|
|
||||||
|
@ -159,9 +163,6 @@ const updateConfig = async (instanceConfig, formData, actions) => {
|
||||||
'Content-Type': contentType
|
'Content-Type': contentType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(error) {
|
|
||||||
actions.setFailed(JSON.stringify({ message: `Unable to read Content-Length: ${error.message}` }))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue