HttpResponse
Description
The HttpResponse object represents a HTTP response received from a HTTP server. It usually is associated with the corresponding HttpRequest object in the HttpRequest.response property. After a HttpResponse has been received, it’s statusCode should be checked to ensure the desired result. If succesful the content property holds the received data.
- › Inherits:
Overview
Properties
Methods
Signals
Enumerations
Properties
autoDetectDataTypeFromContentType
This property holds whether to automatically detect the data type from the received content type header if any. If disabled, the received data is treated as if it had the configured type.
- › Type:
Boolean
- › Default:
true- › Signal:
autoDetectDataTypeFromContentTypeChanged()
- › Attributes:
Writable
connectionEncrypted
This property holds Indicates whether the data was obtained through an encrypted (secure) connection.
- › Type:
Boolean
- › Signal:
connectionEncryptedChanged()
- › Attributes:
Readonly
content
This property holds the content received from the server.
- › Type:
- › Signal:
contentChanged()
- › Attributes:
Writable
headers
This property holds a list of header objects representing the HTTP headers received from the server.
- › Type:
- › Signal:
headersChanged()
- › Attributes:
Readonly
originalContentLength
This property holds the original content-length attribute before being invalidated and removed from the header when the data is compressed and the request was marked to be decompressed automatically.
- › Type:
SignedBigInteger
- › Signal:
originalContentLengthChanged()
- › Attributes:
Readonly
pipeliningWasUsed
This property holds whether the HTTP pipelining was used for receiving this response.
- › Type:
Boolean
- › Signal:
pipeliningWasUsedChanged()
- › Attributes:
Readonly
reasonPhrase
This property holds the HTTP reason phrase as received from the HTTP server (like “Ok”, “Found”, “Not Found”, “Access Denied”, etc.) This is the human-readable representation of the status code (see statusCode).
- › Type:
String
- › Signal:
reasonPhraseChanged()
- › Attributes:
Readonly
redirectionTarget
This property holds that the server is redirecting the request to a different URL. The API does not by default follow redirections: the application can determine if the requested redirection should be allowed, according to its security policies, or it can set HttpRequest.followRedirects to true (in which case the redirection will be followed and this attribute will be empty in the response). The returned URL might be relative.
- › Type:
String
- › Signal:
redirectionTargetChanged()
- › Attributes:
Readonly
statusCode
This property holds the HTTP status code received from the HTTP server such as 200, 404 etc. See the StatusCode enumeration for details.
- › Type:
- › Signal:
statusCodeChanged()
- › Attributes:
Readonly
Methods
wait(SignedInteger msecs)
This method blocks until the HTTP response has been received. This method will timeout after msecs milliseconds. In most cases the asynchronuous received() signal should be used instead of this synchronuous method.
- › Returns:
Boolean
Signals
headersDataChanged(SignedInteger index)
This signal is emitted whenever the List.dataChanged() signal is emitted, i.e. the item at index in the headers list itself emitted the dataChanged() signal.
received()
This signal is emitted when a response is received for the corresponding request and all properties have been updated with the received data.
Enumerations
StatusCode
This enumeration describes all available Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a client’s request made to the server.
Name |
Value |
Description |
|---|---|---|
|
|
Invalid status code, only internal use. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example
See HttpRequest example on how to use HttpResponse.