@crawlee/http-client 4.0.0-beta.113 → 4.0.0-beta.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base-http-client.d.ts +1 -2
- package/base-http-client.js +8 -5
- package/package.json +3 -3
package/base-http-client.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { BaseHttpClient as BaseHttpClientInterface, CrawleeLogger, SendRequestOptions, SessionFingerprint } from '@crawlee/types';
|
|
2
|
-
import { CookieJar } from 'tough-cookie';
|
|
1
|
+
import type { BaseHttpClient as BaseHttpClientInterface, CookieJar, CrawleeLogger, SendRequestOptions, SessionFingerprint } from '@crawlee/types';
|
|
3
2
|
/**
|
|
4
3
|
* Per-request options handed to a concrete client's `fetch` implementation.
|
|
5
4
|
*/
|
package/base-http-client.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CookieJar } from 'tough-cookie';
|
|
2
1
|
/**
|
|
3
2
|
* Base HTTP client that provides fetch-like `sendRequest` with Crawlee-managed
|
|
4
3
|
* behaviors (redirect handling, proxy and cookie handling). Concrete clients
|
|
@@ -48,17 +47,21 @@ export class BaseHttpClient {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
|
-
resolveRequestContext(options) {
|
|
50
|
+
async resolveRequestContext(options) {
|
|
52
51
|
const proxyUrl = options?.proxyUrl ?? options?.session?.proxyInfo?.url;
|
|
53
|
-
const cookieJar = options?.cookieJar ?? options?.session?.cookieJar ??
|
|
52
|
+
const cookieJar = options?.cookieJar ?? options?.session?.cookieJar ?? (await this.#createDefaultCookieJar());
|
|
54
53
|
const signal = this.createAbortSignal(options?.signal, options?.timeoutMillis);
|
|
55
54
|
return {
|
|
56
55
|
proxyUrl,
|
|
57
|
-
cookieJar
|
|
56
|
+
cookieJar,
|
|
58
57
|
signal,
|
|
59
58
|
fingerprint: options?.session?.fingerprint,
|
|
60
59
|
};
|
|
61
60
|
}
|
|
61
|
+
async #createDefaultCookieJar() {
|
|
62
|
+
const { CookieJar: ToughCookieJar } = await import('tough-cookie');
|
|
63
|
+
return new ToughCookieJar();
|
|
64
|
+
}
|
|
62
65
|
createAbortSignal(signal, timeoutMillis) {
|
|
63
66
|
if (signal && timeoutMillis) {
|
|
64
67
|
return AbortSignal.any([signal, AbortSignal.timeout(timeoutMillis)]);
|
|
@@ -104,7 +107,7 @@ export class BaseHttpClient {
|
|
|
104
107
|
const maxRedirects = 10;
|
|
105
108
|
let currentRequest = initialRequest;
|
|
106
109
|
let redirectCount = 0;
|
|
107
|
-
const { proxyUrl, cookieJar, signal, fingerprint } = this.resolveRequestContext(options);
|
|
110
|
+
const { proxyUrl, cookieJar, signal, fingerprint } = await this.resolveRequestContext(options);
|
|
108
111
|
currentRequest = initialRequest.clone();
|
|
109
112
|
while (true) {
|
|
110
113
|
await this.applyCookies(currentRequest, cookieJar);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/http-client",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.114",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@crawlee/types": "4.0.0-beta.
|
|
50
|
+
"@crawlee/types": "4.0.0-beta.114",
|
|
51
51
|
"tough-cookie": "^6.0.0"
|
|
52
52
|
},
|
|
53
53
|
"lerna": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "e00fd1671498a90451e62730d58cae1f5d89f2be"
|
|
61
61
|
}
|