The http.ServerResponse Object

The HTTP server creates the ServerResponse object internally when it receives a request event. This object is passed to the request event handler as the second argument. You use the ServerRequest object to formulate and send a response to the client.

The ServerResponse object implements a Writable stream, so it provides all the functionality of a Writable stream object. For example, you can use the write() method to write to the ServerResponse object as well as pipe a Readable stream into it to write data back to the client.

When handling the client request, you use the properties, events, and methods of the ServerResponse object to build and send headers; write data; and send the response. Table 7.5 lists the event and properties available on ServerResponse objects. Table 7.6 lists the methods available on ServerResponse objects.

Image

Table 7.5 Events and properties available on ServerResponse objects

Image

Table 7.6 Methods available on ServerResponse objects

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.239.166