Merge pull request #1033 from ushuz/patch-1
This commit is contained in:
@@ -1825,7 +1825,6 @@ export default {
|
|||||||
} else if (this.contentType.includes("x-www-form-urlencoded")) {
|
} else if (this.contentType.includes("x-www-form-urlencoded")) {
|
||||||
requestBody = `"${requestBody}"`
|
requestBody = `"${requestBody}"`
|
||||||
}
|
}
|
||||||
requestString.push(`xhr.setRequestHeader('Content-Length', ${requestBody.length})`)
|
|
||||||
requestString.push(
|
requestString.push(
|
||||||
`xhr.setRequestHeader('Content-Type', '${this.contentType}; charset=utf-8')`
|
`xhr.setRequestHeader('Content-Type', '${this.contentType}; charset=utf-8')`
|
||||||
)
|
)
|
||||||
@@ -1856,7 +1855,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
requestString.push(` body: ${requestBody},\n`)
|
requestString.push(` body: ${requestBody},\n`)
|
||||||
headers.push(` "Content-Length": ${requestBody.length},\n`)
|
|
||||||
headers.push(` "Content-Type": "${this.contentType}; charset=utf-8",\n`)
|
headers.push(` "Content-Type": "${this.contentType}; charset=utf-8",\n`)
|
||||||
}
|
}
|
||||||
if (this.headers) {
|
if (this.headers) {
|
||||||
@@ -1879,28 +1877,27 @@ export default {
|
|||||||
return requestString.join("")
|
return requestString.join("")
|
||||||
} else if (this.requestType === "cURL") {
|
} else if (this.requestType === "cURL") {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
requestString.push(`curl -X ${this.method} \n`)
|
requestString.push(`curl -X ${this.method}`)
|
||||||
requestString.push(` '${this.url}${this.pathName}${this.queryString}' \n`)
|
requestString.push(` '${this.url}${this.pathName}${this.queryString}'`)
|
||||||
if (this.auth === "Basic Auth") {
|
if (this.auth === "Basic Auth") {
|
||||||
const basic = `${this.httpUser}:${this.httpPassword}`
|
const basic = `${this.httpUser}:${this.httpPassword}`
|
||||||
requestString.push(
|
requestString.push(
|
||||||
` -H 'Authorization: Basic ${window.btoa(unescape(encodeURIComponent(basic)))}' \n`
|
` -H 'Authorization: Basic ${window.btoa(unescape(encodeURIComponent(basic)))}'`
|
||||||
)
|
)
|
||||||
} else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") {
|
} else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") {
|
||||||
requestString.push(` -H 'Authorization: Bearer ${this.bearerToken}' \n`)
|
requestString.push(` -H 'Authorization: Bearer ${this.bearerToken}'`)
|
||||||
}
|
}
|
||||||
if (this.headers) {
|
if (this.headers) {
|
||||||
this.headers.forEach(({ key, value }) => {
|
this.headers.forEach(({ key, value }) => {
|
||||||
if (key) requestString.push(` -H '${key}: ${value}' \n`)
|
if (key) requestString.push(` -H '${key}: ${value}'`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(this.method)) {
|
if (["POST", "PUT", "PATCH", "DELETE"].includes(this.method)) {
|
||||||
const requestBody = this.rawInput ? this.rawParams : this.rawRequestBody
|
const requestBody = this.rawInput ? this.rawParams : this.rawRequestBody
|
||||||
requestString.push(` -H 'Content-Length: ${requestBody.length}' \n`)
|
requestString.push(` -H 'Content-Type: ${this.contentType}; charset=utf-8'`)
|
||||||
requestString.push(` -H 'Content-Type: ${this.contentType}; charset=utf-8' \n`)
|
requestString.push(` -d '${requestBody}'`)
|
||||||
requestString.push(` -d '${requestBody}' \n`)
|
|
||||||
}
|
}
|
||||||
return requestString.join("").slice(0, -2)
|
return requestString.join(" \\\n")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tokenReqDetails() {
|
tokenReqDetails() {
|
||||||
@@ -2022,13 +2019,11 @@ export default {
|
|||||||
if (headers[id].key) headersObject[headers[id].key] = headers[id].value
|
if (headers[id].key) headersObject[headers[id].key] = headers[id].value
|
||||||
})
|
})
|
||||||
headers = headersObject
|
headers = headersObject
|
||||||
// If the request has a body, we want to ensure Content-Length and
|
// If the request has a body, we want to ensure Content-Type is sent.
|
||||||
// Content-Type are sent.
|
|
||||||
let requestBody
|
let requestBody
|
||||||
if (this.hasRequestBody) {
|
if (this.hasRequestBody) {
|
||||||
requestBody = this.rawInput ? this.rawParams : this.rawRequestBody
|
requestBody = this.rawInput ? this.rawParams : this.rawRequestBody
|
||||||
Object.assign(headers, {
|
Object.assign(headers, {
|
||||||
//'Content-Length': requestBody.length,
|
|
||||||
"Content-Type": `${this.contentType}; charset=utf-8`,
|
"Content-Type": `${this.contentType}; charset=utf-8`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user