Request¶
Represents an incoming HTTP request.
const Request = require('oauth2-server').Request;
new Request(options)¶
Instantiates Request using the supplied options.
Arguments:
| Name | Type | Description |
|---|---|---|
| options | Object | Request options. |
| options.method | String | The HTTP method of the request. |
| options.query | Object | The request’s query string parameters. |
| options.headers | Object | The request’s HTTP header fields. |
| [options.body={}] | Object | Key-value pairs of data submitted in the request body. |
All additional own properties are copied to the new Request object as well.
Return value:
A new Request instance.
Remarks:
The names of HTTP header fields passed in as options.headers are converted to lower case.
To convert Express’ request to a Request simply pass req as options:
function(req, res, next) {
var request = new Request(req);
// ...
}
get(field)¶
Returns the specified HTTP header field. The match is case-insensitive.
Arguments:
| Name | Type | Description |
|---|---|---|
| field | String | The header field name. |
Return value:
The value of the header field or undefined if the field does not exist.
is(types)¶
Checks if the request’s Content-Type HTTP header matches any of the given MIME types.
Arguments:
| Name | Type | Description |
|---|---|---|
| types | Array<String>|String | The MIME type(s) to test against. |
Return value:
Returns the matching MIME type or false if there was no match.
headers¶
The request’s HTTP header fields. Prefer Request#get() over accessing this object directly.
body¶
Key-value pairs of data submitted in the request body.