HttpResponse class
The response for an HTTP request. Returned from the Http service.
class HttpResponse { /** * The HTTP status code. */ int status; /** * DEPRECATED */ var responseText; Map _headers; /** * The [HttpResponseConfig] object which contains the requested URL */ HttpResponseConfig config; /** * Constructor */ HttpResponse([this.status, this.responseText, this._headers, this.config]); /** * Copy constructor. Creates a clone of the response, optionally with new * data. */ HttpResponse.copy(HttpResponse r, {data}) { status = r.status; responseText = data == null ? r.responseText : data; _headers = r._headers == null ? null : new Map.from(r._headers); config = r.config; } /** * The response's data. Either a string or a transformed object. */ get data => responseText; /** * The response's headers. Without parameters, this method will return the * [Map] of headers. With [key] parameter, this method will return the specific * header. */ headers([String key]) { if (key == null) { return _headers; } if (_headers.containsKey(key)) { return _headers[key]; } return null; } /** * Useful for debugging. */ toString() => 'HTTP $status: $data'; }
Constructors
new HttpResponse([int status, responseText, Map _headers, HttpResponseConfig config]) #
Constructor
HttpResponse([this.status, this.responseText, this._headers, this.config]);
new HttpResponse.copy(HttpResponse r, {data}) #
Copy constructor. Creates a clone of the response, optionally with new data.
HttpResponse.copy(HttpResponse r, {data}) { status = r.status; responseText = data == null ? r.responseText : data; _headers = r._headers == null ? null : new Map.from(r._headers); config = r.config; }
Properties
HttpResponseConfig config #
The HttpResponseConfig object which contains the requested URL
HttpResponseConfig config
final data #
The response's data. Either a string or a transformed object.
get data => responseText;
var responseText #
DEPRECATED
var responseText
int status #
The HTTP status code.
int status
Methods
dynamic headers([String key]) #
The response's headers. Without parameters, this method will return the Map of headers. With key parameter, this method will return the specific header.
headers([String key]) { if (key == null) { return _headers; } if (_headers.containsKey(key)) { return _headers[key]; } return null; }
dynamic toString() #
Useful for debugging.
toString() => 'HTTP $status: $data';