Creating a request with custom headers
The HTTP headers are a part of the request
object being sent to the server. Many of them give information about the client's user agent setup and configuration, as that is sometimes the basis of making description for the resources being fetched from the server. Several of them such as Etag
, Expires
, and If-Modified-Since
are closely related to caching, while others such as DNT
that stands for "Do Not Track" (http://www.w3.org/2011/tracking-protection/drafts/tracking-dnt.html) can be quite controversial. In this recipe, we will take a look at a way for using the custom X-Myapp
header in our server and client-side code.
Getting ready
The server will be implemented using Node.js, so you can refer to Appendix A, Installing Node.js and Using npm on how to install Node.js on your machine, and how to use npm. In this example, again for simplicity, we will use restify (http://mcavage.github.io/node-restify/). Also, monitoring the console in your browser and...