nomagick commited on
Commit
a7a4125
·
unverified ·
1 Parent(s): 8ec8123

fix: curl redirections

Browse files
Files changed (1) hide show
  1. src/services/curl.ts +11 -4
src/services/curl.ts CHANGED
@@ -219,7 +219,7 @@ export class CurlControl extends AsyncService {
219
  }
220
  }
221
 
222
- if ([301, 302, 307, 308].includes(statusCode)) {
223
  if (stream) {
224
  stream.resume();
225
  }
@@ -305,7 +305,7 @@ export class CurlControl extends AsyncService {
305
  do {
306
  const r = await this.urlToFile1Shot(nextHopUrl, opts);
307
 
308
- if ([301, 302, 307, 308].includes(r.statusCode)) {
309
  fakeHeaderInfos.push(...r.headers);
310
  const headers = r.headers[r.headers.length - 1];
311
  const location: string | undefined = headers.Location || headers.location;
@@ -402,12 +402,19 @@ export class CurlControl extends AsyncService {
402
  switch (code) {
403
  // 400 User errors
404
  case CurlCode.CURLE_COULDNT_RESOLVE_HOST:
405
- {
406
- return new AssertionFailureError(msg);
 
 
 
 
 
 
407
  }
408
 
409
  // Retryable errors
410
  case CurlCode.CURLE_REMOTE_ACCESS_DENIED:
 
411
  case CurlCode.CURLE_RECV_ERROR:
412
  case CurlCode.CURLE_GOT_NOTHING:
413
  case CurlCode.CURLE_OPERATION_TIMEDOUT:
 
219
  }
220
  }
221
 
222
+ if ([301, 302, 303, 307, 308].includes(statusCode)) {
223
  if (stream) {
224
  stream.resume();
225
  }
 
305
  do {
306
  const r = await this.urlToFile1Shot(nextHopUrl, opts);
307
 
308
+ if ([301, 302, 303, 307, 308].includes(r.statusCode)) {
309
  fakeHeaderInfos.push(...r.headers);
310
  const headers = r.headers[r.headers.length - 1];
311
  const location: string | undefined = headers.Location || headers.location;
 
402
  switch (code) {
403
  // 400 User errors
404
  case CurlCode.CURLE_COULDNT_RESOLVE_HOST:
405
+ {
406
+ return new AssertionFailureError(msg);
407
+ }
408
+
409
+ // Maybe retry but dont retry with curl again
410
+ case CurlCode.CURLE_UNSUPPORTED_PROTOCOL:
411
+ case CurlCode.CURLE_PEER_FAILED_VERIFICATION: {
412
+ return new ServiceBadApproachError(msg);
413
  }
414
 
415
  // Retryable errors
416
  case CurlCode.CURLE_REMOTE_ACCESS_DENIED:
417
+ case CurlCode.CURLE_SEND_ERROR:
418
  case CurlCode.CURLE_RECV_ERROR:
419
  case CurlCode.CURLE_GOT_NOTHING:
420
  case CurlCode.CURLE_OPERATION_TIMEDOUT: