import { IncomingMessage } from "@rill/http"; import { Types as T } from "./_types"; import Context from "./context"; export default class Request { ctx: Context; original: IncomingMessage; /** The path part of the url (eg: /a/b?c=d#e). */ path: string; /** The method for the request (eg: /a/b?c=d#e). */ method: string; /** The http headers for the request (eg: GET). */ headers: T.Headers; /** True if the request is https. */ secure: boolean; /** The path parameters object. */ params: T.StringOrNumberMap; /** The parsed request cookies. */ cookies: T.StringMap; /** The origin part of the request. */ origin: string; /** The protocol for the request (eg: http). */ protocol: string; /** The hostname for the request (eg: google.ca). */ hostname: string; /** The pathname for the request (eg: /a/b). */ pathname: string; /** The raw querystring for the request (eg: ?c=d). */ search: string; /** The hostname + the port for the request. (eg: google.ca:443) */ host: string; /** The port used for the request. */ port: string; /** The hash part of the request (eg: #e). */ hash: string; /** The entire URL for the request (eg: http://google.ca/a/b?c=d#e) */ href: string; /** The requestee's IP address. */ ip: string; /** A placeholder for the parsed request body (see @rill/body). */ body: any; /** A placeholder for the parsed request files (see @rill/body). */ files: any; /** The parsed search object from above (eg: { c: "d" }). */ query: T.StringMapNested; /** A list of subdomains (after the top level domain) for the request. */ subdomains: string[]; /** Allow tools to attach methods/properties. */ [x: string]: any; /** * @description * Wrapper around nodejs `IncomingMessage` that has pre parsed url * and other conveniences. * * @param ctx The related Rill Context for the request. * @param original The original IncomingMessage from rill/http. */ constructor(ctx: Context, original: IncomingMessage); /** * @description * Utility to retrieve a header from the request. * * @example * request.get('Host') // -> 'test.com' * * @param name The name of the request header to get. */ get(name: string): string | string[]; }