IncomingMessage

IncomingMessage

Creates the request object used to access client status, headers and data.

Constructor

new IncomingMessage() → {IncomingMessage}

Source:
Returns:
Type
IncomingMessage

Extends

  • http.IncomingMessage

Members

charset

Source:

Returns the default charset for the current URL.

Example

If the request.pathname is `/script.js`

request.charset // returns 'UTF-8'

contentType

Source:

Returns the default content type for the current URL.

Example

If the request.pathname is `/script.js`

request.contentType // returns 'application/javascript; charset=utf-8'

mimeType

Source:

Returns the default mime type for the current URL.

Example

If the request.pathname is `/script.js`

request.mimeType // returns 'application/javascript'

Methods

includes(pattern) → {Boolean}

Source:

Returns whether the current request matches a particular pattern.

Examples

Match any path name that ends in .js

request.includes('**.js')
request.includes(/\.js$/)
request.includes({ path: '**.js' })
request.includes({ path: /\.js$/ })

Match any GET or POST request on port 80 or 443 that ends in .js

request.includes('GET|POST:80|443 **.js')
request.includes({ method: 'GET|POST', port: '80|443', path: '**.js' })
request.includes({ method: ['GET', 'POST'], port: [80, 443], path: /\.js$/ })
Parameters:
Name Type Description
pattern Object | String | RegExp

The pattern used to match the current request.

Returns:

Whether the pattern matched the current request.

Type
Boolean