Stellarium  0.90.0
httpconnectionhandler.h
Go to the documentation of this file.
1 
6 #ifndef HTTPCONNECTIONHANDLER_H
7 #define HTTPCONNECTIONHANDLER_H
8 
9 #ifndef QT_NO_OPENSSL
10  #include <QSslConfiguration>
11 #endif
12 #include <QTcpSocket>
13 #include <QTimer>
14 #include <QThread>
15 #include "httpglobal.h"
16 #include "httprequest.h"
17 #include "httprequesthandler.h"
18 
23 #if QT_VERSION >= 0x050000
24  typedef qintptr tSocketDescriptor;
25 #else
26  typedef int tSocketDescriptor;
27 #endif
28 
33 #ifdef QT_NO_OPENSSL
34 typedef QObject HttpSslConfiguration;
35 #else
36 typedef QSslConfiguration HttpSslConfiguration;
37 #endif
38 
45  : readTimeout(10000),maxRequestSize(16384),maxMultipartSize(1048576)
46  {}
47 
54 };
55 
56 
73 class DECLSPEC HttpConnectionHandler : public QThread {
74  Q_OBJECT
75  Q_DISABLE_COPY(HttpConnectionHandler)
76 
77 public:
78 
85  HttpConnectionHandler(const HttpConnectionHandlerSettings& settings, HttpRequestHandler* requestHandler, HttpSslConfiguration* sslConfiguration=Q_NULLPTR);
86 
88  virtual ~HttpConnectionHandler();
89 
91  bool isBusy();
92 
94  void setBusy();
95 
96 private:
97 
100 
102  QTcpSocket* socket;
103 
105  QTimer readTimer;
106 
108  HttpRequest* currentRequest;
109 
111  HttpRequestHandler* requestHandler;
112 
114  bool busy;
115 
117  HttpSslConfiguration* sslConfiguration;
118 
120  void run();
121 
123  void createSocket();
124 
125 public slots:
126 
131  void handleConnection(tSocketDescriptor socketDescriptor);
132 
133 private slots:
134 
136  void readTimeout();
137 
139  void read();
140 
142  void disconnected();
143 
144 };
145 
146 #endif // HTTPCONNECTIONHANDLER_H
The request handler generates a response for each HTTP request.
int maxRequestSize
Maximum size of a request in bytes.
int readTimeout
Defines the maximum time to wait for a complete HTTP request in msec.
int tSocketDescriptor
Alias type definition, for compatibility to different Qt versions.
The connection handler accepts incoming connections and dispatches incoming requests to to a request ...
QSslConfiguration HttpSslConfiguration
Alias for QSslConfiguration if OpenSSL is not supported.
This object represents a single HTTP request.
Definition: httprequest.h:36
int maxMultipartSize
Maximum size of a multipart request in bytes.
Contains all settings for the connection handler.