Skip to main content
Module

x/deno_koa/request.ts>Request

A middleware framework for Deno's http serve🦕. Transplanted from Koa with ❤️
Latest
class Request
import { Request } from "https://deno.land/x/deno_koa@v1.0.4/request.ts";

Constructors

new
Request(
request: ServerRequest,
proxy?,
secure?,
)

Properties

accept
readonly
charset: string

Get the charset when present or empty.

readonly
cookies: Cookies
readonly
fresh

Check if the request is fresh, aka Last-Modified and/or the ETag still match.

readonly
hasBody: boolean
header: Headers

Return request header.

headers: Headers

Return request header, alias as request.header

readonly
host: string | null

Parse the "Host" header field host and support X-Forwarded-Host when a proxy is enabled.

readonly
hostname

Parse the "Host" header field hostname and support X-Forwarded-Host when a proxy is enabled.

readonly
href: string

Get full request URL.

readonly
idempotent: boolean

Check if the request is idempotent.

readonly
ip: string

Return request's remote address When app.proxy is true, parse the "X-Forwarded-For" ip address list and return the first one

readonly
ips: string[]

When app.proxy is true, parse the "X-Forwarded-For" ip address list.

For example if the value were "client, proxy1, proxy2" you would receive the array ["client", "proxy1", "proxy2"] where "proxy2" is the furthest down-stream.

readonly
length: number | undefined

Return parsed Content-Length when present.

method: HTTPMethods

Get/Set request method.

readonly
origin: string

Get origin of URL.

originalUrl: string
path: string

Get request pathname. Set pathname, retaining the query-string when present.

readonly
protocol: string
query: Query

Get parsed query-string. Set query-string as an object.

querystring: string
readonly
secure: boolean

Short-hand for:

this.protocol == 'https'

readonly
socket: Deno.Conn

Return the request conn.

readonly
stale

Check if the request is stale, aka "Last-Modified" and / or the "ETag" for the resource has changed.

readonly
type: string

Return the request mime type void of parameters such as "charset".

url: string
readonly
URL: URL

Get WHATWG parsed URL object.

Methods

accepts(...types: string[]):
| string
| string[]
| undefined
| boolean
acceptsCharsets(...types: string[]):
| string
| string[]
| undefined
| boolean
acceptsEncodings(...types: string[]):
| string
| string[]
| undefined
| boolean
acceptsLanguages(...types: string[]):
| string
| string[]
| undefined
| boolean
get(field: string): string

Return request header. If the header is not set, will return an empty string.

The Referrer header field is special-cased, both Referrer and Referer are interchangeable.

Examples:

this.get('Content-Type');
// => "text/plain"

this.get('content-type');
// => "text/plain"

this.get('Something');
// => ''

Inspect implementation.

is(types: string | string[]): string | boolean | null

Check whether the response is one of the listed types.

Return JSON representation.

xhr(): Boolean