Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You can use the response object
in Node.js to display client-specific information in the
browser.
Now that we have hacked our request object, let’s tackle the response. We
can begin by calling the writeHead()
method and passing the success response
code, along with the Content-Type set
to text/plain. This is a pretty
standard response. Then we will call the end() method and pass it a specific string based
on the properties we added to our global DeviceData object.
res.writeHead(200,{'Content-Type':'text/plain'});if(DeviceData.mobile){res.end('Hello Html5\n Request from a Mobile Device');}if(DeviceData