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
14#include <memory>
15
16QT_BEGIN_NAMESPACE
17
18class QRegularExpression;
19class QString;
20
21class QHttpServerRequestPrivate;
22class QHttpServerRequest final
23{
24 friend class QHttpServerResponse;
25 friend class QHttpServerStream;
26
27 Q_GADGET_EXPORT(Q_HTTPSERVER_EXPORT)
28
29public:
30 Q_HTTPSERVER_EXPORT ~QHttpServerRequest();
31
32 enum class Method
33 {
34 Unknown = 0x0000,
35 Get = 0x0001,
36 Put = 0x0002,
37 Delete = 0x0004,
38 Post = 0x0008,
39 Head = 0x0010,
40 Options = 0x0020,
41 Patch = 0x0040,
42 Connect = 0x0080,
43 Trace = 0x0100,
44
45 AnyKnown = Get | Put | Delete | Post | Head | Options | Patch | Connect | Trace,
46 };
47 Q_ENUM(Method)
48 Q_DECLARE_FLAGS(Methods, Method)
49 Q_FLAG(Methods)
50
51 Q_HTTPSERVER_EXPORT QByteArray value(const QByteArray &key) const;
52 Q_HTTPSERVER_EXPORT QUrl url() const;
53 Q_HTTPSERVER_EXPORT QUrlQuery query() const;
54 Q_HTTPSERVER_EXPORT Method method() const;
55 Q_HTTPSERVER_EXPORT QList<QPair<QByteArray, QByteArray>> headers() const;
56 Q_HTTPSERVER_EXPORT QByteArray body() const;
57 Q_HTTPSERVER_EXPORT QHostAddress remoteAddress() const;
58 Q_HTTPSERVER_EXPORT quint16 remotePort() const;
59 Q_HTTPSERVER_EXPORT QHostAddress localAddress() const;
60 Q_HTTPSERVER_EXPORT quint16 localPort() const;
61
62private:
63 Q_DISABLE_COPY(QHttpServerRequest)
64
65#if !defined(QT_NO_DEBUG_STREAM)
66 friend Q_HTTPSERVER_EXPORT QDebug operator<<(QDebug debug, const QHttpServerRequest &request);
67#endif
68
69 Q_HTTPSERVER_EXPORT explicit QHttpServerRequest(const QHostAddress &remoteAddress,
70 quint16 remotePort,
71 const QHostAddress &localAddress,
72 quint16 localPort);
73
74 std::unique_ptr<QHttpServerRequestPrivate> d;
75};
76
77Q_DECLARE_OPERATORS_FOR_FLAGS(QHttpServerRequest::Methods)
78
79QT_END_NAMESPACE
80
81#endif // QHTTPSERVERREQUEST_H
82

source code of qthttpserver/src/httpserver/qhttpserverrequest.h