http.Response#
Implements: Stream (read only)
The Response object is returned from http requests or passed as an argument to request callbacks. It represents the incoming message from the HTTP server. It implements the readable stream interface.
Properties#
Response.status_code#
HTTP status code, e.g. 200, 500, etc.
Response.status_message#
HTTP response status message, e.g. OK or Internal Server Error.
Response.error#
The error found during the processing of the request. Errors are static properties of Response, e.g. Response.READ_MODE. If no error occurred, this will be set to NO_ERROR.
Error |
Value |
Description |
|---|---|---|
|
0 |
No error occurred. |
|
1 |
The remote server refused the connection (the server is not accepting requests). |
|
2 |
The remote server closed the connection prematurely, before the entire reply was received and processed. |
|
3 |
The remote host name was not found (invalid hostname). |
|
4 |
The connection to the remote server timed out. |
|
5 |
The operation was cancelLed via calls to |
|
6 |
The SSL/TLS handshake failed and the encrypted channel could not be established. |
|
7 |
The connection was broken due to disconnection from the network, however the request should be resubmitted and will be processed as soon as the connection is re-established. |
|
8 |
The connection was broken due to disconnection from the network or failure to start the network. |
|
10 |
While following redirects, the maximum limit of 50 was reached. |
|
11 |
While following redirects, a redirect from an encrypted protocol (HTTPS) to an unencrypted one (HTTP) was detected. |
|
99 |
An unknown network-related error was detected. |
|
201 |
The access to the remote content was denied. |
|
202 |
The operation on the remote content is not permitted. |
|
203 |
The remote content was not found at the server. |
|
204 |
The remote server requires authentication to serve the content but the credentials provided were not accepted. |
|
205 |
The request needed to be sent again but this failed, for example because the upload data could not be read a second time. |
|
206 |
The request could not be completed due to a conflict with the current state of the resource. |
|
207 |
The requested resource is no longer available at the server. |
|
299 |
An unknown error related to the remote content was detected. |
|
301 |
The controller cannot process the request because the protocol is not known. |
|
302 |
The requested operation is invalid for this protocol. |
|
399 |
A breakdown in protocol was detected (parsing error, invalid or unexpected responses, etc.) |
|
401 |
The server encountered an unexpected condition which prevented it from fulfilling the request. |
|
402 |
The server does not support the functionality required to fulfill the request. |
|
403 |
The server is unable to handle the request at this time. |
|
499 |
An unknown error related to the server response was detected. |
Response.headers#
Table of headers in the response (see HTTP Headers).
Event handlers#
Response.download_progress_handler#
The handler has the following signature:
function(response, bytesreceived, bytestotal)
The handler is called to indicate download progress of the request, if any, otherwise it’s called once with bytesreceived and bytestotal both at 0. If the download size is not known, bytestotal will be -1.
Response.upload_progresss_handler#
The handler has the following signature:
function(response, bytessent, bytestotal)
The handler is called to indicate upload progress of the request, if any, otherwise it’s not called.
Response.finished_handler#
The handler has the following signature:
function(response)
The handler is called when all the data has been received from the HTTP server.
Response.error_handler#
The handler has the following signature:
function(response, error)
The handler is called if an error occurs while processing the response. The finished_handler will probably be called next.