From 43b2160f26862b92103b80bfcf35febb192bae61 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Fri, 18 Jul 2025 01:35:25 +0200 Subject: [PATCH] fetch: minor modifications --- lib/web/fetch/index.js | 7 +++---- lib/web/fetch/util.js | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/web/fetch/index.js b/lib/web/fetch/index.js index 0c2f5b9693f..d111fd062f1 100644 --- a/lib/web/fetch/index.js +++ b/lib/web/fetch/index.js @@ -2055,7 +2055,7 @@ async function httpNetworkFetch ( function dispatch ({ body }) { const url = requestCurrentURL(request) - /** @type {import('../..').Agent} */ + /** @type {import('../../..').Agent} */ const agent = fetchParams.controller.dispatcher return new Promise((resolve, reject) => agent.dispatch( @@ -2104,12 +2104,11 @@ async function httpNetworkFetch ( onHeaders (status, rawHeaders, resume, statusText) { if (status < 200) { - return + return false } /** @type {string[]} */ let codings = [] - let location = '' const headersList = new HeadersList() @@ -2122,7 +2121,7 @@ async function httpNetworkFetch ( // "All content-coding values are case-insensitive..." codings = contentEncoding.toLowerCase().split(',').map((x) => x.trim()) } - location = headersList.get('location', true) + const location = headersList.get('location', true) this.body = new Readable({ read: resume }) diff --git a/lib/web/fetch/util.js b/lib/web/fetch/util.js index a0471e6a29b..e016dbf396a 100644 --- a/lib/web/fetch/util.js +++ b/lib/web/fetch/util.js @@ -1327,10 +1327,17 @@ function urlIsHttpHttpsScheme (url) { return protocol === 'http:' || protocol === 'https:' } +/** + * @typedef {Object} RangeHeaderValue + * @property {number|null} rangeStartValue + * @property {number|null} rangeEndValue + */ + /** * @see https://fetch.spec.whatwg.org/#simple-range-header-value * @param {string} value * @param {boolean} allowWhitespace + * @return {RangeHeaderValue|'failure'} */ function simpleRangeHeaderValue (value, allowWhitespace) { // 1. Let data be the isomorphic decoding of value.