Hobrasoft httpd server
Embedded HTTP server for Qt and C++
|
General single-threaded, event-driven HTTP server. More...
#include <httpserver.h>
Public Member Functions | |
HttpServer (QObject *parent) | |
Constructor using default HttpSettings object. | |
HttpServer (const HttpSettings *settings, QObject *parent) | |
Constructor using your own HttpSettings. More... | |
void | start () |
Starts of restart HttpServer with new parameters. | |
virtual HttpRequestHandler * | requestHandler (HttpConnection *) |
Creates new request handler and returs pointer to it. More... | |
const HttpSettings * | settings () const |
Returs pointer to HttpSettings used in the HttpServer. | |
QVariant | webStatus () const |
QList< QPointer< HobrasoftHttpd::HttpConnection > > | connections () const |
Protected Member Functions | |
void | close () |
Closes the QTcpServer bind with your HttpServer. | |
Private Slots | |
void | slotNewConnection () |
Slot is invoked when QTcpServer::newConnection() signal arrived. More... | |
void | slotConnectionClosed (QObject *) |
Private Attributes | |
FRIEND_CLASS_TEST | |
General single-threaded, event-driven HTTP server.
The class can be used as a static content server without extending. The .html and .shtml formats are recognized. Html files are returned without any change. In shtml file all occurences of #include pragma is found and replaced with requested file. Only one pragma on line is possible. No other strings are allowed on line with #include pragma:
If you want to use some dynamic content you have to reimplement the Http::requestHandler() method. The method is called for every request and it must return new instance of your own HttpRequestHandler derived class:
The class MyOwnRequestHandler() is derived from HttpRequestHandler where the HttpRequestHandler::service() is reimplemented:
HttpServer class has two constructors:
When the first constructor is used then the default QSettings is used to read the configuration. In the second constructor you can use your own instance of HttpSettings class or your own derived class. Using different configuration classes you can start multiple instances of HttpServer in your application each listening on different addresses or ports.
Definition at line 88 of file httpserver.h.
HttpServer::HttpServer | ( | const HttpSettings * | settings, |
QObject * | parent | ||
) |
Constructor using your own HttpSettings.
When using different settings it is possible to start multiple instances of the HttpServer.
Definition at line 26 of file httpserver.cpp.
|
virtual |
Creates new request handler and returs pointer to it.
This method should be reimplemented in derived classes
Reimplemented in Example::Httpd::Httpd.
Definition at line 71 of file httpserver.cpp.
|
privateslot |
Slot is invoked when QTcpServer::newConnection() signal arrived.
The method processes new request.
Definition at line 76 of file httpserver.cpp.