rekwest 4.2.1 → 4.2.2

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/dist/defaults.js CHANGED
@@ -15,6 +15,7 @@ const stash = {
15
15
  credentials: _constants.requestCredentials.sameOrigin,
16
16
  digest: true,
17
17
  follow: 20,
18
+ h2: false,
18
19
  get maxRetryAfter() {
19
20
  return this[_utils.maxRetryAfter] ?? this.timeout;
20
21
  },
@@ -33,7 +34,8 @@ const stash = {
33
34
  statusCodes: [HTTP_STATUS_TOO_MANY_REQUESTS, HTTP_STATUS_SERVICE_UNAVAILABLE]
34
35
  },
35
36
  thenable: false,
36
- timeout: 3e5
37
+ timeout: 3e5,
38
+ trimTrailingSlashes: false
37
39
  };
38
40
  var _default = {
39
41
  stash
@@ -71,11 +71,14 @@ const postflight = (req, res, options, {
71
71
  if (!/^https?:/i.test(location.protocol)) {
72
72
  return res.emit('error', new _errors.RequestError('URL scheme must be "http" or "https".'));
73
73
  }
74
- if (!(0, _utils.sameOrigin)(location, url) && [_constants.requestCredentials.omit, _constants.requestCredentials.sameOrigin].includes(credentials)) {
75
- Reflect.deleteProperty(options.headers, HTTP2_HEADER_AUTHORIZATION);
76
- location.password = location.username = '';
77
- if (credentials === _constants.requestCredentials.omit) {
78
- options.cookies = false;
74
+ if (!(0, _utils.sameOrigin)(location, url)) {
75
+ Reflect.set(options, 'h2', false);
76
+ if ([_constants.requestCredentials.omit, _constants.requestCredentials.sameOrigin].includes(credentials)) {
77
+ Reflect.deleteProperty(options.headers, HTTP2_HEADER_AUTHORIZATION);
78
+ location.password = location.username = '';
79
+ if (credentials === _constants.requestCredentials.omit) {
80
+ options.cookies = false;
81
+ }
79
82
  }
80
83
  }
81
84
  options.url = location;
@@ -88,7 +91,6 @@ const postflight = (req, res, options, {
88
91
  options.body = null;
89
92
  options.method = HTTP2_METHOD_GET;
90
93
  }
91
- Reflect.set(options, 'h2', false);
92
94
  Reflect.set(options, 'redirected', true);
93
95
  if (statusCode === HTTP_STATUS_MOVED_PERMANENTLY && res.headers[HTTP2_HEADER_RETRY_AFTER]) {
94
96
  let interval = res.headers[HTTP2_HEADER_RETRY_AFTER];
package/package.json CHANGED
@@ -67,5 +67,5 @@
67
67
  "test:bail": "mocha --bail",
68
68
  "test:cover": "c8 --include=src --reporter=lcov --reporter=text npm test"
69
69
  },
70
- "version": "4.2.1"
70
+ "version": "4.2.2"
71
71
  }
package/src/defaults.mjs CHANGED
@@ -1,44 +1,46 @@
1
- import http2 from 'node:http2';
2
- import {
3
- requestCredentials,
4
- requestRedirect,
5
- } from './constants.mjs';
6
- import { maxRetryAfter } from './utils.mjs';
7
-
8
- const {
9
- HTTP2_METHOD_GET,
10
- HTTP_STATUS_SERVICE_UNAVAILABLE,
11
- HTTP_STATUS_TOO_MANY_REQUESTS,
12
- } = http2.constants;
13
-
14
- const stash = {
15
- credentials: requestCredentials.sameOrigin,
16
- digest: true,
17
- follow: 20,
18
- get maxRetryAfter() {
19
- return this[maxRetryAfter] ?? this.timeout;
20
- },
21
- set maxRetryAfter(value) {
22
- this[maxRetryAfter] = value;
23
- },
24
- method: HTTP2_METHOD_GET,
25
- parse: true,
26
- redirect: requestRedirect.follow,
27
- redirected: false,
28
- retry: {
29
- attempts: 0,
30
- backoffStrategy: 'interval * Math.log(Math.random() * (Math.E * Math.E - Math.E) + Math.E)',
31
- interval: 1e3,
32
- retryAfter: true,
33
- statusCodes: [
34
- HTTP_STATUS_TOO_MANY_REQUESTS,
35
- HTTP_STATUS_SERVICE_UNAVAILABLE,
36
- ],
37
- },
38
- thenable: false,
39
- timeout: 3e5,
40
- };
41
-
42
- export default {
43
- stash,
44
- };
1
+ import http2 from 'node:http2';
2
+ import {
3
+ requestCredentials,
4
+ requestRedirect,
5
+ } from './constants.mjs';
6
+ import { maxRetryAfter } from './utils.mjs';
7
+
8
+ const {
9
+ HTTP2_METHOD_GET,
10
+ HTTP_STATUS_SERVICE_UNAVAILABLE,
11
+ HTTP_STATUS_TOO_MANY_REQUESTS,
12
+ } = http2.constants;
13
+
14
+ const stash = {
15
+ credentials: requestCredentials.sameOrigin,
16
+ digest: true,
17
+ follow: 20,
18
+ h2: false,
19
+ get maxRetryAfter() {
20
+ return this[maxRetryAfter] ?? this.timeout;
21
+ },
22
+ set maxRetryAfter(value) {
23
+ this[maxRetryAfter] = value;
24
+ },
25
+ method: HTTP2_METHOD_GET,
26
+ parse: true,
27
+ redirect: requestRedirect.follow,
28
+ redirected: false,
29
+ retry: {
30
+ attempts: 0,
31
+ backoffStrategy: 'interval * Math.log(Math.random() * (Math.E * Math.E - Math.E) + Math.E)',
32
+ interval: 1e3,
33
+ retryAfter: true,
34
+ statusCodes: [
35
+ HTTP_STATUS_TOO_MANY_REQUESTS,
36
+ HTTP_STATUS_SERVICE_UNAVAILABLE,
37
+ ],
38
+ },
39
+ thenable: false,
40
+ timeout: 3e5,
41
+ trimTrailingSlashes: false,
42
+ };
43
+
44
+ export default {
45
+ stash,
46
+ };
@@ -77,14 +77,17 @@ export const postflight = (req, res, options, { reject, resolve }) => {
77
77
  return res.emit('error', new RequestError('URL scheme must be "http" or "https".'));
78
78
  }
79
79
 
80
- if (!sameOrigin(location, url) && [
81
- requestCredentials.omit,
82
- requestCredentials.sameOrigin,
83
- ].includes(credentials)) {
84
- Reflect.deleteProperty(options.headers, HTTP2_HEADER_AUTHORIZATION);
85
- location.password = location.username = '';
86
- if (credentials === requestCredentials.omit) {
87
- options.cookies = false;
80
+ if (!sameOrigin(location, url)) {
81
+ Reflect.set(options, 'h2', false);
82
+ if ([
83
+ requestCredentials.omit,
84
+ requestCredentials.sameOrigin,
85
+ ].includes(credentials)) {
86
+ Reflect.deleteProperty(options.headers, HTTP2_HEADER_AUTHORIZATION);
87
+ location.password = location.username = '';
88
+ if (credentials === requestCredentials.omit) {
89
+ options.cookies = false;
90
+ }
88
91
  }
89
92
  }
90
93
 
@@ -109,7 +112,6 @@ export const postflight = (req, res, options, { reject, resolve }) => {
109
112
  options.method = HTTP2_METHOD_GET;
110
113
  }
111
114
 
112
- Reflect.set(options, 'h2', false);
113
115
  Reflect.set(options, 'redirected', true);
114
116
 
115
117
  if (statusCode === HTTP_STATUS_MOVED_PERMANENTLY && res.headers[HTTP2_HEADER_RETRY_AFTER]) {