fix: curl redirections

This commit is contained in:
yanlong.wang 2025-03-10 13:46:18 +08:00
parent 8ec8123ff4
commit a7a41250d4
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -219,7 +219,7 @@ export class CurlControl extends AsyncService {
} }
} }
if ([301, 302, 307, 308].includes(statusCode)) { if ([301, 302, 303, 307, 308].includes(statusCode)) {
if (stream) { if (stream) {
stream.resume(); stream.resume();
} }
@ -305,7 +305,7 @@ export class CurlControl extends AsyncService {
do { do {
const r = await this.urlToFile1Shot(nextHopUrl, opts); const r = await this.urlToFile1Shot(nextHopUrl, opts);
if ([301, 302, 307, 308].includes(r.statusCode)) { if ([301, 302, 303, 307, 308].includes(r.statusCode)) {
fakeHeaderInfos.push(...r.headers); fakeHeaderInfos.push(...r.headers);
const headers = r.headers[r.headers.length - 1]; const headers = r.headers[r.headers.length - 1];
const location: string | undefined = headers.Location || headers.location; const location: string | undefined = headers.Location || headers.location;
@ -406,8 +406,15 @@ export class CurlControl extends AsyncService {
return new AssertionFailureError(msg); return new AssertionFailureError(msg);
} }
// Maybe retry but dont retry with curl again
case CurlCode.CURLE_UNSUPPORTED_PROTOCOL:
case CurlCode.CURLE_PEER_FAILED_VERIFICATION: {
return new ServiceBadApproachError(msg);
}
// Retryable errors // Retryable errors
case CurlCode.CURLE_REMOTE_ACCESS_DENIED: case CurlCode.CURLE_REMOTE_ACCESS_DENIED:
case CurlCode.CURLE_SEND_ERROR:
case CurlCode.CURLE_RECV_ERROR: case CurlCode.CURLE_RECV_ERROR:
case CurlCode.CURLE_GOT_NOTHING: case CurlCode.CURLE_GOT_NOTHING:
case CurlCode.CURLE_OPERATION_TIMEDOUT: case CurlCode.CURLE_OPERATION_TIMEDOUT: