An IncomingMessage object is created by http.Server or http.ClientRequest and passed as the first argument to the 'request' and 'response' event respectively.
It may be used to access response status, headers and data.
It implements the Readable Stream interface, as well as the following additional events, methods, and properties.
Variables
read onlycomplete:Bool
The complete property will be true if a complete HTTP message has been received and successfully parsed.
read onlyheaders:DynamicAccess<EitherType<String, Array<String>>>
The request/response headers object.
Key-value pairs of header names and values. Header names are lower-cased.
Duplicates in raw headers are handled in the following ways, depending on the header name:
- Duplicates of
age,authorization,content-length,content-type,etag,expires,from,host,if-modified-since,if-unmodified-since,last-modified,location,max-forwards,proxy-authorization,referer,retry-after, oruser-agentare discarded. set-cookieis always an array. Duplicates are added to the array.- For duplicate
cookieheaders, the values are joined together with '; '. - For all other headers, the values are joined together with ', '.
read onlyhttpVersion:String
In case of server request, the HTTP version sent by the client.
In the case of client response, the HTTP version of the connected-to server.
Probably either '1.1' or '1.0'.
read onlymethod:Method
Only valid for request obtained from* Server.
The request method as a string.
Read only. Example: 'GET', 'DELETE'.
read onlyrawHeaders:Array<String>
The raw request/response headers list exactly as they were received.
The keys and values are in the same list. It is not a list of tuples. So, the even-numbered offsets are key values, and the odd-numbered offsets are the associated values.
Header names are not lowercased, and duplicates are not merged.
read onlyrawTrailers:Array<String>
The raw request/response trailer keys and values exactly as they were received.
Only populated at the 'end' event.
read onlysocket:Socket
The Socket object associated with the connection.
With HTTPS support, use request.socket.getPeerCertificate() to obtain the client's authentication details.
read onlystatusCode:Int
Only valid for response obtained from* ClientRequest.
The 3-digit HTTP response status code. E.G. 404.
read onlystatusMessage:String
Only valid for response obtained from* ClientRequest.
The HTTP response status message (reason phrase). E.G. OK or Internal Server Error.
read onlytrailers:DynamicAccess<String>
The request/response trailers object.
Only populated after the 'end' event.
Methods
destroy(?error:Error):IncomingMessage
Calls destroy() on the socket that received the IncomingMessage.
If error is provided, an 'error' event is emitted and error is passed as an argument to any listeners on the event.