diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-04-10 09:51:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 09:51:17 -0400 |
commit | 02bc58d83253fd3be61787bb28b6b02e3aa71092 (patch) | |
tree | 287491a848ee9fecf1e1e983841f040bc9bec0a4 /std/examples/curl.ts | |
parent | be71885628c3820cc4e62d229326de16a6830fec (diff) |
BREAKING: Make fetch API more web compatible (#4687)
- Removes the __fetch namespace from `deno types`
- Response.redirect should be a static.
- Response.body should not be AsyncIterable.
- Disables the deno_proxy benchmark
- Makes std/examples/curl.ts buffer the body before printing to stdout
Diffstat (limited to 'std/examples/curl.ts')
-rw-r--r-- | std/examples/curl.ts | 8 |
1 files changed, 7 insertions, 1 deletions
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); |