Represents a reply of the nymea webserver to a HttpRequest. More...
Header: | #include <HttpReply> |
Inherits: |
enum | HttpHeaderType { ContentTypeHeader, ContentLenghtHeader, ConnectionHeader, LocationHeader, ..., ServerHeader } |
enum | HttpStatusCode { Ok, Created, Accepted, NoContent, ..., HttpVersionNotSupported } |
enum | Type { TypeSync, TypeAsync } |
HttpReply(QObject * parent = 0) | |
HttpReply(const HttpStatusCode & statusCode = HttpStatusCode::Ok, const Type & type = TypeSync, QObject * parent = 0) | |
void | clear() |
QUuid | clientId() const |
bool | closeConnection() const |
QByteArray | data() const |
QByteArray | httpReasonPhrase() const |
HttpStatusCode | httpStatusCode() const |
bool | isEmpty() const |
void | packReply() |
QByteArray | payload() const |
QByteArray | rawHeader() const |
QHash<QByteArray, QByteArray> | rawHeaderList() const |
void | setClientId(const QUuid & clientId) |
void | setCloseConnection(const bool & close) |
void | setHeader(const HttpHeaderType & headerType, const QByteArray & value) |
void | setHttpStatusCode(const HttpStatusCode & statusCode) |
void | setPayload(const QByteArray & data) |
void | setRawHeader(const QByteArray headerType, const QByteArray & value) |
bool | timedOut() const |
Type | type() const |
void | startWait() |
void | finished() |
Represents a reply of the nymea webserver to a HttpRequest.
This class holds the header and the payload data of a network reply and represents a response from the nymea webserver to a HttpRequest.
Note: RFC 7231 HTTP/1.1 Semantics and Content -> http://tools.ietf.org/html/rfc7231
This enum type specifies the known type of a header in a HTTP webserver reply. You can find more information here: http://tools.ietf.org/html/rfc7231#section-5
Constant | Value | Description |
---|---|---|
nymeaserver::HttpReply::ContentTypeHeader | 0 | The content type header i.e. application/json. |
nymeaserver::HttpReply::ContentLenghtHeader | 1 | The length of the sent content. |
nymeaserver::HttpReply::ConnectionHeader | 2 | The connection header. |
nymeaserver::HttpReply::LocationHeader | 3 | The location header. |
nymeaserver::HttpReply::UserAgentHeader | 4 | The user agent of the client. |
nymeaserver::HttpReply::CacheControlHeader | 5 | The cache control header. |
nymeaserver::HttpReply::AllowHeader | 6 | The allowed methods header. |
nymeaserver::HttpReply::DateHeader | 7 | The server date header. |
nymeaserver::HttpReply::ServerHeader | 8 | The name of the server i.e. "Server: nymea/0.6.0" |
This enum type specifies the status code of a HTTP webserver reply.
You can find more information here: http://tools.ietf.org/html/rfc7231#section-6.1
Constant | Value | Description |
---|---|---|
nymeaserver::HttpReply::Ok | 200 | The request was understood and everything is Ok. |
nymeaserver::HttpReply::Created | 201 | The resource was created successfully. |
nymeaserver::HttpReply::Accepted | 202 | The resource was accepted. |
nymeaserver::HttpReply::NoContent | 204 | The request has no content but it was expected. |
nymeaserver::HttpReply::Found | 302 | The resource was found. |
nymeaserver::HttpReply::PermanentRedirect | 308 | The resource redirects permanent to given url. |
nymeaserver::HttpReply::BadRequest | 400 | The request was bad formatted. Also if a Param was not understood or the header is not correct. |
nymeaserver::HttpReply::Forbidden | 403 | The request tries to get access to a forbidden space. |
nymeaserver::HttpReply::NotFound | 404 | The requested resource could not be found. |
nymeaserver::HttpReply::MethodNotAllowed | 405 | The request method is not allowed. See "Allowed-Methods" header for the allowed methods. |
nymeaserver::HttpReply::RequestTimeout | 408 | The request method timed out. Default timeout = 5s. |
nymeaserver::HttpReply::Conflict | 409 | The request resource conflicts with an other. |
nymeaserver::HttpReply::InternalServerError | 500 | There was an internal server error. |
nymeaserver::HttpReply::NotImplemented | 501 | The requestet method call is not implemented. |
nymeaserver::HttpReply::BadGateway | 502 | The gateway is not correct. |
nymeaserver::HttpReply::ServiceUnavailable | 503 | The service is not available at the moment. |
nymeaserver::HttpReply::GatewayTimeout | 504 | The gateway timed out. |
nymeaserver::HttpReply::HttpVersionNotSupported | 505 | The HTTP version is not supported. The only supported version is HTTP/1.1. |
This enum type describes the type of this HttpReply. There are two types:
Construct an empty HttpReply with the given parent.
Construct a HttpReply with the given statusCode, type and parent.
Clears all data of this HttpReply.
Returns the clientId of this HttpReply.
See also setClientId().
Returns the connection close parameter of this HttpReply. If close is true, the connection of the client will be closed after this reply was sent.
See also setCloseConnection().
Returns the current raw data (header + payload) of this HttpReply.
[signal]
void HttpReply::finished()This signal is emitted when this async HttpReply is finished.
Returns the error code reason phrase for the current HttpStatusCode.
Returns the status code of this HttpReply.
See also setHttpStatusCode().
Returns true if the raw header and the payload of this HttpReply is empty.
Packs the whole reply data of this HttpReply. The data can be accessed with HttpReply::data().
See also data().
Returns the payload of this HttpReply.
See also setPayload().
Returns the raw headers of this HttpReply.
Note: The header will be empty until the method packReply() was called.
See also setRawHeader() and packReply().
Returns the list of all set headers in this HttpReply.
Set the clientId of this HttpReply.
See also clientId().
Sets the close parameter of this HttpReply. If close is true, the connection of the client will be closed after this reply was sent.
See also closeConnection().
This method appends a known header to the header list of this HttpReply. The Header will be set to headerType : value.
Set the HttpStatusCode of this HttpReply to the given statusCode.
See also httpStatusCode().
Set the payload of this HttpReply to the given data.
See also payload().
This method appends a raw header to the header list of this HttpReply. The Header will be set to headerType : value.
See also rawHeader().
[slot]
void HttpReply::startWait()Starts the timer for an async HttpReply.
See also finished().
Return true if the response took to long for the request.
Returns the type of this HttpReply.
See also Type.