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)) 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);
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);
331 void redirect(
const QString &url, quint16 status = Found);
350 void redirectSafe(
const QUrl &url,
const QUrl &fallback);
355 QUrl location() const noexcept;
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 = {},
404 bool webSocketTextMessage(
const QString &message);
409 bool webSocketBinaryMessage(
const QByteArray &message);
419 bool webSocketPing(
const QByteArray &payload = {});
428 bool webSocketClose(quint16 code = Response::CloseCodeNormal,
const QString &reason = {});
434 explicit Response(
const Headers &defaultHeaders, EngineRequest *conn =
nullptr);
443 virtual qint64 writeData(
const char *data, qint64 len)
override;
448 virtual qint64 readData(
char *data, qint64 maxlen)
override;
450 ResponsePrivate *d_ptr;
451 friend class Application;
453 friend class EngineConnection;
454 friend class Context;
455 friend class ContextPrivate;
475 #endif // CUTELYST_RESPONSE_H
void setJsonBody(const QJsonDocument &documment)
The Cutelyst namespace holds all public Cutelyst API.
QByteArray toUtf8() const const
void setBody(QIODevice *body)
QByteArray toUtf8() const const