13 #include <QTextStream> 14 #include <QJsonDocument> 15 #include <QNetworkCookie> 16 #include "constants.h" 17 #include "cppwebframework_global.h" 29 int statusCode = Response::SC_OK;
31 QByteArray statusText = HTTP::OK;
32 QMap<QByteArray, QByteArray> headers;
33 QVector<QNetworkCookie> cookies;
39 void write(
const QJsonObject &json,
bool writeContentType =
true);
41 void write(
const QJsonArray &array,
bool writeContentType =
true);
43 void write(QByteArray &&data);
45 void write(
const QByteArray &data,
bool flush =
true);
47 void sendError(
int sc,
const QByteArray &msg);
51 inline int getBufferSize()
const noexcept {
return content.size(); }
53 inline void addHeader(
const QByteArray &name,
const QByteArray &value) noexcept { headers.insert(name, value); }
55 inline void addCookie(
const QNetworkCookie &cookie) noexcept { cookies.push_back(cookie); }
57 void setStatus(
int statusCode,
const QByteArray &description);
59 void sendRedirect(
const QByteArray &url);
61 static const int SC_CONTINUE;
63 static const int SC_SWITCHING_PROTOCOLS;
65 static const int SC_OK;
67 static const int SC_CREATED;
69 static const int SC_ACCEPTED;
71 static const int SC_NON_AUTHORITATIVE_INFORMATION;
73 static const int SC_NO_CONTENT;
75 static const int SC_RESET_CONTENT;
77 static const int SC_PARTIAL_CONTENT;
79 static const int SC_MULTIPLE_CHOICES;
81 static const int SC_MOVED_PERMANENTLY;
83 static const int SC_MOVED_TEMPORARILY;
85 static const int SC_FOUND;
87 static const int SC_SEE_OTHER;
89 static const int SC_NOT_MODIFIED;
91 static const int SC_USE_PROXY;
93 static const int SC_TEMPORARY_REDIRECT;
95 static const int SC_BAD_REQUEST;
97 static const int SC_UNAUTHORIZED;
99 static const int SC_PAYMENT_REQUIRED;
101 static const int SC_FORBIDDEN;
103 static const int SC_NOT_FOUND;
105 static const int SC_METHOD_NOT_ALLOWED;
107 static const int SC_NOT_ACCEPTABLE;
109 static const int SC_PROXY_AUTHENTICATION_REQUIRED;
111 static const int SC_REQUEST_TIMEOUT;
113 static const int SC_CONFLICT;
115 static const int SC_GONE;
117 static const int SC_LENGTH_REQUIRED;
119 static const int SC_PRECONDITION_FAILED;
121 static const int SC_REQUEST_ENTITY_TOO_LARGE;
123 static const int SC_REQUEST_URI_TOO_LONG;
125 static const int SC_UNSUPPORTED_MEDIA_TYPE;
127 static const int SC_REQUESTED_RANGE_NOT_SATISFIABLE;
129 static const int SC_EXPECTATION_FAILED;
131 static const int SC_INTERNAL_SERVER_ERROR;
133 static const int SC_NOT_IMPLEMENTED;
135 static const int SC_BAD_GATEWAY;
137 static const int SC_SERVICE_UNAVAILABLE;
139 static const int SC_GATEWAY_TIMEOUT;
141 static const int SC_HTTP_VERSION_NOT_SUPPORTED;
All classes of C++ Web Framework are contained within the namespace CWF.
Definition: configuration.h:24
The Response class is responsable to response a Http request.
Definition: response.h:25