mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2026-02-05 17:17:21 +08:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60b4626721 | ||
|
|
586518fec3 | ||
|
|
0a8bc3c016 | ||
|
|
f4f70998eb | ||
|
|
4b51642463 | ||
|
|
ad07b6cac3 | ||
|
|
4a2ead4d55 | ||
|
|
315ec27690 | ||
|
|
68b6b7f418 | ||
|
|
fb4418ffc0 | ||
|
|
187b77b4ea |
1467
dist/index.js
vendored
1467
dist/index.js
vendored
File diff suppressed because one or more lines are too long
13
package-lock.json
generated
13
package-lock.json
generated
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"name": "http-request-action",
|
||||
"version": "1.16.2",
|
||||
"version": "1.14.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "http-request-action",
|
||||
"version": "1.16.2",
|
||||
"version": "1.14.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.38.2",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"axios": "^1.7",
|
||||
"form-data": "^4.0.0",
|
||||
"yargs": "^17.7.2"
|
||||
@@ -51,10 +51,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vercel/ncc": {
|
||||
"version": "0.38.2",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.2.tgz",
|
||||
"integrity": "sha512-3yel3jaxUg9pHBv4+KeC9qlbdZPug+UMtUOlhvpDYCMSgcNSrS2Hv1LoqMsOV7hf2lYscx+BESfJOIla1WsmMQ==",
|
||||
"version": "0.38.1",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz",
|
||||
"integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"ncc": "dist/ncc/cli.js"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "http-request-action",
|
||||
"version": "1.16.2",
|
||||
"version": "1.14.2",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"private": false,
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/fjogeleit/http-request-action#readme",
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.38.2",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"axios": "^1.7",
|
||||
"form-data": "^4.0.0",
|
||||
"yargs": "^17.7.2"
|
||||
|
||||
@@ -24,7 +24,7 @@ const convertToJSON = (value) => {
|
||||
*
|
||||
* @returns {FormData}
|
||||
*/
|
||||
const convertToFormData = (data, files) => {
|
||||
const convertToFormData = (data, files, convertPaths) => {
|
||||
const formData = new FormData();
|
||||
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
|
||||
@@ -53,17 +53,11 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +129,7 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
||||
if (error.response) {
|
||||
actions.setFailed(JSON.stringify({ code: error.response.status, message: error.response.data }))
|
||||
} else if (error.request) {
|
||||
actions.setFailed(JSON.stringify({ error: "no response received", message: error.message }));
|
||||
actions.setFailed(JSON.stringify({ error: "no response received" }));
|
||||
} else {
|
||||
actions.setFailed(JSON.stringify({ message: error.message, data }));
|
||||
}
|
||||
@@ -145,10 +139,12 @@ 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) => {
|
||||
const updateConfig = async (instanceConfig, formData, actions) => {
|
||||
try {
|
||||
const formHeaders = formData.getHeaders()
|
||||
const contentType = formHeaders['content-type']
|
||||
|
||||
@@ -163,6 +159,9 @@ const updateConfig = async (instanceConfig, formData) => {
|
||||
'Content-Type': contentType
|
||||
}
|
||||
}
|
||||
} catch(error) {
|
||||
actions.setFailed({ message: `Unable to read Content-Length: ${error.message}`, data, files })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user