-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrestserver.h
45 lines (38 loc) · 1.22 KB
/
restserver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef RESTServer_H
#define RESTServer_H
#include <QTcpServer>
#include <QTcpSocket>
#include <QSslCertificate>
#include <QSslKey>
#include <QSslSocket>
#include <QStringList>
#include <QString>
#include <QStringList>
#include <QHash>
#include "serverrequest.h"
class RESTServer : public QTcpServer {
Q_OBJECT
public:
RESTServer(int port, QObject* parent = 0);
virtual ~RESTServer();
protected slots:
virtual void incomingConnection(int socketDescriptor);
void handshakeComplete();
void connectionClosed();
void receiveData();
private:
QString m_certPath;
QSslKey* m_key;
QSslCertificate m_cert;
QString m_notFoundFileHtmlPath;
void sendNoContent(QSslSocket* socket);
void sendMSG(QSslSocket* socket, const QString msg);
bool isBasicAuthorizated(const QStringList& authlist) const;
void receivedPUT(QSslSocket* socket, const QStringList& firstLine, const QHash<QString, QStringList>& header);
void sendOnGETReply(QTcpSocket* socket, const ServerRequest* req);
void sendOnPUTReply(QTcpSocket* socket, const ServerRequest* req);
ServerRequest* receiveRequestHeader(QTcpSocket* socket);
public slots:
void errorySSL(QList<QSslError>);
};
#endif // RESTServer_H