diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 0eae43cb28f..ecf19b6e81e 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -762,8 +762,8 @@ async function schemeFetch (fetchParams) { switch (scheme) { case 'about:': { // If request’s current URL’s path is the string "blank", then return a new response - // whose status message is `OK`, header list is « (`Content-Type`, `text/html;charset=utf-8`) », - // and body is the empty byte sequence. + // whose status message is `OK`, header list is « (`Content-Type`, `text/html;charset=utf-8`) », + // and body is the empty byte sequence. if (path === 'blank') { const resp = makeResponse({ statusText: 'OK', @@ -771,7 +771,7 @@ async function schemeFetch (fetchParams) { 'content-type', 'text/html;charset=utf-8' ] }) - + resp.urlList = [new URL('about:blank')] return resp } @@ -784,12 +784,12 @@ async function schemeFetch (fetchParams) { context.on('terminated', onRequestAborted) - // 1. Run these steps, but abort when the ongoing fetch is terminated: + // 1. Run these steps, but abort when the ongoing fetch is terminated: // 1a. Let blob be request’s current URL’s blob URL entry’s object. // https://w3c.github.io/FileAPI/#blob-url-entry // P.S. Thank God this method is available in node. const currentURL = requestCurrentURL(request) - + // https://github.com/web-platform-tests/wpt/blob/7b0ebaccc62b566a1965396e5be7bb2bc06f841f/FileAPI/url/resources/fetch-tests.js#L52-L56 // Buffer.resolveObjectURL does not ignore URL queries. if (currentURL.search.length !== 0) { @@ -803,7 +803,7 @@ async function schemeFetch (fetchParams) { return makeNetworkError('invalid method') } - // 3a. Let response be a new response whose status message is `OK`. + // 3a. Let response be a new response whose status message is `OK`. const response = makeResponse({ statusText: 'OK', urlList: [currentURL] }) // 4a. Append (`Content-Length`, blob’s size attribute value) to response’s header list. @@ -1883,11 +1883,16 @@ function httpNetworkFetch ( decoders.push(new PassThrough()) } - this.decoder = decoders[0].on('drain', resume) + this.decoder = decoders[0].on('drain', resume).on('error', () => {}) const iterator = decoders[decoders.length - 1][Symbol.asyncIterator]() pullAlgorithm = async (controller) => { + if (resume) { + resume() + resume = null + } + // 4. Set bytes to the result of handling content codings given // codings and bytes. let bytes @@ -1946,7 +1951,7 @@ function httpNetworkFetch ( resolve(response) - return true + return false }, onData (chunk) {