Fixing an issue with error cases that have a content-disposition being downloaded as a file.
This commit is contained in:
parent
52c1d505ef
commit
9912904bd1
|
@ -149,13 +149,12 @@ class RestIntegration implements IntegrationBase {
|
||||||
{ downloadImages: this.config.downloadImages }
|
{ downloadImages: this.config.downloadImages }
|
||||||
)
|
)
|
||||||
let contentLength = response.headers.get("content-length")
|
let contentLength = response.headers.get("content-length")
|
||||||
if (!contentLength && raw) {
|
let isSuccess = response.status >= 200 && response.status < 300
|
||||||
contentLength = Buffer.byteLength(raw, "utf8").toString()
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
contentDisposition.includes("filename") ||
|
(contentDisposition.includes("filename") ||
|
||||||
contentDisposition.includes("attachment") ||
|
contentDisposition.includes("attachment") ||
|
||||||
contentDisposition.includes("form-data")
|
contentDisposition.includes("form-data")) &&
|
||||||
|
isSuccess
|
||||||
) {
|
) {
|
||||||
filename =
|
filename =
|
||||||
path.basename(parse(contentDisposition).parameters?.filename) || ""
|
path.basename(parse(contentDisposition).parameters?.filename) || ""
|
||||||
|
@ -168,6 +167,9 @@ class RestIntegration implements IntegrationBase {
|
||||||
return handleFileResponse(response, filename, this.startTimeMs)
|
return handleFileResponse(response, filename, this.startTimeMs)
|
||||||
} else {
|
} else {
|
||||||
responseTxt = response.text ? await response.text() : ""
|
responseTxt = response.text ? await response.text() : ""
|
||||||
|
if (!contentLength && responseTxt) {
|
||||||
|
contentLength = Buffer.byteLength(responseTxt, "utf8").toString()
|
||||||
|
}
|
||||||
const hasContent =
|
const hasContent =
|
||||||
(contentLength && parseInt(contentLength) > 0) ||
|
(contentLength && parseInt(contentLength) > 0) ||
|
||||||
responseTxt.length > 0
|
responseTxt.length > 0
|
||||||
|
|
Loading…
Reference in New Issue