tufao  1.3.0
An asynchronous web framework for C++ built on top of Qt
httpserverrequest.h
1 /*
2  Copyright (c) 2012, 2013 Vinícius dos Santos Oliveira
3 
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10 
11  The above copyright notice and this permission notice shall be included in all
12  copies or substantial portions of the Software.
13 
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  SOFTWARE.
21  */
22 
23 #ifndef TUFAO_HTTPSERVERREQUEST_H
24 #define TUFAO_HTTPSERVERREQUEST_H
25 
26 #include "httpserverresponse.h"
27 
28 class QAbstractSocket;
29 class QUrl;
30 
31 namespace Tufao {
32 
33 struct Headers;
34 
35 enum class HttpVersion
36 {
37  HTTP_1_0,
38  HTTP_1_1
39 };
40 
54 class TUFAO_EXPORT HttpServerRequest : public QObject
55 {
56  Q_OBJECT
57 public:
58 
70  explicit HttpServerRequest(QAbstractSocket &socket, QObject *parent = 0);
71 
76 
108  QByteArray method() const;
109 
119  void setUrl(const QUrl &url);
120 
137  QUrl url() const;
138 
146  Headers headers() const;
147 
158  Headers &headers();
159 
169  Headers trailers() const;
170 
174  HttpVersion httpVersion() const;
175 
196  QByteArray readBody();
197 
207  QAbstractSocket &socket() const;
208 
221  void setTimeout(int msecs = 0);
222 
226  int timeout() const;
227 
234  Tufao::HttpServerResponse::Options responseOptions() const;
235 
247  QVariant customData() const;
248 
262  void setCustomData(const QVariant &data);
263 
264 signals:
290  void ready();
291 
303  void data();
304 
314  void end();
315 
323  void close();
324 
339  void upgrade();
340 
341 private slots:
342  void onReadyRead();
343  void onTimeout();
344 
345 private:
346  void clearBuffer();
347  void clearRequest();
348 
349  struct Priv;
350  Priv *priv;
351 
352  friend struct Tufao::HttpServerRequest::Priv;
353 };
354 
355 } // namespace Tufao
356 
357 #endif // TUFAO_HTTPSERVERREQUEST_H
The Tufao::HttpServer represents a HTTP request received by Tufao::HttpServer.
Definition: httpserverrequest.h:54
This is the namespace where all Tufão facilities are grouped.
Definition: abstracthttpserverrequesthandler.h:30
This class provides a representation of HTTP headers.
Definition: headers.h:42