1
0
Fork 0
mirror of synced 2024-09-21 03:43:21 +12:00

Fixing an issue with error cases that have a content-disposition being downloaded as a file.

This commit is contained in:
mike12345567 2024-05-31 16:07:46 +01:00
parent 52c1d505ef
commit 9912904bd1

View file

@ -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