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:

Object

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:

HttpContent

› Signal:

contentChanged()

› Attributes:

Writable

headers

This property holds a list of header objects representing the HTTP headers received from the server.

› Type:

List<HttpHeader>

› 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:

StatusCode

› 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

HttpResponse.InvalidStatus

-1

Invalid status code, only internal use.

HttpResponse.Continue

100

See details on status code 100 .

HttpResponse.SwitchingProtocols

101

See details on status code 101 .

HttpResponse.Processing

102

See details on status code 102 .

HttpResponse.OK

200

See details on status code 200 .

HttpResponse.Created

201

See details on status code 201 .

HttpResponse.Accepted

202

See details on status code 202 .

HttpResponse.NonAuthoritativeInformation

203

See details on status code 203 .

HttpResponse.NoContent

204

See details on status code 204 .

HttpResponse.ResetContent

205

See details on status code 205 .

HttpResponse.PartialContent

206

See details on status code 206 .

HttpResponse.MultiStatus

207

See details on status code 207 .

HttpResponse.AlreadyReported

208

See details on status code 208 .

HttpResponse.IMUsed

226

See details on status code 226 .

HttpResponse.MultipleChoices

300

See details on status code 300 .

HttpResponse.MovedPermanently

301

See details on status code 301 .

HttpResponse.Found

302

See details on status code 302 .

HttpResponse.SeeOther

303

See details on status code 303 .

HttpResponse.NotModified

304

See details on status code 304 .

HttpResponse.UseProxy

305

See details on status code 305 .

HttpResponse.TemporaryRedirect

307

See details on status code 307 .

HttpResponse.PermanentRedirect

308

See details on status code 308 .

HttpResponse.BadRequest

400

See details on status code 400 .

HttpResponse.Unauthorized

401

See details on status code 401 .

HttpResponse.PaymentRequired

402

See details on status code 402 .

HttpResponse.Forbidden

403

See details on status code 403 .

HttpResponse.NotFound

404

See details on status code 404 .

HttpResponse.MethodNotAllowed

405

See details on status code 405 .

HttpResponse.NotAcceptable

406

See details on status code 406 .

HttpResponse.ProxyAuthenticationRequired

407

See details on status code 407 .

HttpResponse.RequestTimeout

408

See details on status code 408 .

HttpResponse.Conflict

409

See details on status code 409 .

HttpResponse.Gone

410

See details on status code 410 .

HttpResponse.LengthRequired

411

See details on status code 411 .

HttpResponse.PreconditionFailed

412

See details on status code 412 .

HttpResponse.RequestEntityTooLarge

413

See details on status code 413 .

HttpResponse.URITooLong

414

See details on status code 414 .

HttpResponse.UnsupportedMediaType

415

See details on status code 415 .

HttpResponse.RequestedRangeNotSatisfiable

416

See details on status code 416 .

HttpResponse.ExpectationFailed

417

See details on status code 417 .

HttpResponse.PolicyNotFulfilled

420

See details on status code 420 .

HttpResponse.MisdirectedRequest

421

See details on status code 421 .

HttpResponse.UnprocessableEntity

422

See details on status code 422 .

HttpResponse.Locked

423

See details on status code 423 .

HttpResponse.FailedDependency

424

See details on status code 424 .

HttpResponse.UpgradeRequired

426

See details on status code 426 .

HttpResponse.PreconditionRequired

428

See details on status code 428 .

HttpResponse.TooManyRequests

429

See details on status code 429 .

HttpResponse.RequestHeaderFieldsTooLarge

431

See details on status code 431 .

HttpResponse.UnavailableForLegalReasons

451

See details on status code 451 .

HttpResponse.InternalServerError

500

See details on status code 500 .

HttpResponse.NotImplemented

501

See details on status code 501 .

HttpResponse.BadGateway

502

See details on status code 502 .

HttpResponse.ServiceUnavailable

503

See details on status code 503 .

HttpResponse.GatewayTimeout

504

See details on status code 504 .

HttpResponse.HttpVersionNotSupported

505

See details on status code 505 .

HttpResponse.VariantAlsoNegotiates

506

See details on status code 506 .

HttpResponse.InsufficientStorage

507

See details on status code 507 .

HttpResponse.LoopDetected

508

See details on status code 508 .

HttpResponse.NotExtended

510

See details on status code 510 .

HttpResponse.NetworkAuthenticationRequired

511

See details on status code 511 .

Example

See HttpRequest example on how to use HttpResponse.