mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
refactor(fetch/request): use callback for url and method (#15483)
This commit is contained in:
parent
a2ab5eee01
commit
0b0843e4a5
3 changed files with 87 additions and 17 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue