Skip to content

Commit

Permalink
feat(ext/fetch): Allow Response status 101 (denoland#13969)
Browse files Browse the repository at this point in the history
Co-authored-by: Bartek Iwańczuk <[email protected]>
  • Loading branch information
ry and bartlomieju committed Mar 16, 2022
1 parent 426ca98 commit 45b3aa2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cli/tests/unit/fetch_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ Deno.test(function fetchResponseConstructorNullBody() {
});

Deno.test(function fetchResponseConstructorInvalidStatus() {
const invalidStatus = [101, 600, 199, null, "", NaN];
const invalidStatus = [100, 600, 199, null, "", NaN];

for (const status of invalidStatus) {
try {
Expand All @@ -980,7 +980,11 @@ Deno.test(function fetchResponseConstructorInvalidStatus() {
fail(`Invalid status: ${status}`);
} catch (e) {
assert(e instanceof RangeError);
assert(e.message.endsWith("is outside the range [200, 599]."));
assert(
e.message.endsWith(
"is not equal to 101 and outside the range [200, 599].",
),
);
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions ext/fetch/23_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@
context: "Argument 2",
});

if (init.status < 200 || init.status > 599) {
if ((init.status < 200 || init.status > 599) && init.status != 101) {
throw new RangeError(
`The status provided (${init.status}) is outside the range [200, 599].`,
`The status provided (${init.status}) is not equal to 101 and outside the range [200, 599].`,
);
}

Expand Down

0 comments on commit 45b3aa2

Please sign in to comment.