1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QHTTPSERVERRESPONSE_H |
5 | #define QHTTPSERVERRESPONSE_H |
6 | |
7 | #include <QtHttpServer/qhttpserverresponder.h> |
8 | |
9 | #include <memory> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | class QJsonObject; |
14 | |
15 | class QHttpServerResponsePrivate; |
16 | class Q_HTTPSERVER_EXPORT QHttpServerResponse final |
17 | { |
18 | Q_DECLARE_PRIVATE(QHttpServerResponse) |
19 | Q_DISABLE_COPY(QHttpServerResponse) |
20 | |
21 | friend class QHttpServerResponder; |
22 | public: |
23 | using StatusCode = QHttpServerResponder::StatusCode; |
24 | |
25 | QHttpServerResponse(QHttpServerResponse &&other) noexcept; |
26 | QHttpServerResponse& operator=(QHttpServerResponse &&other) noexcept; |
27 | |
28 | QHttpServerResponse(const StatusCode statusCode); |
29 | |
30 | QHttpServerResponse(const char *data, const StatusCode status = StatusCode::Ok); |
31 | |
32 | QHttpServerResponse(const QString &data, const StatusCode status = StatusCode::Ok); |
33 | |
34 | explicit QHttpServerResponse(const QByteArray &data, const StatusCode status = StatusCode::Ok); |
35 | explicit QHttpServerResponse(QByteArray &&data, const StatusCode status = StatusCode::Ok); |
36 | |
37 | QHttpServerResponse(const QJsonObject &data, const StatusCode status = StatusCode::Ok); |
38 | QHttpServerResponse(const QJsonArray &data, const StatusCode status = StatusCode::Ok); |
39 | |
40 | QHttpServerResponse(const QByteArray &mimeType, |
41 | const QByteArray &data, |
42 | const StatusCode status = StatusCode::Ok); |
43 | QHttpServerResponse(QByteArray &&mimeType, |
44 | const QByteArray &data, |
45 | const StatusCode status = StatusCode::Ok); |
46 | QHttpServerResponse(const QByteArray &mimeType, |
47 | QByteArray &&data, |
48 | const StatusCode status = StatusCode::Ok); |
49 | QHttpServerResponse(QByteArray &&mimeType, |
50 | QByteArray &&data, |
51 | const StatusCode status = StatusCode::Ok); |
52 | |
53 | ~QHttpServerResponse(); |
54 | static QHttpServerResponse fromFile(const QString &fileName); |
55 | |
56 | QByteArray data() const; |
57 | |
58 | QByteArray mimeType() const; |
59 | |
60 | StatusCode statusCode() const; |
61 | |
62 | void (QByteArray &&name, QByteArray &&value); |
63 | void (QByteArray &&name, const QByteArray &value); |
64 | void (const QByteArray &name, QByteArray &&value); |
65 | void (const QByteArray &name, const QByteArray &value); |
66 | |
67 | void (QHttpServerResponder::HeaderList ); |
68 | |
69 | template<typename Container> |
70 | void (const Container &) |
71 | { |
72 | for (const auto & : headerList) |
73 | addHeader(header.first, header.second); |
74 | } |
75 | |
76 | void (const QByteArray &name); |
77 | void (); |
78 | |
79 | void (QByteArray &&name, QByteArray &&value); |
80 | void (QByteArray &&name, const QByteArray &value); |
81 | void (const QByteArray &name, QByteArray &&value); |
82 | void (const QByteArray &name, const QByteArray &value); |
83 | |
84 | void (QHttpServerResponder::HeaderList ); |
85 | |
86 | bool (const QByteArray &name) const; |
87 | bool (const QByteArray &name, const QByteArray &value) const; |
88 | |
89 | QList<QByteArray> (const QByteArray &name) const; |
90 | |
91 | private: |
92 | std::unique_ptr<QHttpServerResponsePrivate> d_ptr; |
93 | }; |
94 | |
95 | QT_END_NAMESPACE |
96 | |
97 | #endif // QHTTPSERVERRESPONSE_H |
98 | |