tufao  0.8.1
An asynchronous web framework for C++ built on top of Qt
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
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 
30 namespace Tufao {
31 
32 struct Headers;
33 
47 class TUFAO_EXPORT HttpServerRequest : public QObject
48 {
49  Q_OBJECT
50 public:
51  enum HttpVersion
52  {
53  HTTP_1_0,
54  HTTP_1_1
55  };
56 
65  explicit HttpServerRequest(QAbstractSocket *socket, QObject *parent = 0);
66 
71 
103  QByteArray method() const;
104 
114  void setUrl(const QByteArray &url);
115 
131  QByteArray url() const;
132 
140  Headers headers() const;
141 
152  Headers &headers();
153 
158  Headers trailers() const;
159 
163  HttpVersion httpVersion() const;
164 
171  QAbstractSocket *socket() const;
172 
185  void setTimeout(int msecs = 0);
186 
190  int timeout() const;
191 
198  Tufao::HttpServerResponse::Options responseOptions() const;
199 
200 signals:
208  void ready(Tufao::HttpServerResponse::Options);
209 
227  void ready();
228 
235  void data(QByteArray data);
236 
243  void end();
244 
252  void close();
253 
264  void upgrade(QByteArray head);
265 
266 private slots:
267  void onReadyRead();
268  void onTimeout();
269 
270 private:
271  void clearBuffer();
272  void clearRequest();
273 
274  struct Priv;
275  Priv *priv;
276 
277  friend struct Tufao::HttpServerRequest::Priv;
278 };
279 
280 } // namespace Tufao
281 
282 #endif // TUFAO_HTTPSERVERREQUEST_H
The Tufao::HttpServer represents a HTTP request received by Tufao::HttpServer.
Definition: httpserverrequest.h:47
This class provides a representation of HTTP headers.
Definition: headers.h:42