@crawlee/http-client 4.0.0-beta.116 → 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.
@@ -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
@@ -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);
@@ -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
  }
@@ -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.116",
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.116",
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": "2bdc17928f47674f08fff7a83de861d881b7947a"
60
+ "gitHead": "7c9c8c83da02da0444130cb95368045d30881c3b"
61
61
  }