| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | // Qt-Security score:significant reason:default |
| 4 | |
| 5 | #ifndef QHTTPSERVERRESPONSE_H |
| 6 | #define QHTTPSERVERRESPONSE_H |
| 7 | |
| 8 | #include <QtHttpServer/qhttpserverresponder.h> |
| 9 | #include <QtNetwork/qhttpheaders.h> |
| 10 | |
| 11 | QT_BEGIN_NAMESPACE |
| 12 | |
| 13 | class QJsonObject; |
| 14 | |
| 15 | class QHttpServerResponsePrivate; |
| 16 | class 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 | : d_ptr(std::exchange(obj&: other.d_ptr, new_val: nullptr)) {} |
| 27 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QHttpServerResponse) |
| 28 | void swap(QHttpServerResponse &other) noexcept { qt_ptr_swap(lhs&: d_ptr, rhs&: other.d_ptr); } |
| 29 | |
| 30 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(StatusCode statusCode); |
| 31 | |
| 32 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const char *data, |
| 33 | StatusCode status = StatusCode::Ok); |
| 34 | |
| 35 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QString &data, |
| 36 | StatusCode status = StatusCode::Ok); |
| 37 | |
| 38 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QByteArray &data, |
| 39 | StatusCode status = StatusCode::Ok); |
| 40 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(QByteArray &&data, |
| 41 | StatusCode status = StatusCode::Ok); |
| 42 | |
| 43 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QJsonObject &data, |
| 44 | StatusCode status = StatusCode::Ok); |
| 45 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QJsonArray &data, |
| 46 | StatusCode status = StatusCode::Ok); |
| 47 | |
| 48 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QByteArray &mimeType, |
| 49 | const QByteArray &data, |
| 50 | StatusCode status = StatusCode::Ok); |
| 51 | Q_HTTPSERVER_EXPORT Q_IMPLICIT QHttpServerResponse(const QByteArray &mimeType, |
| 52 | QByteArray &&data, |
| 53 | StatusCode status = StatusCode::Ok); |
| 54 | |
| 55 | Q_HTTPSERVER_EXPORT ~QHttpServerResponse(); |
| 56 | Q_HTTPSERVER_EXPORT static QHttpServerResponse fromFile(const QString &fileName); |
| 57 | |
| 58 | Q_HTTPSERVER_EXPORT QByteArray data() const; |
| 59 | |
| 60 | Q_HTTPSERVER_EXPORT QByteArray mimeType() const; |
| 61 | |
| 62 | Q_HTTPSERVER_EXPORT StatusCode statusCode() const; |
| 63 | |
| 64 | Q_HTTPSERVER_EXPORT QHttpHeaders () const; |
| 65 | Q_HTTPSERVER_EXPORT void (const QHttpHeaders &); |
| 66 | Q_HTTPSERVER_EXPORT void (QHttpHeaders &&); |
| 67 | |
| 68 | private: |
| 69 | QHttpServerResponsePrivate *d_ptr; |
| 70 | }; |
| 71 | |
| 72 | QT_END_NAMESPACE |
| 73 | |
| 74 | #endif // QHTTPSERVERRESPONSE_H |
| 75 | |