Overte C++ Documentation
HTTPSManager.h
1 //
2 // HTTPSManager.h
3 // libraries/embedded-webserver/src
4 //
5 // Created by Stephen Birarda on 2014-04-24.
6 // Copyright 2014 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_HTTPSManager_h
13 #define hifi_HTTPSManager_h
14 
15 #include <QtNetwork/QSslKey>
16 #include <QtNetwork/QSslCertificate>
17 
18 #include "HTTPManager.h"
19 
20 class HTTPSRequestHandler : public HTTPRequestHandler {
21 public:
23  virtual bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false) = 0;
24 };
25 
26 class HTTPSManager : public HTTPManager, public HTTPSRequestHandler {
27  Q_OBJECT
28 public:
29  HTTPSManager(QHostAddress listenAddress,
30  quint16 port,
31  const QSslCertificate& certificate,
32  const QSslKey& privateKey,
33  const QString& documentRoot,
34  HTTPSRequestHandler* requestHandler = nullptr);
35 
36  void setCertificate(const QSslCertificate& certificate) { _certificate = certificate; }
37  void setPrivateKey(const QSslKey& privateKey) { _privateKey = privateKey; }
38 
39  bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) override;
40  bool handleHTTPSRequest(HTTPSConnection* connection, const QUrl& url, bool skipSubHandler = false) override;
41 
42 protected:
43  void incomingConnection(qintptr socketDescriptor) override;
44  bool requestHandledByRequestHandler(HTTPConnection* connection, const QUrl& url) override;
45 private:
46  QSslCertificate _certificate;
47  QSslKey _privateKey;
48  HTTPSRequestHandler* _sslRequestHandler;
49 };
50 
51 #endif // hifi_HTTPSManager_h
Handles a single HTTP connection.
Definition: HTTPConnection.h:43
Handles HTTP connections.
Definition: HTTPManager.h:32
virtual void incomingConnection(qintptr socketDescriptor) override
Accepts all pending connections.
Definition: HTTPManager.cpp:40