diff options
author | Chris Knight <cknight1234@gmail.com> | 2020-05-28 18:36:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 13:36:18 -0400 |
commit | 86c6f05404427fb0fcb95f7e2568c6659a0a022a (patch) | |
tree | 14e763cc025e95f92f89f2407e6bdcc3130996f4 /std/http/server.ts | |
parent | dc6c07e3ed12f579889ffce633284aeb45972da6 (diff) |
doc: improve documentation for consuming request body (#5771)
Diffstat (limited to 'std/http/server.ts')
-rw-r--r-- | std/http/server.ts | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/std/http/server.ts b/std/http/server.ts index 787820a56..faf5da6af 100644 --- a/std/http/server.ts +++ b/std/http/server.ts @@ -53,18 +53,9 @@ export class ServerRequest { private _body: Deno.Reader | null = null; /** - * Body of the request. + * Body of the request. The easiest way to consume the body is: * - * const buf = new Uint8Array(req.contentLength); - * let bufSlice = buf; - * let totRead = 0; - * while (true) { - * const nread = await req.body.read(bufSlice); - * if (nread === null) break; - * totRead += nread; - * if (totRead >= req.contentLength) break; - * bufSlice = bufSlice.subarray(nread); - * } + * const buf: Uint8Array = await Deno.readAll(req.body); */ get body(): Deno.Reader { if (!this._body) { |