Nuria Framework - Network
Network module of the NuriaProject Framework
 All Classes Functions Typedefs Enumerations Enumerator
httpserver.hpp
1 /* Copyright (c) 2014, The Nuria Project
2  * This software is provided 'as-is', without any express or implied
3  * warranty. In no event will the authors be held liable for any damages
4  * arising from the use of this software.
5  * Permission is granted to anyone to use this software for any purpose,
6  * including commercial applications, and to alter it and redistribute it
7  * freely, subject to the following restrictions:
8  * 1. The origin of this software must not be misrepresented; you must not
9  * claim that you wrote the original software. If you use this software
10  * in a product, an acknowledgment in the product documentation would be
11  * appreciated but is not required.
12  * 2. Altered source versions must be plainly marked as such, and must not be
13  * misrepresented as being the original software.
14  * 3. This notice may not be removed or altered from any source
15  * distribution.
16  */
17 
18 #ifndef NURIA_HTTPSERVER_HPP
19 #define NURIA_HTTPSERVER_HPP
20 
21 #include "network_global.hpp"
22 #include <QSslCertificate>
23 #include <QHostAddress>
24 #include <QObject>
25 #include <QSslKey>
26 
27 class QTcpServer;
28 
29 namespace Nuria {
30 class HttpServerPrivate;
31 class HttpClient;
32 class SslServer;
33 class HttpNode;
34 
40 class NURIA_NETWORK_EXPORT HttpServer : public QObject {
41  Q_OBJECT
42 public:
43 
49  HttpServer (bool supportSsl = true, QObject *parent = 0);
50 
52  ~HttpServer ();
53 
55  HttpNode *root () const;
56 
61  void setRoot (HttpNode *node);
62 
67  bool listen (const QHostAddress &interface = QHostAddress::Any, quint16 port = 80);
68 
75  bool listenSecure (const QHostAddress &interface = QHostAddress::Any, quint16 port = 443);
76 
78  QSslCertificate localCertificate () const;
79 
81  QSslKey privateKey () const;
82 
87  const QString &fqdn () const;
88 
93  void setLocalCertificate (const QSslCertificate &cert);
94 
99  void setPrivateKey (const QSslKey &key);
100 
105  int port () const;
106 
111  int securePort () const;
112 
118  void setFqdn (const QString &fqdn);
119 
120 signals:
121 
122 public slots:
123 
124 private slots:
125 
126  void newClient ();
127 
128 private:
129  friend class HttpClient;
130  friend class HttpNode;
131 
136  bool invokeByPath (HttpClient *client, const QString &path);
137 
142  void redirectClientToUseEncryption (HttpClient *client);
143 
144  //
145  HttpServerPrivate *d_ptr;
146 
147 };
148 }
149 
150 #endif // NURIA_HTTPSERVER_HPP
The HttpServer class provides a simple HTTP server. This server is directed at providing interactive ...
Definition: httpserver.hpp:40
The HttpClient class represents a connection to a client.
Definition: httpclient.hpp:92
The HttpNode class represents a virtual directory (or a virtual file) HttpServer uses these nodes to ...
Definition: httpnode.hpp:140