mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2026-02-04 16:45:52 +08:00
Update FileUpload ContentType
This commit is contained in:
18
dist/index.js
vendored
18
dist/index.js
vendored
@@ -1342,8 +1342,6 @@ const METHOD_POST = 'POST'
|
||||
|
||||
const request = async({ method, instanceConfig, data, files, auth, actions, preventFailureOnNoResponse, escapeData }) => {
|
||||
try {
|
||||
const instance = axios.create(instanceConfig);
|
||||
|
||||
if (escapeData) {
|
||||
data = data.replace(/"[^"]*"/g, (match) => {
|
||||
return match.replace(/[\n\r]\s*/g, "\\n");
|
||||
@@ -1375,6 +1373,10 @@ const request = async({ method, instanceConfig, data, files, auth, actions, prev
|
||||
data
|
||||
}
|
||||
|
||||
actions.debug('Instance Configuration: ' + JSON.stringify(instanceConfig))
|
||||
|
||||
const instance = axios.create(instanceConfig);
|
||||
|
||||
actions.debug('Request Data: ' + JSON.stringify(requestData))
|
||||
|
||||
const response = await instance.request(requestData)
|
||||
@@ -1421,12 +1423,18 @@ const convertToFormData = (data, files) => {
|
||||
|
||||
const updateConfig = async (instanceConfig, formData, actions) => {
|
||||
try {
|
||||
const formHeaders = formData.getHeaders()
|
||||
const contentType = formHeaders['content-type']
|
||||
|
||||
delete formHeaders['content-type']
|
||||
|
||||
return {
|
||||
...instanceConfig,
|
||||
headers: {
|
||||
...instanceConfig.headers,
|
||||
...formData.getHeaders(),
|
||||
'Content-Length': await contentLength(formData)
|
||||
...formHeaders,
|
||||
'Content-Length': await contentLength(formData),
|
||||
'Content-Type': contentType
|
||||
}
|
||||
}
|
||||
} catch(error) {
|
||||
@@ -3561,8 +3569,6 @@ const instanceConfig = {
|
||||
headers: { ...headers, ...customHeaders }
|
||||
}
|
||||
|
||||
core.debug('Instance Configuration: ' + JSON.stringify(instanceConfig))
|
||||
|
||||
const data = core.getInput('data') || '{}';
|
||||
const files = core.getInput('files') || '{}';
|
||||
const method = core.getInput('method') || METHOD_POST;
|
||||
|
||||
Reference in New Issue
Block a user