summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2019-09-03 01:30:14 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-09-02 12:30:14 -0400
commit56508f113d9fe61ffcce4cbbb85e3d6961888e1d (patch)
treecad7a845065462fa13c4dd68a749a0ee1d7f0d4a /js
parent0ce15f08c76f075948a132dd0f9f27855bd00a1d (diff)
ops/fetch: add statusText (#2851)
Diffstat (limited to 'js')
-rw-r--r--js/fetch.ts5
-rw-r--r--js/fetch_test.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/js/fetch.ts b/js/fetch.ts
index 317239630..2e18ece9a 100644
--- a/js/fetch.ts
+++ b/js/fetch.ts
@@ -243,7 +243,6 @@ class Body implements domTypes.Body, domTypes.ReadableStream, io.ReadCloser {
}
export class Response implements domTypes.Response {
- statusText = "FIXME"; // TODO
readonly type = "basic"; // TODO
readonly redirected: boolean;
headers: domTypes.Headers;
@@ -254,6 +253,7 @@ export class Response implements domTypes.Response {
constructor(
readonly url: string,
readonly status: number,
+ readonly statusText: string,
headersList: Array<[string, string]>,
rid: number,
redirected_: boolean,
@@ -313,6 +313,7 @@ export class Response implements domTypes.Response {
return new Response(
this.url,
this.status,
+ this.statusText,
headersList,
-1,
this.redirected,
@@ -324,6 +325,7 @@ export class Response implements domTypes.Response {
interface FetchResponse {
bodyRid: number;
status: number;
+ statusText: string;
headers: Array<[string, string]>;
}
@@ -422,6 +424,7 @@ export async function fetch(
const response = new Response(
url,
fetchResponse.status,
+ fetchResponse.statusText,
fetchResponse.headers,
fetchResponse.bodyRid,
redirected
diff --git a/js/fetch_test.ts b/js/fetch_test.ts
index 542d69147..8d8b581d8 100644
--- a/js/fetch_test.ts
+++ b/js/fetch_test.ts
@@ -107,6 +107,7 @@ testPerm(
testPerm({ net: true }, async function fetchWithRedirection(): Promise<void> {
const response = await fetch("http://localhost:4546/"); // will redirect to http://localhost:4545/
assertEquals(response.status, 200);
+ assertEquals(response.statusText, "OK");
assertEquals(response.url, "http://localhost:4545/");
const body = await response.text();
assert(body.includes("<title>Directory listing for /</title>"));
@@ -117,6 +118,7 @@ testPerm({ net: true }, async function fetchWithRelativeRedirection(): Promise<
> {
const response = await fetch("http://localhost:4545/tests"); // will redirect to /tests/
assertEquals(response.status, 200);
+ assertEquals(response.statusText, "OK");
const body = await response.text();
assert(body.includes("<title>Directory listing for /tests/</title>"));
});