fix: curl response headers

This commit is contained in:
yanlong.wang 2025-02-19 15:18:38 +08:00
parent d749809966
commit 7f04a65548
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -108,19 +108,17 @@ export class CurlControl extends AsyncService {
let contentEncoding = '';
curl.on('stream', (stream, statusCode, headers) => {
status = statusCode;
outerLoop:
for (const headerVec of headers) {
for (const [k, v] of Object.entries(headerVec)) {
const kl = k.toLowerCase();
if (kl === 'content-type') {
contentType = v.toLowerCase();
}
if (kl === 'content-encoding') {
contentEncoding = v.toLowerCase();
}
if (contentType && contentEncoding) {
break outerLoop;
}
const lastResHeaders = headers[headers.length - 1];
for (const [k, v] of Object.entries(lastResHeaders)) {
const kl = k.toLowerCase();
if (kl === 'content-type') {
contentType = v.toLowerCase();
}
if (kl === 'content-encoding') {
contentEncoding = v.toLowerCase();
}
if (contentType && contentEncoding) {
break;
}
}