June 2014
Intermediate to advanced
696 pages
38h 52m
English
An important part of formulating a proper HTTP response is to set the headers. For example, setting the Content-Type header tells the browser how to handle responses. The Response object provides several helper methods to get and set the header values that are sent with HTTP responses.
The most commonly used methods are get(header) and set(header, value), which get and set any header value. For example, the following code first gets the Content-Type header and then sets it:
var oldType = res.get('Content-Type');res.set('Content-Type', 'text/plain');
Table 18.3 describes the helper methods to get and set header values.
Table 18.3 Methods to get and set header values on the Response object
Read now
Unlock full access