From 847ab7bfca7d7e2989e49446c4ea406d55fa79ea Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Thu, 28 May 2020 18:36:18 +0100 Subject: [PATCH] doc: improve documentation for consuming request body (denoland/deno#5771) --- http/server.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/http/server.ts b/http/server.ts index 787820a563bd7..faf5da6af11b3 100644 --- a/http/server.ts +++ b/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) {