rekwest 4.4.0 → 4.4.1

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/README.md CHANGED
@@ -187,7 +187,7 @@ const {
187
187
  } = constants;
188
188
 
189
189
  const rk = rekwest.extend({
190
- baseURL: 'https://somewhe.re'
190
+ baseURL: 'https://somewhe.re',
191
191
  });
192
192
 
193
193
  const signal = AbortSignal.timeout(1e4);
@@ -73,7 +73,7 @@ const postflight = (req, res, options, {
73
73
  return res.emit('error', new _errors.RequestError('URL scheme must be "http" or "https".'));
74
74
  }
75
75
  if (!(0, _utils.sameOrigin)(location, url)) {
76
- Reflect.set(options, 'h2', false);
76
+ options.h2 = false;
77
77
  if ([_constants.requestCredentials.omit, _constants.requestCredentials.sameOrigin].includes(credentials)) {
78
78
  Object.keys(options.headers).filter(it => new RegExp(HTTP2_HEADER_AUTHORIZATION, 'i').test(it)).forEach(it => Reflect.deleteProperty(options.headers, it));
79
79
  location.password = location.username = '';
@@ -82,17 +82,17 @@ const postflight = (req, res, options, {
82
82
  }
83
83
  }
84
84
  }
85
- options.url = location;
86
85
  if (statusCode !== HTTP_STATUS_SEE_OTHER && options.body?.pipe?.constructor === Function) {
87
86
  return res.emit('error', new _errors.RequestError(`Unable to ${redirect} redirect with streamable body.`));
88
87
  }
89
- options.follow--;
90
88
  if ([HTTP_STATUS_MOVED_PERMANENTLY, HTTP_STATUS_FOUND].includes(statusCode) && options.method === HTTP2_METHOD_POST || statusCode === HTTP_STATUS_SEE_OTHER && ![HTTP2_METHOD_GET, HTTP2_METHOD_HEAD].includes(options.method)) {
91
89
  Object.keys(options.headers).filter(it => /^content-/i.test(it)).forEach(it => Reflect.deleteProperty(options.headers, it));
92
90
  options.body = null;
93
91
  options.method = HTTP2_METHOD_GET;
94
92
  }
95
- Reflect.set(options, 'redirected', true);
93
+ options.follow--;
94
+ options.redirected = true;
95
+ options.url = location;
96
96
  if (statusCode === HTTP_STATUS_MOVED_PERMANENTLY && res.headers[HTTP2_HEADER_RETRY_AFTER]) {
97
97
  let interval = res.headers[HTTP2_HEADER_RETRY_AFTER];
98
98
  interval = Number(interval) * 1000 || new Date(interval) - Date.now();
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.4.0"
70
+ "version": "4.4.1"
71
71
  }
@@ -78,7 +78,7 @@ export const postflight = (req, res, options, { reject, resolve }) => {
78
78
  }
79
79
 
80
80
  if (!sameOrigin(location, url)) {
81
- Reflect.set(options, 'h2', false);
81
+ options.h2 = false;
82
82
  if ([
83
83
  requestCredentials.omit,
84
84
  requestCredentials.sameOrigin,
@@ -92,14 +92,10 @@ export const postflight = (req, res, options, { reject, resolve }) => {
92
92
  }
93
93
  }
94
94
 
95
- options.url = location;
96
-
97
95
  if (statusCode !== HTTP_STATUS_SEE_OTHER && options.body?.pipe?.constructor === Function) {
98
96
  return res.emit('error', new RequestError(`Unable to ${ redirect } redirect with streamable body.`));
99
97
  }
100
98
 
101
- options.follow--;
102
-
103
99
  if (([
104
100
  HTTP_STATUS_MOVED_PERMANENTLY,
105
101
  HTTP_STATUS_FOUND,
@@ -113,7 +109,9 @@ export const postflight = (req, res, options, { reject, resolve }) => {
113
109
  options.method = HTTP2_METHOD_GET;
114
110
  }
115
111
 
116
- Reflect.set(options, 'redirected', true);
112
+ options.follow--;
113
+ options.redirected = true;
114
+ options.url = location;
117
115
 
118
116
  if (statusCode === HTTP_STATUS_MOVED_PERMANENTLY && res.headers[HTTP2_HEADER_RETRY_AFTER]) {
119
117
  let interval = res.headers[HTTP2_HEADER_RETRY_AFTER];