Either the HTTP server or the HTTP client creates the IncomingMessage
object. On the server side the client request is represented by an IncomingMessage
object, and on the client side the server response is represented by an IncomingMessage
object. The reason that the IncomingMessage
object can be used for both is that the functionality is basically the same.
The IncomingMessage
object implements a Readable
stream, allowing you to read the client request or server response as a streaming source. This means that the readable
and data
events can be listened on and used to read data from the stream.
In addition to the functionality provided by the Readable
class, IncomingMessage
objects also provide the properties, events, and methods listed in Table 7.7. These allow you to access information from the client request or server response.