HttpResponse
Direct Subclass:
HTTP response.
Wraps a XMLHttpRequest to make it easier to get information about the response from the server.
Constructor Summary
Public Constructor | ||
public |
constructor(request: *) |
Member Summary
Public Members | ||
public get |
body: * Get the response body (the responseText attribute of the XMLHttpRequest). |
|
public |
request: * |
|
public get |
status: * Get the status code of the response (the status attribute of the XMLHttpRequest). |
Method Summary
Public Methods | ||
public |
getPrettyfiedBody(): * Get HttpResponse#body pretty formatted. |
|
public |
isClientError(): * Returns |
|
public |
isConnectionRefused(): * Returns |
|
public |
isRedirect(): * Returns |
|
public |
isServerError(): * Returns |
|
public |
isSuccess(): * Returns |
|
public |
Get the response header as string. |
|
public |
Create a HttpResponseError from this HttpResponse. |
|
public |
Format as a string suitable for debugging. |
Public Constructors
public constructor(request: *) source
Params:
Name | Type | Attribute | Description |
request | * | A XMLHttpRequest object. |
Public Members
public request: * source
public get status: * source
Get the status code of the response (the status attribute of the XMLHttpRequest).
Public Methods
public getPrettyfiedBody(): * source
Get HttpResponse#body pretty formatted.
By default, this just returns HttpResponse#body but subclasses can override this to prettify the body if they know the output format of the body.
Return:
* |
public isClientError(): * source
Returns true
if HttpResponse#status is
400 or larger and less than 500.
Return:
* |
public isConnectionRefused(): * source
Returns true
if HttpResponse#status is 0.
Assuming the XMLHttpRequest was actually sent, this
means that the connection was refused.
Return:
* |
public isRedirect(): * source
Returns true
if HttpResponse#status is
300 or larger and less than 400.
Return:
* |
public isSuccess(): * source
Returns true
if HttpResponse#status is
200 or larger and less than 300.
Return:
* |