import { Oak } from "https://deno.land/x/oak_http_proxy@2.3.0/test/deps.ts";
const { Request } = Oak;
An interface which provides information about the current request. The
instance related to the current request is available on the
Context
's .request
property.
The interface contains several properties to get information about the request as well as several methods, which include content negotiation and the ability to decode a request body.
Properties
Is true
if the request might have a body, otherwise false
.
WARNING this is an unreliable API. In HTTP/2 in many situations you cannot determine if a request has a body or not unless you attempt to read the body, due to the streaming nature of HTTP/2. As of Deno 1.16.1, for HTTP/1.1, Deno also reflects that behaviour. The only reliable way to determine if a request has a body or not is to attempt to read the body.
The Headers
supplied in the request.
Request remote address. When the application's .proxy
is true, the
X-Forwarded-For
will be used to determine the requesting remote address.
When the application's .proxy
is true
, this will be set to an array of
IPs, ordered from upstream to downstream, based on the value of the header
X-Forwarded-For
. When false
an empty array is returned.
The HTTP Method used by the request.
A parsed URL for the request which complies with the browser standards.
When the application's .proxy
is true
, this value will be based off of
the X-Forwarded-Proto
and X-Forwarded-Host
header values if present in
the request.
An object representing the requesting user agent. If the User-Agent
header isn't defined in the request, all the properties will be undefined.
See std/http/user_agent#UserAgent for more information.
Methods
Returns an array of media types, accepted by the requestor, in order of preference. If there are no encodings supplied by the requestor, then accepting any is implied is returned.
For a given set of media types, return the best match accepted by the
requestor. If there are no encoding that match, then the method returns
undefined
.
Returns an array of encodings, accepted by the requestor, in order of
preference. If there are no encodings supplied by the requestor,
then ["*"]
is returned, matching any.
For a given set of encodings, return the best match accepted by the
requestor. If there are no encodings that match, then the method returns
undefined
.
NOTE: You should always supply identity
as one of the encodings
to ensure that there is a match when the Accept-Encoding
header is part
of the request.
Returns an array of languages, accepted by the requestor, in order of
preference. If there are no languages supplied by the requestor,
["*"]
is returned, indicating any language is accepted.
For a given set of languages, return the best match accepted by the
requestor. If there are no languages that match, then the method returns
undefined
.