• HttpRequest
  • HttpRequest Class

    (nymeaserver::HttpRequest)

    Represents a HTTP request from a client to the nymea WebServer. More...

    Header: #include <HttpRequest>

    Public Types

    enum RequestMethod { Get, Post, Put, Delete, Options, Unhandled }

    Public Functions

    HttpRequest()
    HttpRequest(QByteArray rawData)
    void appendData(const QByteArray & data)
    bool hasPayload() const
    QByteArray httpVersion() const
    bool isComplete() const
    bool isValid() const
    RequestMethod method() const
    QString methodString() const
    QByteArray payload() const
    QByteArray rawHeader() const
    QHash<QByteArray, QByteArray> rawHeaderList() const
    QUrl url() const
    QUrlQuery urlQuery() const

    Detailed Description

    Represents a HTTP request from a client to the nymea WebServer.

    This class holds the header and the payload data of a network request from a client to the WebServer.

    Note: RFC 7231 HTTP/1.1 Semantics and Content -> http://tools.ietf.org/html/rfc7231

    Member Type Documentation

    enum HttpRequest::RequestMethod

    This enum type describes the method of a HttpRequest. Following methods are allowed/handled:

    ConstantValueDescription
    nymeaserver::HttpRequest::Get0Represents the HTTP/1.1 GET method.
    nymeaserver::HttpRequest::Post1Represents the HTTP/1.1 POST method.
    nymeaserver::HttpRequest::Put2Represents the HTTP/1.1 PUT method.
    nymeaserver::HttpRequest::Delete3Represents the HTTP/1.1 DELETE method.
    nymeaserver::HttpRequest::Options4Represents the HTTP/1.1 OPTIONS method.
    nymeaserver::HttpRequest::Unhandled5Represents every other method which is not handled.

    Member Function Documentation

    HttpRequest::HttpRequest()

    Construct an empty HttpRequest.

    HttpRequest::HttpRequest(QByteArray rawData)

    Construct a HttpRequest with the given rawData. The rawData will be parsed in this constructor. You can check if the data is valid with isValid(). You can check if the request is complete with isComplete.

    See also isValid() and isComplete().

    void HttpRequest::appendData(const QByteArray & data)

    Appends the given data to the current raw data of this HttpRequest. * This method will be used if a HttpRequest is not complete yet. * *

    See also isComplete().

    bool HttpRequest::hasPayload() const

    Returns true if this HttpRequest has a payload.

    QByteArray HttpRequest::httpVersion() const

    Returns the HTTP version of this HttpRequest.

    bool HttpRequest::isComplete() const

    Returns true if this HttpRequest is complete. A HTTP request is complete if "Content-Length" header value matches the actual payload size. Bigger packages will be sent in multiple TCP packages.

    bool HttpRequest::isValid() const

    Returns true if this HttpRequest is valid. A HTTP request is valid if the header and the payload were paresed successfully without errors.

    RequestMethod HttpRequest::method() const

    Returns the RequestMethod of this request.

    See also RequestMethod.

    QString HttpRequest::methodString() const

    Returns the method as human readable string.

    QByteArray HttpRequest::payload() const

    Returns the payload (content) of this HttpRequest.

    QByteArray HttpRequest::rawHeader() const

    Returns the raw header of this request.

    QHash<QByteArray, QByteArray> HttpRequest::rawHeaderList() const

    Returns the list of raw header as key and value pairs.

    QUrl HttpRequest::url() const

    Returns the URL of this HttpRequest.

    QUrlQuery HttpRequest::urlQuery() const

    Returns the URL query of this HttpRequest.