refactor(fetch/request): use callback for url and method (#15483)

This commit is contained in:
Leo Kettmeir 2022-08-17 16:29:26 +02:00 committed by GitHub
parent a2ab5eee01
commit 0b0843e4a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 87 additions and 17 deletions

View file

@ -28,6 +28,7 @@
nullBodyStatus,
networkError,
abortedNetworkError,
processUrlList,
} = window.__bootstrap.fetch;
const abortSignal = window.__bootstrap.abortSignal;
const {
@ -295,6 +296,8 @@
}
if (terminator.aborted) return abortedNetworkError();
processUrlList(req.urlList, req.urlListProcessed);
/** @type {InnerResponse} */
const response = {
headerList: resp.headers,
@ -306,7 +309,7 @@
if (this.urlList.length == 0) return null;
return this.urlList[this.urlList.length - 1];
},
urlList: req.urlList,
urlList: req.urlListProcessed,
};
if (redirectStatus(resp.status)) {
switch (req.redirectMode) {
@ -339,7 +342,8 @@
if (recursive) return response;
if (response.urlList.length === 0) {
response.urlList = [...new SafeArrayIterator(req.urlList)];
processUrlList(req.urlList, req.urlListProcessed);
response.urlList = [...new SafeArrayIterator(req.urlListProcessed)];
}
return response;
@ -407,7 +411,7 @@
const res = extractBody(request.body.source);
request.body = res.body;
}
ArrayPrototypePush(request.urlList, locationURL.href);
ArrayPrototypePush(request.urlList, () => locationURL.href);
return mainFetch(request, true, terminator);
}