5 #ifndef CUTELYST_RESPONSE_H
6 #define CUTELYST_RESPONSE_H
8 #include <QtCore/QIODevice>
10 #include <Cutelyst/cutelyst_global.h>
11 #include <Cutelyst/headers.h>
17 #if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
23 class ResponsePrivate;
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);
221 { headers().setContentType(type); }
226 QString contentTypeCharset()
const;
234 #if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
249 #if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
264 #if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
271 void setCuteCookie(
const Cookie &cookie);
280 #if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
296 #if (QT_VERSION < QT_VERSION_CHECK(6, 1, 0))
303 int removeCuteCookies(
const QByteArray &name);
318 void redirect(
const QUrl &url, quint16 status = Found);
376 bool isFinalizedHeaders() const noexcept;
381 virtual
bool isSequential() const noexcept override;
386 virtual qint64 size() const noexcept override;
442 virtual qint64 writeData(
const char *data, qint64 len)
override;
447 virtual qint64 readData(
char *data, qint64 maxlen)
override;
449 ResponsePrivate *d_ptr;
452 friend class EngineConnection;
454 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