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 | #include <QtNetwork/qhttpheaders.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | class QJsonObject; |
13 | |
14 | class QHttpServerResponsePrivate; |
15 | class QHttpServerResponse final |
16 | { |
17 | Q_DECLARE_PRIVATE(QHttpServerResponse) |
18 | Q_DISABLE_COPY(QHttpServerResponse) |
19 | |
20 | friend class QHttpServerResponder; |
21 | public: |
22 | using StatusCode = QHttpServerResponder::StatusCode; |
23 | |
24 | QHttpServerResponse(QHttpServerResponse &&other) noexcept |
25 | : d_ptr(std::exchange(obj&: other.d_ptr, new_val: nullptr)) {} |
26 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QHttpServerResponse) |
27 | void swap(QHttpServerResponse &other) noexcept { qt_ptr_swap(lhs&: d_ptr, rhs&: other.d_ptr); } |
28 | |
29 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(StatusCode statusCode); |
30 | |
31 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const char *data, |
32 | StatusCode status = StatusCode::Ok); |
33 | |
34 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QString &data, |
35 | StatusCode status = StatusCode::Ok); |
36 | |
37 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QByteArray &data, |
38 | StatusCode status = StatusCode::Ok); |
39 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(QByteArray &&data, |
40 | StatusCode status = StatusCode::Ok); |
41 | |
42 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QJsonObject &data, |
43 | StatusCode status = StatusCode::Ok); |
44 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QJsonArray &data, |
45 | StatusCode status = StatusCode::Ok); |
46 | |
47 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QByteArray &mimeType, |
48 | const QByteArray &data, |
49 | StatusCode status = StatusCode::Ok); |
50 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QByteArray &mimeType, |
51 | QByteArray &&data, |
52 | StatusCode status = StatusCode::Ok); |
53 | |
54 | Q_HTTPSERVER_EXPORT ~QHttpServerResponse(); |
55 | Q_HTTPSERVER_EXPORT static QHttpServerResponse fromFile(const QString &fileName); |
56 | |
57 | Q_HTTPSERVER_EXPORT QByteArray data() const; |
58 | |
59 | Q_HTTPSERVER_EXPORT QByteArray mimeType() const; |
60 | |
61 | Q_HTTPSERVER_EXPORT StatusCode statusCode() const; |
62 | |
63 | Q_HTTPSERVER_EXPORT QHttpHeaders () const; |
64 | Q_HTTPSERVER_EXPORT void (const QHttpHeaders &); |
65 | Q_HTTPSERVER_EXPORT void (QHttpHeaders &&); |
66 | |
67 | private: |
68 | QHttpServerResponsePrivate *d_ptr; |
69 | }; |
70 | |
71 | QT_END_NAMESPACE |
72 | |
73 | #endif // QHTTPSERVERRESPONSE_H |
74 | |