Request.accepts(String)
Checks if the specified content types are acceptable, based on the request’s Accept HTTP header field.
Checks if the specified content types are acceptable, based on the request’s Accept HTTP header field. The method returns the best match, or if none of the specified content types is acceptable, returns false (in which case, the application should respond with 406 "Not Acceptable").
The type value may be a single MIME type string (such as “application/json”), an extension name such as “json”, a comma-delimited list, or an array. For a list or array, the method returns the best match (if any).
This property holds a reference to the instance of the Express application that is using the middleware.
This property holds a reference to the instance of the Express application that is using the middleware. If you follow the pattern in which you create a module that just exports a middleware function and require() it in your main file, then the middleware can access the Express instance via req.app
The URL path on which a router instance was mounted.
The URL path on which a router instance was mounted. The req.baseUrl property is similar to the mountpath property of the app object, except app.mountpath returns the matched path pattern(s).
Contains key-value pairs of data submitted in the request body.
Contains key-value pairs of data submitted in the request body. By default, it is undefined, and is populated when you use body-parsing middleware such as body-parser and multer. The following example shows how to use body-parsing middleware to populate req.body
When using cookie-parser middleware, this property is an object that contains cookies sent by the request.
When using cookie-parser middleware, this property is an object that contains cookies sent by the request. If the request contains no cookies, it defaults to {}.
Indicates whether the request is “fresh.” It is the opposite of req.stale.
Indicates whether the request is “fresh.” It is the opposite of req.stale. It is true if the cache-control request header doesn’t have a no-cache directive and any of the following are true:
Returns the specified HTTP request header field (case-insensitive match).
Returns the specified HTTP request header field (case-insensitive match). The Referrer and Referer fields are interchangeable.
Contains the hostname derived from the Host HTTP header.
Contains the hostname derived from the Host HTTP header. When the trust proxy setting does not evaluate to false, this property will instead have the value of the X-Forwarded-Host header field. This header can be set by the client or by the proxy.
Contains the remote IP address of the request.
Contains the remote IP address of the request. When the trust proxy setting does not evaluate to false, the value of this property is derived from the left-most entry in the X-Forwarded-For header. This header can be set by the client or by the proxy.
When the trust proxy setting does not evaluate to false, this property contains an array of IP addresses specified in the X-Forwarded-For request header.
When the trust proxy setting does not evaluate to false, this property contains an array of IP addresses specified in the X-Forwarded-For request header. Otherwise, it contains an empty array. This header can be set by the client or by the proxy.
For example, if X-Forwarded-For is client, proxy1, proxy2, req.ips would be ["client", "proxy1", "proxy2"], where proxy2 is the furthest downstream.
Returns true if the incoming request’s “Content-Type” HTTP header field matches the MIME type specified by the type parameter.
Returns true if the incoming request’s “Content-Type” HTTP header field matches the MIME type specified by the type parameter. Returns false otherwise.
Contains a string corresponding to the HTTP method of the request: GET, POST, PUT, and so on.
This property is much like req.url; however, it retains the original request URL, allowing you to rewrite req.url freely for internal routing purposes.
This property is much like req.url; however, it retains the original request URL, allowing you to rewrite req.url freely for internal routing purposes. For example, the “mounting” feature of app.use() will rewrite req.url to strip the mount point.
Returns the value of param name when present.
This property is an object containing properties mapped to the named route “parameters”.
This property is an object containing properties mapped to the named route “parameters”. For example, if you have the route /user/:name, then the “name” property is available as req.params.name. This object defaults to {}.
Contains the path part of the request URL.
Contains the request protocol string: either http or (for TLS requests) https.
Contains the request protocol string: either http or (for TLS requests) https. When the trust proxy setting does not evaluate to false, this property will use the value of the X-Forwarded-Proto header field if present. This header can be set by the client or by the proxy.
Returns an object containing a property for each query string parameter in the route.
Returns an object containing a property for each query string parameter in the route. If there is no query string, it is the empty object, {}.
Contains the currently-matched route, a string.
A Boolean property that is true if a TLS connection is established.
A Boolean property that is true if a TLS connection is established. Equivalent to:
'https' == req.protocol
.
When using cookie-parser middleware, this property contains signed cookies sent by the request, unsigned and ready for use.
When using cookie-parser middleware, this property contains signed cookies sent by the request, unsigned and ready for use. Signed cookies reside in a different object to show developer intent; otherwise, a malicious attack could be placed on req.cookie values (which are easy to spoof). Note that signing a cookie does not make it “hidden” or encrypted; but simply prevents tampering (because the secret used to sign is private).
If no signed cookies are sent, the property defaults to {}.
Indicates whether the request is “stale,” and is the opposite of req.fresh.
Indicates whether the request is “stale,” and is the opposite of req.fresh.
An array of sub-domains in the domain name of the request.
A Boolean property that is true if the request’s X-Requested-With header field is “XMLHttpRequest”, indicating that the request was issued by a client library such as jQuery.
Express Http Request
http://expressjs.com/en/api.html