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 +1 -1
- package/dist/postflight.js +4 -4
- package/package.json +1 -1
- package/src/postflight.mjs +4 -6
package/README.md
CHANGED
package/dist/postflight.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
package/src/postflight.mjs
CHANGED
|
@@ -78,7 +78,7 @@ export const postflight = (req, res, options, { reject, resolve }) => {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
if (!sameOrigin(location, url)) {
|
|
81
|
-
|
|
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
|
-
|
|
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];
|