Response
A class that creates a definition for an HTTP response.If an exception occurs during processing, most of the properties in the response object are empty.
// Gets the content of a PasteBin paste, assuming that we have received its key (`pasteBinKey`) in a prior request.
var connection = new http.Connection('http://pastebin.com/raw/');
connection.addHeader({name: ‘Content-Type’, value: ‘text/plain’});
var response = connection.getSync(pasteBinKey, '');
if (response && response.code === 200) {
var text = '';
response.headers.forEach(function(header) {
text += header.name + ': ' + header.value + '\n';
});
text += '\n' + response.response;
issue.addComment(text);
}
Properties
Name | Type | Description | Read-only |
---|---|---|---|
code | | The HTTP status code that is assigned to the response.If an exception occurs during processing, the property is empty. | |
exception | | The exception that occurred during processing. | |
headers | | A collection of response headers.If an exception occurs during processing, the collection is empty. | |
isSuccess | | An indication of the success or failure for the request.If the HTTP status code is between 200 (inclusive) and 400 (exclusive), this property is set to 'true'. | |
response | | The response body. If an exception occurs during processing, the response body is empty (null). | |
responseAsStream | | A byte stream representation of the response body.If an exception occurs during processing, the property is empty (null). |