summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/examples/chat/server.ts5
-rw-r--r--std/examples/chat/server_test.ts2
-rw-r--r--std/examples/curl.ts8
-rw-r--r--std/http/file_server_test.ts8
4 files changed, 15 insertions, 8 deletions
diff --git a/std/examples/chat/server.ts b/std/examples/chat/server.ts
index eb5b2f7d4..40affbd5f 100644
--- a/std/examples/chat/server.ts
+++ b/std/examples/chat/server.ts
@@ -35,13 +35,14 @@ listenAndServe({ port: 8080 }, async (req) => {
const u = new URL("./index.html", import.meta.url);
if (u.protocol.startsWith("http")) {
// server launched by deno run http(s)://.../server.ts,
- fetch(u.href).then((resp) => {
+ fetch(u.href).then(async (resp) => {
+ const body = new Uint8Array(await resp.arrayBuffer());
return req.respond({
status: resp.status,
headers: new Headers({
"content-type": "text/html",
}),
- body: resp.body,
+ body,
});
});
} else {
diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts
index 673b61174..e1b1c0e12 100644
--- a/std/examples/chat/server_test.ts
+++ b/std/examples/chat/server_test.ts
@@ -38,7 +38,7 @@ test({
const resp = await fetch("http://127.0.0.1:8080/");
assertEquals(resp.status, 200);
assertEquals(resp.headers.get("content-type"), "text/html");
- const html = await resp.body.text();
+ const html = await resp.text();
assert(html.includes("ws chat example"), "body is ok");
} finally {
server.close();
diff --git a/std/examples/curl.ts b/std/examples/curl.ts
index 39e917591..44ee66125 100644
--- a/std/examples/curl.ts
+++ b/std/examples/curl.ts
@@ -1,4 +1,10 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
const url_ = Deno.args[0];
const res = await fetch(url_);
-await Deno.copy(Deno.stdout, res.body);
+
+// TODO(ry) Re-enable streaming in this example.
+// Originally we did: await Deno.copy(Deno.stdout, res.body);
+// But maybe more JS-y would be: res.pipeTo(Deno.stdout);
+
+const body = new Uint8Array(await res.arrayBuffer());
+await Deno.stdout.write(body);
diff --git a/std/http/file_server_test.ts b/std/http/file_server_test.ts
index 404d133ae..dc14d2c57 100644
--- a/std/http/file_server_test.ts
+++ b/std/http/file_server_test.ts
@@ -79,7 +79,7 @@ test(async function serveFallback(): Promise<void> {
assert(res.headers.has("access-control-allow-origin"));
assert(res.headers.has("access-control-allow-headers"));
assertEquals(res.status, 404);
- res.body.close();
+ const _ = await res.text();
} finally {
killFileServer();
}
@@ -92,12 +92,12 @@ test(async function serveWithUnorthodoxFilename(): Promise<void> {
assert(res.headers.has("access-control-allow-origin"));
assert(res.headers.has("access-control-allow-headers"));
assertEquals(res.status, 200);
- res.body.close();
+ let _ = await res.text();
res = await fetch("http://localhost:4500/http/testdata/test%20file.txt");
assert(res.headers.has("access-control-allow-origin"));
assert(res.headers.has("access-control-allow-headers"));
assertEquals(res.status, 200);
- res.body.close();
+ _ = await res.text();
} finally {
killFileServer();
}
@@ -118,7 +118,7 @@ test(async function servePermissionDenied(): Promise<void> {
try {
const res = await fetch("http://localhost:4500/");
- res.body.close();
+ const _ = await res.text();
assertStrContains(
(await errReader.readLine()) as string,
"run again with the --allow-read flag"