SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
httprequest.h
Go to the documentation of this file.
1 
6 #ifndef HTTPREQUEST_H
7 #define HTTPREQUEST_H
8 
9 #include <QByteArray>
10 #include <QHostAddress>
11 #include <QTcpSocket>
12 #include <QMap>
13 #include <QMultiMap>
14 #include <QSettings>
15 #include <QTemporaryFile>
16 #include <QUuid>
17 #include "httpglobal.h"
18 #include "httplistenersettings.h"
19 
20 #include "export.h"
21 
22 namespace qtwebapp {
23 
42  Q_DISABLE_COPY(HttpRequest)
43  friend class HttpSessionStore;
44 
45 public:
46 
48  enum RequestStatus {waitForRequest, waitForHeader, waitForBody, complete, abort};
49 
54  HttpRequest(QSettings* settings);
55 
60  HttpRequest(const HttpListenerSettings* settings);
61 
65  virtual ~HttpRequest();
66 
73  void readFromSocket(QTcpSocket* socket);
74 
79  RequestStatus getStatus() const;
80 
82  QByteArray getMethod() const;
83 
85  QByteArray getPath() const;
86 
88  const QByteArray& getRawPath() const;
89 
91  QByteArray getVersion() const;
92 
99  QByteArray getHeader(const QByteArray& name) const;
100 
105  QList<QByteArray> getHeaders(const QByteArray& name) const;
106 
111  QMultiMap<QByteArray,QByteArray> getHeaderMap() const;
112 
119  QByteArray getParameter(const QByteArray& name) const;
120 
125  QList<QByteArray> getParameters(const QByteArray& name) const;
126 
128  QMultiMap<QByteArray,QByteArray> getParameterMap() const;
129 
131  QByteArray getBody() const;
132 
139  static QByteArray urlDecode(const QByteArray source);
140 
149  QTemporaryFile* getUploadedFile(const QByteArray fieldName) const;
150 
155  QByteArray getCookie(const QByteArray& name) const;
156 
158  QMap<QByteArray,QByteArray>& getCookieMap();
159 
165  QHostAddress getPeerAddress() const;
166 
167 private:
168 
170  QMultiMap<QByteArray,QByteArray> headers;
171 
173  QMultiMap<QByteArray,QByteArray> parameters;
174 
176  QMap<QByteArray,QTemporaryFile*> uploadedFiles;
177 
179  QMap<QByteArray,QByteArray> cookies;
180 
182  QByteArray bodyData;
183 
185  QByteArray method;
186 
188  QByteArray path;
189 
191  QByteArray version;
192 
198 
200  QHostAddress peerAddress;
201 
203  int maxSize;
204 
207 
210 
213 
215  QByteArray currentHeader;
216 
218  QByteArray boundary;
219 
221  QTemporaryFile* tempFile;
222 
224  void parseMultiPartFile();
225 
227  void readRequest(QTcpSocket* socket);
228 
230  void readHeader(QTcpSocket* socket);
231 
233  void readBody(QTcpSocket* socket);
234 
236  void decodeRequestParams();
237 
239  void extractCookies();
240 
242  QByteArray lineBuffer;
243 
246 };
247 
248 } // end of namespace
249 
250 #endif // HTTPREQUEST_H
QTemporaryFile * tempFile
Definition: httprequest.h:221
QMultiMap< QByteArray, QByteArray > parameters
Definition: httprequest.h:173
#define HTTPSERVER_API
Definition: export.h:88
RequestStatus status
Definition: httprequest.h:197
QMultiMap< QByteArray, QByteArray > headers
Definition: httprequest.h:170
QHostAddress peerAddress
Definition: httprequest.h:200
QMap< QByteArray, QByteArray > cookies
Definition: httprequest.h:179
QMap< QByteArray, QTemporaryFile * > uploadedFiles
Definition: httprequest.h:176
QByteArray currentHeader
Definition: httprequest.h:215