QHttpEngine 0.1.0
Simple and secure HTTP server for Qt applications
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QHttpServer Class Reference

TCP server for HTTP requests. More...

#include <QHttpEngine/QHttpServer>

Inheritance diagram for 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.
 

Detailed Description

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:

QHttpServer server;
if(!server.listen()) {
// error handling
}
TCP server for HTTP requests.
Definition qhttpserver.h:61

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.


The documentation for this class was generated from the following file: