Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

std/http/mod.ts>ServerRequest

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
class ServerRequest
Re-export
import { ServerRequest } from "https://deno.land/std@0.39.0/http/mod.ts";

Properties

private
_body: Deno.Reader | null
private
_contentLength: number | undefined | null
private
finalized: boolean
readonly
body: Deno.Reader

Body of the request.

const buf = new Uint8Array(req.contentLength);
let bufSlice = buf;
let totRead = 0;
while (true) {
  const nread = await req.body.read(bufSlice);
  if (nread === Deno.EOF) break;
  totRead += nread;
  if (totRead >= req.contentLength) break;
  bufSlice = bufSlice.subarray(nread);
}
conn: Conn
readonly
contentLength: number | null

Value of Content-Length header. If null, then content length is invalid or not given (e.g. chunked encoding).

done: Deferred<Error | undefined>
headers: Headers
method: string
proto: string
protoMajor: number
protoMinor: number
url: string

Methods

finalize(): Promise<void>
respond(r: Response): Promise<void>