@crawlee/http-client 4.0.0-beta.115 → 4.0.0-beta.117
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 +8 -0
- package/base-http-client.js +3 -1
- package/fetch-http-client.d.ts +5 -0
- package/fetch-http-client.js +9 -0
- package/package.json +3 -3
package/base-http-client.d.ts
CHANGED
|
@@ -24,6 +24,14 @@ export interface CustomFetchOptions {
|
|
|
24
24
|
* rest on a best-effort basis. Sourced from `SendRequestOptions.session.fingerprint`.
|
|
25
25
|
*/
|
|
26
26
|
fingerprint?: SessionFingerprint;
|
|
27
|
+
/**
|
|
28
|
+
* When `true`, TLS certificate errors should be ignored for this request.
|
|
29
|
+
* Set when `SendRequestOptions.ignoreTlsErrors` is passed (e.g. from the
|
|
30
|
+
* `ignoreTlsErrors` crawler option) or when the session's proxy is a MITM
|
|
31
|
+
* proxy (`session.proxyInfo.ignoreTlsErrors`). Best-effort: clients that
|
|
32
|
+
* cannot disable TLS verification ignore it.
|
|
33
|
+
*/
|
|
34
|
+
ignoreTlsErrors?: boolean;
|
|
27
35
|
}
|
|
28
36
|
/**
|
|
29
37
|
* Base HTTP client that provides fetch-like `sendRequest` with Crawlee-managed
|
package/base-http-client.js
CHANGED
|
@@ -56,6 +56,7 @@ export class BaseHttpClient {
|
|
|
56
56
|
cookieJar,
|
|
57
57
|
signal,
|
|
58
58
|
fingerprint: options?.session?.fingerprint,
|
|
59
|
+
ignoreTlsErrors: options?.ignoreTlsErrors || options?.session?.proxyInfo?.ignoreTlsErrors,
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
async #createDefaultCookieJar() {
|
|
@@ -107,7 +108,7 @@ export class BaseHttpClient {
|
|
|
107
108
|
const maxRedirects = 10;
|
|
108
109
|
let currentRequest = initialRequest;
|
|
109
110
|
let redirectCount = 0;
|
|
110
|
-
const { proxyUrl, cookieJar, signal, fingerprint } = await this.resolveRequestContext(options);
|
|
111
|
+
const { proxyUrl, cookieJar, signal, fingerprint, ignoreTlsErrors } = await this.resolveRequestContext(options);
|
|
111
112
|
currentRequest = initialRequest.clone();
|
|
112
113
|
while (true) {
|
|
113
114
|
await this.applyCookies(currentRequest, cookieJar);
|
|
@@ -116,6 +117,7 @@ export class BaseHttpClient {
|
|
|
116
117
|
proxyUrl,
|
|
117
118
|
cookieJar,
|
|
118
119
|
fingerprint,
|
|
120
|
+
ignoreTlsErrors,
|
|
119
121
|
redirect: 'manual',
|
|
120
122
|
});
|
|
121
123
|
await this.setCookies(response, cookieJar);
|
package/fetch-http-client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CrawleeLogger } from '@crawlee/types';
|
|
1
2
|
import { BaseHttpClient, type CustomFetchOptions } from './base-http-client.js';
|
|
2
3
|
/**
|
|
3
4
|
* A HTTP client implementation using the native `fetch` API.
|
|
@@ -5,5 +6,9 @@ import { BaseHttpClient, type CustomFetchOptions } from './base-http-client.js';
|
|
|
5
6
|
* This implementation does not support proxying.
|
|
6
7
|
*/
|
|
7
8
|
export declare class FetchHttpClient extends BaseHttpClient {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(options?: {
|
|
11
|
+
logger?: CrawleeLogger;
|
|
12
|
+
});
|
|
8
13
|
fetch(request: Request, options?: RequestInit & CustomFetchOptions): Promise<Response>;
|
|
9
14
|
}
|
package/fetch-http-client.js
CHANGED
|
@@ -5,7 +5,16 @@ import { BaseHttpClient } from './base-http-client.js';
|
|
|
5
5
|
* This implementation does not support proxying.
|
|
6
6
|
*/
|
|
7
7
|
export class FetchHttpClient extends BaseHttpClient {
|
|
8
|
+
#logger;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super(options);
|
|
11
|
+
this.#logger = options?.logger;
|
|
12
|
+
}
|
|
8
13
|
async fetch(request, options) {
|
|
14
|
+
if (options?.ignoreTlsErrors) {
|
|
15
|
+
this.#logger?.warningOnce('FetchHttpClient cannot disable TLS certificate verification, the `ignoreTlsErrors` option is ignored. ' +
|
|
16
|
+
'Install the optional @crawlee/impit-client dependency to make it work.');
|
|
17
|
+
}
|
|
9
18
|
return fetch(request, options);
|
|
10
19
|
}
|
|
11
20
|
}
|
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.117",
|
|
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.117",
|
|
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": "7c9c8c83da02da0444130cb95368045d30881c3b"
|
|
61
61
|
}
|