@adobe/fetch
Advanced tools
Comparing version 4.1.0 to 4.1.1
{ | ||
"name": "@adobe/fetch", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "Light-weight Fetch implementation transparently supporting both HTTP/1(.1) and HTTP/2", | ||
@@ -61,20 +61,20 @@ "main": "./src/index.js", | ||
"c8": "8.0.1", | ||
"chai": "4.3.8", | ||
"chai": "4.3.10", | ||
"chai-as-promised": "7.1.1", | ||
"chai-bytes": "0.1.2", | ||
"chai-iterator": "3.0.2", | ||
"eslint": "8.49.0", | ||
"eslint": "8.52.0", | ||
"eslint-config-airbnb-base": "15.0.0", | ||
"eslint-plugin-header": "3.1.1", | ||
"eslint-plugin-import": "2.28.1", | ||
"eslint-plugin-import": "2.29.0", | ||
"formdata-node": "5.0.1", | ||
"husky": "8.0.3", | ||
"lint-staged": "14.0.1", | ||
"lint-staged": "15.0.2", | ||
"mocha": "10.2.0", | ||
"mocha-multi-reporters": "1.5.1", | ||
"nock": "13.3.3", | ||
"nock": "13.3.6", | ||
"parse-cache-control": "1.0.1", | ||
"parse-multipart-data": "1.5.0", | ||
"semantic-release": "21.1.1", | ||
"sinon": "15.2.0", | ||
"semantic-release": "22.0.5", | ||
"sinon": "17.0.0", | ||
"stream-buffers": "3.0.2" | ||
@@ -81,0 +81,0 @@ }, |
@@ -145,8 +145,12 @@ /* | ||
case 'follow': { | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 2 | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 4 | ||
if (locationURL === null) { | ||
break; | ||
} | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 6 | ||
if (!(locationURL.protocol === 'http:' || locationURL.protocol === 'https:')) { | ||
throw new FetchError('Cannot follow redirect with a non http location url', 'unsupported-redirect'); | ||
} | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 5 | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 7 | ||
if (req.counter >= req.follow) { | ||
@@ -160,3 +164,3 @@ if (signal) { | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 6 (counter increment) | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 8 (counter increment) | ||
// Create a new Request object. | ||
@@ -174,3 +178,3 @@ const requestOptions = { | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 9 | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 11 | ||
if (statusCode !== 303 && req.body && req.init.body instanceof Readable) { | ||
@@ -184,10 +188,20 @@ if (signal) { | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 11 | ||
if (statusCode === 303 || ((statusCode === 301 || statusCode === 302) && req.method === 'POST')) { | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 12 | ||
if ((statusCode === 303 && !['GET', 'HEAD'].includes(req.method)) | ||
|| ((statusCode === 301 || statusCode === 302) && req.method === 'POST')) { | ||
requestOptions.method = 'GET'; | ||
requestOptions.body = undefined; | ||
requestOptions.headers.delete('content-length'); | ||
requestOptions.headers.delete('content-encoding'); | ||
requestOptions.headers.delete('content-language'); | ||
requestOptions.headers.delete('content-location'); | ||
requestOptions.headers.delete('content-type'); | ||
} | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 15 | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 13 | ||
if (locationURL.origin !== new URL(req.url).origin) { | ||
requestOptions.headers.delete('authorization'); | ||
} | ||
// https://fetch.spec.whatwg.org/#http-redirect-fetch step 22 | ||
if (signal) { | ||
@@ -194,0 +208,0 @@ // deregister from signal |
142699
3278