Skip to content

Commit

Permalink
refactor(ext/fetch): use primordials in 26_fetch.js
Browse files Browse the repository at this point in the history
  • Loading branch information
satyarohith committed Jul 4, 2021
1 parent 5d6c9e5 commit b92fcfc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions extensions/fetch/26_fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
} = window.__bootstrap.fetch;
const abortSignal = window.__bootstrap.abortSignal;
const { DOMException } = window.__bootstrap.domException;
const {
ArrayPrototypeIncludes,
TypedArrayPrototypeSubarray,
} = window.__bootstrap.primordials;

const REQUEST_BODY_HEADER_NAMES = [
"content-encoding",
Expand Down Expand Up @@ -104,7 +108,7 @@
);
if (read > 0) {
// We read some data. Enqueue it onto the stream.
controller.enqueue(chunk.subarray(0, read));
controller.enqueue(TypedArrayPrototypeSubarray(chunk, 0, read));
} else {
// We have reached the end of the body, so we close the stream.
controller.close();
Expand Down Expand Up @@ -335,7 +339,12 @@
request.method = "GET";
request.body = null;
for (let i = 0; i < request.headerList.length; i++) {
if (REQUEST_BODY_HEADER_NAMES.includes(request.headerList[i][0])) {
if (
ArrayPrototypeIncludes(
REQUEST_BODY_HEADER_NAMES,
request.headerList[i][0],
)
) {
request.headerList.splice(i, 1);
i--;
}
Expand Down

0 comments on commit b92fcfc

Please sign in to comment.