mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader.git
synced 2025-08-19 05:05:59 +08:00
fix: curl redirection location
This commit is contained in:
parent
fb43578fdd
commit
63a2e15f4d
@ -10,7 +10,7 @@ import { AssertionFailureError, FancyFile } from 'civkit';
|
||||
import { ServiceBadAttemptError, TempFileManager } from '../shared';
|
||||
import { createBrotliDecompress, createInflate, createGunzip } from 'zlib';
|
||||
import { ZSTDDecompress } from 'simple-zstd';
|
||||
import _, { set } from 'lodash';
|
||||
import _ from 'lodash';
|
||||
import { Readable } from 'stream';
|
||||
import { AsyncLocalContext } from './async-context';
|
||||
|
||||
@ -277,7 +277,7 @@ export class CurlControl extends AsyncService {
|
||||
|
||||
if ([301, 302, 307, 308].includes(r.statusCode)) {
|
||||
const headers = r.headers[r.headers.length - 1];
|
||||
const location = headers.Location || headers.location;
|
||||
const location: string | undefined = headers.Location || headers.location;
|
||||
|
||||
const setCookieHeader = headers['Set-Cookie'] || headers['set-cookie'];
|
||||
if (setCookieHeader) {
|
||||
@ -292,7 +292,7 @@ export class CurlControl extends AsyncService {
|
||||
throw new AssertionFailureError(`Failed to access ${urlToCrawl}: Bad redirection from ${nextHopUrl}`);
|
||||
}
|
||||
|
||||
nextHopUrl = new URL(location, nextHopUrl);
|
||||
nextHopUrl = new URL(location || '', nextHopUrl);
|
||||
fakeHeaderInfos.push(...r.headers);
|
||||
leftRedirection -= 1;
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user