| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QHTTPSERVERREQUEST_H |
| 5 | #define QHTTPSERVERREQUEST_H |
| 6 | |
| 7 | #include <QtHttpServer/qthttpserverglobal.h> |
| 8 | |
| 9 | #include <QtCore/qglobal.h> |
| 10 | #include <QtCore/qurl.h> |
| 11 | #include <QtCore/qurlquery.h> |
| 12 | #include <QtNetwork/qhostaddress.h> |
| 13 | #if QT_CONFIG(ssl) |
| 14 | #include <QtNetwork/qsslconfiguration.h> |
| 15 | #endif |
| 16 | |
| 17 | #include <memory> |
| 18 | |
| 19 | QT_BEGIN_NAMESPACE |
| 20 | |
| 21 | class QRegularExpression; |
| 22 | class QString; |
| 23 | class ; |
| 24 | |
| 25 | class QHttpServerRequestPrivate; |
| 26 | class QHttpServerRequest final |
| 27 | { |
| 28 | friend class QHttpServerResponse; |
| 29 | friend class QHttpServerStream; |
| 30 | friend class QHttpServerHttp1ProtocolHandler; |
| 31 | friend class QHttpServerHttp2ProtocolHandler; |
| 32 | |
| 33 | Q_GADGET_EXPORT(Q_HTTPSERVER_EXPORT) |
| 34 | |
| 35 | public: |
| 36 | Q_HTTPSERVER_EXPORT ~QHttpServerRequest(); |
| 37 | |
| 38 | enum class Method |
| 39 | { |
| 40 | Unknown = 0x0000, |
| 41 | Get = 0x0001, |
| 42 | Put = 0x0002, |
| 43 | Delete = 0x0004, |
| 44 | Post = 0x0008, |
| 45 | Head = 0x0010, |
| 46 | Options = 0x0020, |
| 47 | Patch = 0x0040, |
| 48 | Connect = 0x0080, |
| 49 | Trace = 0x0100, |
| 50 | |
| 51 | AnyKnown = Get | Put | Delete | Post | Head | Options | Patch | Connect | Trace, |
| 52 | }; |
| 53 | Q_ENUM(Method) |
| 54 | Q_DECLARE_FLAGS(Methods, Method) |
| 55 | Q_FLAG(Methods) |
| 56 | |
| 57 | Q_HTTPSERVER_EXPORT QByteArray value(const QByteArray &key) const; |
| 58 | Q_HTTPSERVER_EXPORT QUrl url() const; |
| 59 | Q_HTTPSERVER_EXPORT QUrlQuery query() const; |
| 60 | Q_HTTPSERVER_EXPORT Method method() const; |
| 61 | Q_HTTPSERVER_EXPORT const QHttpHeaders &() const &; |
| 62 | Q_HTTPSERVER_EXPORT QHttpHeaders () &&; |
| 63 | Q_HTTPSERVER_EXPORT QByteArray body() const; |
| 64 | Q_HTTPSERVER_EXPORT QHostAddress remoteAddress() const; |
| 65 | Q_HTTPSERVER_EXPORT quint16 remotePort() const; |
| 66 | Q_HTTPSERVER_EXPORT QHostAddress localAddress() const; |
| 67 | Q_HTTPSERVER_EXPORT quint16 localPort() const; |
| 68 | #if QT_CONFIG(ssl) |
| 69 | Q_HTTPSERVER_EXPORT QSslConfiguration sslConfiguration() const; |
| 70 | #endif |
| 71 | |
| 72 | private: |
| 73 | Q_DISABLE_COPY(QHttpServerRequest) |
| 74 | |
| 75 | #if !defined(QT_NO_DEBUG_STREAM) |
| 76 | friend Q_HTTPSERVER_EXPORT QDebug operator<<(QDebug debug, const QHttpServerRequest &request); |
| 77 | #endif |
| 78 | |
| 79 | Q_HTTPSERVER_EXPORT explicit QHttpServerRequest(const QHostAddress &remoteAddress, |
| 80 | quint16 remotePort, |
| 81 | const QHostAddress &localAddress, |
| 82 | quint16 localPort); |
| 83 | #if QT_CONFIG(ssl) |
| 84 | Q_HTTPSERVER_EXPORT explicit QHttpServerRequest(const QHostAddress &remoteAddress, |
| 85 | quint16 remotePort, |
| 86 | const QHostAddress &localAddress, |
| 87 | quint16 localPort, |
| 88 | const QSslConfiguration &sslConfiguration); |
| 89 | #endif |
| 90 | |
| 91 | std::unique_ptr<QHttpServerRequestPrivate> d; |
| 92 | }; |
| 93 | |
| 94 | Q_DECLARE_OPERATORS_FOR_FLAGS(QHttpServerRequest::Methods) |
| 95 | |
| 96 | QT_END_NAMESPACE |
| 97 | |
| 98 | #endif // QHTTPSERVERREQUEST_H |
| 99 | |