QHttpEngine 0.1.0
Simple and secure HTTP server for Qt applications
|
TCP server for HTTP requests. More...
#include <QHttpEngine/QHttpServer>
Public Member Functions | |
QHttpServer (QHttpHandler *handler, QObject *parent=0) | |
Create an HTTP server with the specified handler. | |
QHttpServer (QObject *parent=0) | |
Create an HTTP server. | |
void | setHandler (QHttpHandler *handler) |
Set the root handler for all new requests. | |
This class provides a TCP server that listens for HTTP requests on the specified address and port. When a new request is received, a QHttpSocket is created for the QTcpSocket which abstracts a TCP server socket. Once the request headers are received, the root handler is invoked and the request processed. The QHttpSocket assumes ownership of the QTcpSocket.
Because QHttpServer derives from QTcpServer, instructing the server to listen on an available port is as simple as invoking listen() with no parameters:
Before passing the socket to the handler, the QTcpSocket's disconnected() signal is connected to the QHttpSocket's deleteLater() slot to ensure that the socket is deleted when the client disconnects.