ClientResponse.headers
Property Description |
The response header or headers. For more information, see HTTP Header Information. |
Type |
Object.<String, String[]> // Client SuiteScript Object.<String, String> // Server SuiteScript |
Module |
|
Parent Object |
|
Sibling Object Members |
|
Since |
2015.2 |
Errors
Error Code |
Thrown If |
---|---|
|
You attempted to edit this property. This property is read-only. |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/http Module Script Samples.
// Add additional code
...
var response = https.get({
url: 'https://www.testwebsite.com'
});
log.debug({
title: 'Client Response Header',
details: response.headers
});
...
// Add additional code
HTTP allows multiple response headers with the same name. Therefore, in the browser (client SuiteScript), a header value is a list of strings. On the server, however, for legacy reasons, a header value is only a string. If a response contains multiple headers with the same name, only the first one can be retrieved.
// Client SuiteScript
>>> response.headers["cache-control"]
[ "no-cache", "no-store" ]
// Server SuiteScript
>>> response.headers["cache-control"]
"no-cache"
HTTP headers are defined as case insensitive. It is best to retrieve specific headers in lower-case. For example, response.headers["content-type"]
..
For compatibility reasons, each header is repeated in two to three cases. For example:
"content-type" // lower-case
"Content-Type" // Title-Case
"CONTENT-type" // original case (if it differs from the previous two)