Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BodyHandler

A handler which gathers the entire request body and sets it on the .

It also handles HTTP file uploads and can be used to limit body sizes.

Hierarchy

  • BodyHandler

Implements

  • any

Index

Properties

Static Readonly DEFAULT_BODY_LIMIT

DEFAULT_BODY_LIMIT: number

Default max size for a request body = -1 means unlimited

Static Readonly DEFAULT_DELETE_UPLOADED_FILES_ON_END

DEFAULT_DELETE_UPLOADED_FILES_ON_END: boolean

Default value of whether uploaded files should be removed after handling the request

Static Readonly DEFAULT_MERGE_FORM_ATTRIBUTES

DEFAULT_MERGE_FORM_ATTRIBUTES: boolean

Default value of whether form attributes should be merged into request params

Static Readonly DEFAULT_PREALLOCATE_BODY_BUFFER

DEFAULT_PREALLOCATE_BODY_BUFFER: boolean

Default value of whether to pre-allocate the body buffer size according to the content-length HTTP request header

Static Readonly DEFAULT_UPLOADS_DIRECTORY

DEFAULT_UPLOADS_DIRECTORY: string

Default uploads directory on server for file uploads

Methods

handle

  • Parameters

    Returns void

setBodyLimit

  • Set the maximum body size in bytes, -1 means no limit

    Parameters

    • bodyLimit: number

    Returns BodyHandler

setDeleteUploadedFilesOnEnd

  • setDeleteUploadedFilesOnEnd(deleteUploadedFilesOnEnd: boolean): BodyHandler
  • Set whether uploaded files should be removed after handling the request

    Parameters

    • deleteUploadedFilesOnEnd: boolean

    Returns BodyHandler

setHandleFileUploads

  • setHandleFileUploads(handleFileUploads: boolean): BodyHandler
  • Set whether file uploads will be handled

    Parameters

    • handleFileUploads: boolean

    Returns BodyHandler

setMergeFormAttributes

  • setMergeFormAttributes(mergeFormAttributes: boolean): BodyHandler
  • Set whether form attributes will be added to the request parameters

    Parameters

    • mergeFormAttributes: boolean

    Returns BodyHandler

setPreallocateBodyBuffer

  • setPreallocateBodyBuffer(isPreallocateBodyBuffer: boolean): BodyHandler
  • Pre-allocate the body buffer according to the value parsed from content-length header. The buffer is capped at 64KB

    Parameters

    • isPreallocateBodyBuffer: boolean

    Returns BodyHandler

setUploadsDirectory

  • setUploadsDirectory(uploadsDirectory: string): BodyHandler
  • Set the uploads directory to use

    Parameters

    • uploadsDirectory: string

    Returns BodyHandler

Static create

  • Create a body handler with defaults

    Returns BodyHandler

  • Create a body handler setting if it should handle file uploads

    Parameters

    • handleFileUploads: boolean

    Returns BodyHandler

  • Create a body handler and use the given upload directory.

    Parameters

    • uploadDirectory: string

    Returns BodyHandler

Generated using TypeDoc