@crawlee/basic 4.0.0-beta.256 → 4.0.0-beta.258

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.
@@ -1,3 +1,5 @@
1
+ import { Readable } from 'node:stream';
2
+ import { processHttpRequestOptions } from '@crawlee/utils/internal';
1
3
  /**
2
4
  * Prepares a function to be used as the `sendRequest` context helper.
3
5
  *
@@ -9,24 +11,31 @@
9
11
  export function createSendRequest(httpClient, originRequest, session) {
10
12
  return async (overrideRequest = {}, overrideOptions = {}) => {
11
13
  const baseRequest = originRequest.intoFetchAPIRequest();
12
- const mergedUrl = overrideRequest.url ?? baseRequest.url;
13
- const mergedMethod = overrideRequest.method ?? baseRequest.method;
14
14
  const mergedHeaders = new Headers(baseRequest.headers);
15
15
  if (overrideRequest.headers) {
16
16
  overrideRequest.headers.forEach((value, key) => {
17
17
  mergedHeaders.set(key, value);
18
18
  });
19
19
  }
20
- const request = new Request(mergedUrl, {
21
- method: mergedMethod,
20
+ const opts = processHttpRequestOptions({
21
+ ...overrideRequest,
22
+ url: overrideRequest.url ?? baseRequest.url,
23
+ method: overrideRequest.method ?? originRequest.method,
22
24
  headers: mergedHeaders,
23
- body: overrideRequest.body ?? baseRequest.body,
25
+ });
26
+ const request = new Request(opts.url, {
27
+ method: opts.method,
28
+ headers: opts.headers,
29
+ body: opts.body ? Readable.toWeb(opts.body) : baseRequest.body,
30
+ // Node-specific option to make the request body work with streams
31
+ duplex: 'half',
24
32
  });
25
33
  return httpClient.sendRequest(request, {
26
34
  session,
27
- cookieJar: overrideOptions?.cookieJar ?? session.cookieJar,
28
- timeoutMillis: overrideOptions.timeoutMillis,
29
- signal: overrideOptions.signal,
35
+ cookieJar: overrideOptions.cookieJar ?? opts.cookieJar ?? session.cookieJar,
36
+ proxyUrl: overrideOptions.proxyUrl ?? opts.proxyUrl,
37
+ timeoutMillis: overrideOptions.timeoutMillis ?? opts.timeout,
38
+ signal: overrideOptions.signal ?? opts.signal,
30
39
  ignoreTlsErrors: overrideOptions.ignoreTlsErrors,
31
40
  });
32
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/basic",
3
- "version": "4.0.0-beta.256",
3
+ "version": "4.0.0-beta.258",
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.13.0"
@@ -42,10 +42,10 @@
42
42
  "@apify/datastructures": "^3.0.1",
43
43
  "@apify/timeout": "^1.0.1",
44
44
  "@apify/utilities": "^3.1.0",
45
- "@crawlee/core": "4.0.0-beta.256",
46
- "@crawlee/http-client": "4.0.0-beta.256",
47
- "@crawlee/types": "4.0.0-beta.256",
48
- "@crawlee/utils": "4.0.0-beta.256",
45
+ "@crawlee/core": "4.0.0-beta.258",
46
+ "@crawlee/http-client": "4.0.0-beta.258",
47
+ "@crawlee/types": "4.0.0-beta.258",
48
+ "@crawlee/utils": "4.0.0-beta.258",
49
49
  "@sapphire/async-queue": "^1.5.5",
50
50
  "@standard-schema/spec": "^1.1.0",
51
51
  "csv-stringify": "^6.9.0",
@@ -57,7 +57,7 @@
57
57
  "zod": "^4.6.7"
58
58
  },
59
59
  "optionalDependencies": {
60
- "@crawlee/impit-client": "4.0.0-beta.256"
60
+ "@crawlee/impit-client": "4.0.0-beta.258"
61
61
  },
62
62
  "lerna": {
63
63
  "command": {
@@ -66,5 +66,5 @@
66
66
  }
67
67
  }
68
68
  },
69
- "gitHead": "06cbfcc77b373a93f1a6a048e8115433db98c862"
69
+ "gitHead": "a285256b541becf78e187043be064db917c643ea"
70
70
  }