TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
qhttprequest.h
Go to the documentation of this file.
1 #ifndef QHTTPREQUEST_H
2 #define QHTTPREQUEST_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Music Player project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QUrl>
23 #include <QMetaEnum>
24 #include <QMetaType>
25 #include "qhttpserverfwd.h"
26 
28 
32 class TTK_MODULE_EXPORT QHttpRequest : public QObject
33 {
34  Q_OBJECT
35  Q_PROPERTY(HeaderHash headers READ headers)
36  Q_PROPERTY(QString remoteAddress READ remoteAddress)
37  Q_PROPERTY(quint16 remotePort READ remotePort)
38  Q_PROPERTY(QString method READ method)
39  Q_PROPERTY(QUrl url READ url)
40  Q_PROPERTY(QString path READ path)
41  Q_PROPERTY(QString httpVersion READ httpVersion)
42 
43  Q_ENUMS(HttpMethod)
44 
46  friend class QHttpConnection;
47  friend class QHttpConnectionPrivate;
49 
50 public:
52 
53  enum HttpMethod {
54  HTTP_DELETE = 0,
59  // pathological
63  // webdav
72  // subversion
77  // upnp
82  // RFC-5789
84  HTTP_PURGE
85  };
86 
88  HttpMethod method() const;
89 
91 
92  const QString methodString() const;
93 
95 
97  const QUrl &url() const;
98 
100 
101  const QString path() const;
102 
104 
105  const QString &httpVersion() const;
106 
108 
113  const HeaderHash &headers() const;
114 
116 
119  QString header(const QString &field);
120 
122  const QString &remoteAddress() const;
123 
125  quint16 remotePort() const;
126 
128 
129  const QByteArray &body() const;
130 
132 
135  bool successful() const;
136 
138 
146  void storeBody();
147 
148 Q_SIGNALS:
150 
153  void data(const QByteArray &data);
154 
156 
157  void end();
158 
159 private Q_SLOTS:
160  void appendBody(const QByteArray &body);
161 
162 private:
163  explicit QHttpRequest(QHttpConnection *connection, QObject *parent = nullptr);
164 
165  static QString MethodToString(HttpMethod method);
166  void setMethod(HttpMethod method);
167  void setVersion(const QString &version);
168  void setUrl(const QUrl &url);
169  void setHeaders(const HeaderHash headers);
170  void setSuccessful(bool success);
171  void setRemoteAddress(const QString &address);
172  void setRemotePort(quint16 port);
173 
174 private:
176 
177 };
178 
179 #endif
HttpMethod
Request method enumeration.
Definition: qhttprequest.h:53
#define TTK_MODULE_EXPORT
The class of the http connection.
The class of the http connection private.
The class of the http request.
Definition: qhttprequest.h:32
#define TTK_DECLARE_PRIVATE(Class)
Definition: ttkprivate.h:26
QHash< QString, QString > HeaderHash
The class of the http request private.
Definition: qhttprequest.cpp:7