Cute   Learning Hub


  • HttpResponse
  • HttpResponse Class

    class Cute::Server::HttpResponse

    The Cute::Server::HttpResponse class represents the HTTP response that HTTP handlers send to clients. More...

    Header: #include <HttpResponse>

    Public Functions

    HttpResponse(const Cute::Server::HttpResponse &other)
    HttpResponse(int httpStatusCode, const QByteArray &description = QByteArray(), const QByteArray &body = QByteArray(), int majorHttpVersion = 1, int minorHttpVersion = 1)
    HttpResponse(Cute::Server::HttpStatusCode httpStatusCode, const QByteArray &body = QByteArray(), int majorHttpVersion = 1, int minorHttpVersion = 1)
    HttpResponse()
    Cute::Server::HttpResponse &operator=(const Cute::Server::HttpResponse &other)
    ~HttpResponse()
    void addHeader(const QByteArray &name, const QByteArray &value)
    const QByteArray &body() const
    void clear()
    const QByteArray &description() const
    QByteArray header(const QByteArray &name) const
    int headerCount(const QByteArray &name) const
    QVector<QByteArray> headers(const QByteArray &name) const
    int headersCount() const
    int majorHttpVersion() const
    int minorHttpVersion() const
    void setBody(const QByteArray &body)
    void setHttpVersion(int majorVersion, int minorVersion)
    void setStatusCode(Cute::Server::HttpStatusCode statusCode)
    int statusCode() const
    void write(QByteArray &buffer) const
    bool operator!=(const Cute::Server::HttpResponse &other) const
    bool operator==(const Cute::Server::HttpResponse &other) const

    Detailed Description

    The Cute::Server::HttpResponse class represents the HTTP response that HTTP handlers send to clients.

    Member Function Documentation

    HttpResponse::HttpResponse(const Cute::Server::HttpResponse &other)

    Constructs a copy of other.

    HttpResponse::HttpResponse(int httpStatusCode, const QByteArray &description = QByteArray(), const QByteArray &body = QByteArray(), int majorHttpVersion = 1, int minorHttpVersion = 1)

    Constructs a HTTP response with httpStatusCode status code, having description with body as message body, and with HTTP version majorHttpVersion.minorHttpVersion. Note that the Cute Server HTTP request parser supports HTTP version 1.1.

    HttpResponse::HttpResponse(Cute::Server::HttpStatusCode httpStatusCode, const QByteArray &body = QByteArray(), int majorHttpVersion = 1, int minorHttpVersion = 1)

    Constructs a HTTP response with httpStatusCode status code, having body as message body, and with HTTP version majorHttpVersion.minorHttpVersion. Note that the Cute Server HTTP request parser supports HTTP version 1.1.

    HttpResponse::HttpResponse()

    Constructs an empty HTTP response. An empty HTTP response has 0 as status code, empty description and body, no headers and major and minor HTTP versions set to 0.

    Cute::Server::HttpResponse &HttpResponse::operator=(const Cute::Server::HttpResponse &other)

    Assigns other to this HTTP response and returns a reference to this HTTP response.

    HttpResponse::~HttpResponse()

    Destroys the HTTP response.

    void HttpResponse::addHeader(const QByteArray &name, const QByteArray &value)

    Adds the HTTP response header name: value to this HTTP response.

    const QByteArray &HttpResponse::body() const

    Returns the body of this HTTP response message.

    See also setBody().

    void HttpResponse::clear()

    Clears this HTTP response. This method has the same effect as assigning this HTTP response to a default-constructed HTTP response.

    const QByteArray &HttpResponse::description() const

    Returns the description for this HTTP response status code.

    Returns the value of the header with name. If this HTTP response does not contain a header with name, an empty QByteArray is returned. If this response has many headers with same name, the value returned will be from one of the headers.

    See also headerCount and headers.

    int HttpResponse::headerCount(const QByteArray &name) const

    Returns the number of headers in this HTTP response with name as header name.

    QVector<QByteArray> HttpResponse::headers(const QByteArray &name) const

    Returns all values of headers named name in this HTTP response. If this HTTP response does not contain a header named name, the returned vector is empty. Otherwise it contains the values from all headers named name.

    See also header and headerCount.

    int HttpResponse::headersCount() const

    Returns the number of headers in this HTTP response.

    int HttpResponse::majorHttpVersion() const

    Returns the major HTTP version of this HTTP response.

    int HttpResponse::minorHttpVersion() const

    Returns the minor HTTP version of this HTTP response.

    void HttpResponse::setBody(const QByteArray &body)

    Sets this HTTP response message body to body. Note that this method does not set the content-length header, that must be sent by addHeader.

    See also body().

    void HttpResponse::setHttpVersion(int majorVersion, int minorVersion)

    Sets HTTP version of this response to majorVersion.minorVersion.

    void HttpResponse::setStatusCode(Cute::Server::HttpStatusCode statusCode)

    Sets the HTTP response status code of this response to statusCode.

    See also statusCode().

    int HttpResponse::statusCode() const

    Returns the HTTP status code of this response.

    See also setStatusCode().

    void HttpResponse::write(QByteArray &buffer) const

    Writes the content of this HTTP response to buffer.

    bool HttpResponse::operator!=(const Cute::Server::HttpResponse &other) const

    Returns true if this HTTP response is not equal to other; otherwise returns false.

    bool HttpResponse::operator==(const Cute::Server::HttpResponse &other) const

    Returns true if this HTTP response is equal to other; otherwise returns false.