ClientResponse.headers

Note:

The content in this help topic pertains to SuiteScript 2.0.

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

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Module

N/http Module

Parent Object

http.ClientResponse

Sibling Object Members

ClientResponse Object Members

Since

2015.2

Errors

Error Code

Thrown If

READ_ONLY_PROPERTY

You attempted to edit this property. This property is read-only.

Syntax
Important:

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) 

        

Related Topics

http.ClientResponse
HTTP Header Information
N/http Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices