Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface RequestWithRawBody

An Express Request with a buffer containing the raw HTTP body

Hierarchy

  • Request
    • RequestWithRawBody

Index

Properties

aborted

aborted: boolean

accepted

accepted: MediaType[]

Return an array of Accepted media types ordered from highest quality to lowest.

app

app: Application

Optional authInfo

authInfo: AuthInfo

baseUrl

baseUrl: string

body

body: any

complete

complete: boolean

connection

connection: Socket
deprecated

since v13.0.0 - Use socket instead.

cookies

cookies: any

destroyed

destroyed: boolean

Optional file

file: File

Multer.File object populated by single() middleware.

Optional files

files: File[] | {}

Array or dictionary of Multer.File object populated by array(), fields(), and any() middleware.

fresh

fresh: boolean

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

headers

headers: IncomingHttpHeaders

host

host: string
deprecated

Use hostname instead.

hostname

hostname: string

Parse the "Host" header field hostname.

httpVersion

httpVersion: string

httpVersionMajor

httpVersionMajor: number

httpVersionMinor

httpVersionMinor: number

ip

ip: string

Return the remote address, or when "trust proxy" is true return the upstream addr.

ips

ips: string[]

When "trust 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.

method

method: string

Optional next

next: NextFunction

originalUrl

originalUrl: string

params

params: ParamsDictionary

path

path: string

Short-hand for url.parse(req.url).pathname.

protocol

protocol: string

Return the protocol string "http" or "https" when requested with TLS. When the "trust proxy" setting is enabled the "X-Forwarded-Proto" header field will be trusted. If you're running behind a reverse proxy that supplies https for you this may be enabled.

query

query: ParsedQs

rawBody

rawBody: Buffer

The raw HTTP body

rawHeaders

rawHeaders: string[]

rawTrailers

rawTrailers: string[]

readable

readable: boolean

Readonly readableEncoding

readableEncoding: null | BufferEncoding

Readonly readableEnded

readableEnded: boolean

Readonly readableFlowing

readableFlowing: null | boolean

Readonly readableHighWaterMark

readableHighWaterMark: number

Readonly readableLength

readableLength: number

Readonly readableObjectMode

readableObjectMode: boolean

Optional res

res: Response<any, Record<string, any>, number>

After middleware.init executed, Request will contain res and next properties See: express/lib/middleware/init.js

route

route: any

secure

secure: boolean

Short-hand for:

req.protocol == 'https'

Optional session

session: null | CookieSessionObject

Represents the session for the given request.

sessionOptions

sessionOptions: CookieSessionOptions

Represents the session options for the current request. These options are a shallow clone of what was provided at middleware construction and can be altered to change cookie setting behavior on a per-request basis.

signedCookies

signedCookies: any

socket

socket: Socket

stale

stale: boolean

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

Optional statusCode

statusCode: number

Only valid for response obtained from http.ClientRequest.

Optional statusMessage

statusMessage: string

Only valid for response obtained from http.ClientRequest.

subdomains

subdomains: string[]

Return subdomains as an array.

Subdomains are the dot-separated parts of the host before the main domain of the app. By default, the domain of the app is assumed to be the last two parts of the host. This can be changed by setting "subdomain offset".

For example, if the domain is "tobi.ferrets.example.com": If "subdomain offset" is not set, req.subdomains is ["ferrets", "tobi"]. If "subdomain offset" is 3, req.subdomains is ["tobi"].

trailers

trailers: Dict<string>

url

url: string

Optional user

user: User

xhr

xhr: boolean

Check if the request was an XMLHttpRequest.

Methods

[asyncIterator]

  • [asyncIterator](): AsyncIterableIterator<any>
  • Returns AsyncIterableIterator<any>

_destroy

  • _destroy(error: null | Error, callback: (error?: null | Error) => void): void
  • Parameters

    • error: null | Error
    • callback: (error?: null | Error) => void
        • (error?: null | Error): void
        • Parameters

          • Optional error: null | Error

          Returns void

    Returns void

_read

  • _read(size: number): void
  • Parameters

    • size: number

    Returns void

accepts

  • accepts(): string[]
  • accepts(type: string): string | false
  • accepts(type: string[]): string | false
  • accepts(...type: string[]): string | false
  • Check if the given type(s) is acceptable, returning the best match when true, otherwise undefined, in which case you should respond with 406 "Not Acceptable".

    The type value may be a single mime type string such as "application/json", the extension name such as "json", a comma-delimted list such as "json, html, text/plain", or an array ["json", "html", "text/plain"]. When a list or array is given the best match, if any is returned.

    Examples:

    // Accept: text/html
    req.accepts('html');
    // => "html"
    
    // Accept: text/*, application/json
    req.accepts('html');
    // => "html"
    req.accepts('text/html');
    // => "text/html"
    req.accepts('json, text');
    // => "json"
    req.accepts('application/json');
    // => "application/json"
    
    // Accept: text/*, application/json
    req.accepts('image/png');
    req.accepts('png');
    // => undefined
    
    // Accept: text/*;q=.5, application/json
    req.accepts(['html', 'json']);
    req.accepts('html, json');
    // => "json"
    

    Returns string[]

  • Parameters

    • type: string

    Returns string | false

  • Parameters

    • type: string[]

    Returns string | false

  • Parameters

    • Rest ...type: string[]

    Returns string | false

acceptsCharsets

  • acceptsCharsets(): string[]
  • acceptsCharsets(charset: string): string | false
  • acceptsCharsets(charset: string[]): string | false
  • acceptsCharsets(...charset: string[]): string | false
  • Returns the first accepted charset of the specified character sets, based on the request's Accept-Charset HTTP header field. If none of the specified charsets is accepted, returns false.

    For more information, or if you have issues or concerns, see accepts.

    Returns string[]

  • Parameters

    • charset: string

    Returns string | false

  • Parameters

    • charset: string[]

    Returns string | false

  • Parameters

    • Rest ...charset: string[]

    Returns string | false

acceptsEncodings

  • acceptsEncodings(): string[]
  • acceptsEncodings(encoding: string): string | false
  • acceptsEncodings(encoding: string[]): string | false
  • acceptsEncodings(...encoding: string[]): string | false
  • Returns the first accepted encoding of the specified encodings, based on the request's Accept-Encoding HTTP header field. If none of the specified encodings is accepted, returns false.

    For more information, or if you have issues or concerns, see accepts.

    Returns string[]

  • Parameters

    • encoding: string

    Returns string | false

  • Parameters

    • encoding: string[]

    Returns string | false

  • Parameters

    • Rest ...encoding: string[]

    Returns string | false

acceptsLanguages

  • acceptsLanguages(): string[]
  • acceptsLanguages(lang: string): string | false
  • acceptsLanguages(lang: string[]): string | false
  • acceptsLanguages(...lang: string[]): string | false
  • Returns the first accepted language of the specified languages, based on the request's Accept-Language HTTP header field. If none of the specified languages is accepted, returns false.

    For more information, or if you have issues or concerns, see accepts.

    Returns string[]

  • Parameters

    • lang: string

    Returns string | false

  • Parameters

    • lang: string[]

    Returns string | false

  • Parameters

    • Rest ...lang: string[]

    Returns string | false

addListener

  • Event emitter The defined events on documents including:

    1. close
    2. data
    3. end
    4. error
    5. pause
    6. readable
    7. resume

    Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "data"
    • listener: (chunk: any) => void
        • (chunk: any): void
        • Parameters

          • chunk: any

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "end"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "pause"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "readable"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "resume"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns RequestWithRawBody

csrfToken

  • csrfToken(): string
  • Returns string

destroy

  • destroy(error?: Error): void
  • Parameters

    • Optional error: Error

    Returns void

emit

  • emit(event: "close"): boolean
  • emit(event: "data", chunk: any): boolean
  • emit(event: "end"): boolean
  • emit(event: "error", err: Error): boolean
  • emit(event: "pause"): boolean
  • emit(event: "readable"): boolean
  • emit(event: "resume"): boolean
  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: "close"

    Returns boolean

  • Parameters

    • event: "data"
    • chunk: any

    Returns boolean

  • Parameters

    • event: "end"

    Returns boolean

  • Parameters

    • event: "error"
    • err: Error

    Returns boolean

  • Parameters

    • event: "pause"

    Returns boolean

  • Parameters

    • event: "readable"

    Returns boolean

  • Parameters

    • event: "resume"

    Returns boolean

  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

get

  • get(name: "set-cookie"): undefined | string[]
  • get(name: string): undefined | string
  • Return request header.

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

    Examples:

    req.get('Content-Type');
    // => "text/plain"
    
    req.get('content-type');
    // => "text/plain"
    
    req.get('Something');
    // => undefined
    

    Aliased as req.header().

    Parameters

    • name: "set-cookie"

    Returns undefined | string[]

  • Parameters

    • name: string

    Returns undefined | string

getMaxListeners

  • getMaxListeners(): number
  • Returns number

header

  • header(name: "set-cookie"): undefined | string[]
  • header(name: string): undefined | string
  • Parameters

    • name: "set-cookie"

    Returns undefined | string[]

  • Parameters

    • name: string

    Returns undefined | string

is

  • is(type: string | string[]): null | string | false
  • Check if the incoming request contains the "Content-Type" header field, and it contains the give mime type.

    Examples:

     // With Content-Type: text/html; charset=utf-8
     req.is('html');
     req.is('text/html');
     req.is('text/*');
     // => true
    
     // When Content-Type is application/json
     req.is('json');
     req.is('application/json');
     req.is('application/*');
     // => true
    
     req.is('html');
     // => false
    

    Parameters

    • type: string | string[]

    Returns null | string | false

isAuthenticated

  • isAuthenticated(): this is AuthenticatedRequest
  • Returns this is AuthenticatedRequest

isPaused

  • isPaused(): boolean
  • Returns boolean

isUnauthenticated

  • isUnauthenticated(): this is UnauthenticatedRequest
  • Returns this is UnauthenticatedRequest

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

logIn

  • logIn(user: User, done: (err: any) => void): void
  • logIn(user: User, options: any, done: (err: any) => void): void
  • Parameters

    • user: User
    • done: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

  • Parameters

    • user: User
    • options: any
    • done: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

logOut

  • logOut(): void
  • Returns void

login

  • login(user: User, done: (err: any) => void): void
  • login(user: User, options: any, done: (err: any) => void): void
  • Parameters

    • user: User
    • done: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

  • Parameters

    • user: User
    • options: any
    • done: (err: any) => void
        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

logout

  • logout(): void
  • Returns void

off

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns RequestWithRawBody

on

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "data"
    • listener: (chunk: any) => void
        • (chunk: any): void
        • Parameters

          • chunk: any

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "end"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "pause"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "readable"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "resume"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns RequestWithRawBody

once

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "data"
    • listener: (chunk: any) => void
        • (chunk: any): void
        • Parameters

          • chunk: any

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "end"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "pause"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "readable"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "resume"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns RequestWithRawBody

param

  • param(name: string, defaultValue?: any): string
  • deprecated

    since 4.11 Use either req.params, req.body or req.query, as applicable.

    Return the value of param name when present or defaultValue.

    • Checks route placeholders, ex: /user/:id
    • Checks body params, ex: id=12, {"id":12}
    • Checks query string params, ex: ?id=12

    To utilize request bodies, req.body should be an object. This can be done by using the connect.bodyParser() middleware.

    Parameters

    • name: string
    • Optional defaultValue: any

    Returns string

pause

  • Returns RequestWithRawBody

pipe

  • pipe<T>(destination: T, options?: { end?: boolean }): T
  • Type parameters

    • T: WritableStream<T>

    Parameters

    • destination: T
    • Optional options: { end?: boolean }
      • Optional end?: boolean

    Returns T

prependListener

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "data"
    • listener: (chunk: any) => void
        • (chunk: any): void
        • Parameters

          • chunk: any

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "end"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "pause"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "readable"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "resume"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns RequestWithRawBody

prependOnceListener

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "data"
    • listener: (chunk: any) => void
        • (chunk: any): void
        • Parameters

          • chunk: any

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "end"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "pause"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "readable"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "resume"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns RequestWithRawBody

push

  • push(chunk: any, encoding?: BufferEncoding): boolean
  • Parameters

    • chunk: any
    • Optional encoding: BufferEncoding

    Returns boolean

range

  • range(size: number, options?: Options): undefined | Ranges | Result
  • Parse Range header field, capping to the given size.

    Unspecified ranges such as "0-" require knowledge of your resource length. In the case of a byte range this is of course the total number of bytes. If the Range header field is not given undefined is returned. If the Range header field is given, return value is a result of range-parser. See more ./types/range-parser/index.d.ts

    NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" should respond with 4 users when available, not 3.

    Parameters

    • size: number
    • Optional options: Options

    Returns undefined | Ranges | Result

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

read

  • read(size?: number): any
  • Parameters

    • Optional size: number

    Returns any

removeAllListeners

  • Parameters

    • Optional event: string | symbol

    Returns RequestWithRawBody

removeListener

  • Parameters

    • event: "close"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "data"
    • listener: (chunk: any) => void
        • (chunk: any): void
        • Parameters

          • chunk: any

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "end"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "error"
    • listener: (err: Error) => void
        • (err: Error): void
        • Parameters

          • err: Error

          Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "pause"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "readable"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: "resume"
    • listener: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns RequestWithRawBody

resume

  • Returns RequestWithRawBody

setEncoding

  • Parameters

    • encoding: BufferEncoding

    Returns RequestWithRawBody

setMaxListeners

  • Parameters

    • n: number

    Returns RequestWithRawBody

setTimeout

  • Parameters

    • msecs: number
    • Optional callback: () => void
        • (): void
        • Returns void

    Returns RequestWithRawBody

unpipe

  • Parameters

    • Optional destination: WritableStream

    Returns RequestWithRawBody

unshift

  • unshift(chunk: any, encoding?: BufferEncoding): void
  • Parameters

    • chunk: any
    • Optional encoding: BufferEncoding

    Returns void

wrap

  • Parameters

    • oldStream: ReadableStream

    Returns RequestWithRawBody

Generated using TypeDoc