123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #ifndef QHTTPSERVER_HPP
- #define QHTTPSERVER_HPP
- #include "qhttpfwd.hpp"
- #include <QObject>
- #include <QHostAddress>
- namespace qhttp {
- namespace server {
- class QHTTP_API QHttpServer : public QObject
- {
- Q_OBJECT
- Q_PROPERTY(quint32 timeOut READ timeOut WRITE setTimeOut)
- public:
-
- explicit QHttpServer(QObject *parent = nullptr);
- virtual ~QHttpServer();
-
- bool listen(const QString& socketOrPort,
- const TServerHandler& handler = nullptr);
-
- bool listen(const QHostAddress& address, quint16 port,
- const TServerHandler& handler = nullptr);
-
- bool listen(quint16 port) {
- return listen(QHostAddress::Any, port);
- }
-
- bool isListening() const;
-
- void stopListening();
-
- quint32 timeOut()const;
-
- void setTimeOut(quint32);
-
- TBackend backendType() const;
- signals:
-
- void newRequest(QHttpRequest *request, QHttpResponse *response);
-
- void newConnection(QHttpConnection* connection);
- protected:
-
- QTcpServer* tcpServer() const;
-
- QLocalServer* localServer() const;
-
- virtual void incomingConnection(QHttpConnection* connection);
-
- virtual void incomingConnection(qintptr handle);
- private:
- explicit QHttpServer(QHttpServerPrivate&, QObject *parent);
- Q_DECLARE_PRIVATE(QHttpServer)
- Q_DISABLE_COPY(QHttpServer)
- QScopedPointer<QHttpServerPrivate> d_ptr;
- };
- }
- }
- #endif
|