5#ifndef CUTELYST_RESPONSE_H
6#define CUTELYST_RESPONSE_H
8#include <Cutelyst/cutelyst_global.h>
9#include <Cutelyst/headers.h>
11#include <QtCore/QIODevice>
17#if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
32 SwitchingProtocols = 101,
36 NonAuthoritativeInformation = 203,
41 MultipleChoices = 300,
42 MovedPermanently = 301,
47 TemporaryRedirect = 307,
48 PermanentRedirect = 308,
51 PaymentRequired = 402,
54 MethodNotAllowed = 405,
56 ProxyAuthenticationRequired = 407,
61 PreconditionFailed = 412,
62 RequestEntityTooLarge = 413,
63 RequestURITooLong = 414,
64 UnsupportedMediaType = 415,
65 RequestedRangeNotSatisfiable = 416,
66 ExpectationFailed = 417,
67 InternalServerError = 500,
70 ServiceUnavailable = 503,
72 HTTPVersionNotSupported = 505,
73 BandwidthLimitExceeded = 509
79 CloseCodeNormal = 1000,
80 CloseCodeGoingAway = 1001,
81 CloseCodeProtocolError = 1002,
82 CloseCodeDatatypeNotSupported = 1003,
83 CloseCodeReserved1004 = 1004,
84 CloseCodeMissingStatusCode = 1005,
85 CloseCodeAbnormalDisconnection = 1006,
86 CloseCodeWrongDatatype = 1007,
87 CloseCodePolicyViolated = 1008,
88 CloseCodeTooMuchData = 1009,
89 CloseCodeMissingExtension = 1010,
90 CloseCodeBadOperation = 1011,
91 CloseCodeTlsHandshakeFailed = 1015
100 quint16 status() const noexcept;
105 void setStatus(quint16 status) noexcept;
112 bool hasBody() const noexcept;
145 inline
void setBody(const
QString &body);
164 void setJsonBody(const
QString &json);
190 void setJsonArrayBody(const
QJsonArray &array);
195 QString contentEncoding() const;
200 void setContentEncoding(const
QString &encoding);
205 qint64 contentLength() const;
210 void setContentLength(qint64 length);
220 void setContentType(const
QString &type) { headers().setContentType(type); }
225 QString contentTypeCharset()
const;
233#if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
248#if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
263#if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
270 void setCuteCookie(
const Cookie &cookie);
279#if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
295#if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
302 int removeCuteCookies(
const QByteArray &name);
317 void redirect(
const QUrl &url, quint16 status = Found);
375 bool isFinalizedHeaders() const noexcept;
380 virtual
bool isSequential() const noexcept override;
385 virtual qint64 size() const noexcept override;
397 bool webSocketHandshake(const
QString &key = {},
443 virtual qint64 writeData(
const char *data, qint64 len)
override;
448 virtual qint64 readData(
char *data, qint64 maxlen)
override;
450 ResponsePrivate *d_ptr;
453 friend class EngineConnection;
455 friend class ContextPrivate;
The Cutelyst Application.
bool webSocketTextMessage(const QString &message)
Sends a WebSocket text message.
bool webSocketPing(const QByteArray &payload={})
Sends a WebSocket ping with an optional payload limited to 125 bytes, which will be truncated if larg...
void setBody(QIODevice *body)
void redirectSafe(const QUrl &url, const QUrl &fallback)
bool webSocketBinaryMessage(const QByteArray &message)
Sends a WebSocket binary message.
void redirect(const QString &url, quint16 status=Found)
void setJsonBody(const QJsonDocument &documment)
bool webSocketClose(quint16 code=Response::CloseCodeNormal, const QString &reason={})
Sends a WebSocket close frame, with both optional close code and a string reason.
QUrl location() const noexcept
The Cutelyst namespace holds all public Cutelyst API.
QByteArray toUtf8() const const
QByteArray toUtf8() const const