- Author
- Petr Bravenec petr..nosp@m.brav.nosp@m.enec@.nosp@m.hobr.nosp@m.asoft.nosp@m..cz
Features
- C++, Qt – server is writen in C++ and Qt, both Qt4 and Qt5
- embedded – you can link the server to your own application, no need for server like Apache
- simple – configuration is very simple. For basic use you need no configuration at all.
- single threaded – server runs in one thread, no need for locking, mutexes etc.
- multi threaded – it is simple to switch the server to use multiple threads
- event driven – server is not blocking your application, it is event driver.
- unlimited number of connection – your application is not limited to preconfigured pool of connections
- server side includes – html files can include other html files - usefull for headers, footers etc.
Licence
LGPL
Source code
https://dev.hobrasoft.cz/diffusion/HTTPD/
Usage
Static contents server
Server can be used very easy to server static contents.
#include <QCoreApplication>
int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
return app.exec();
}
The configuration of the server can be set in configuration file (Configuration)
#include <QCoreApplication>
#include <QSettings>
int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
QSettings qsettings("/etc/http.conf", QSettings::IniFormat);
return app.exec();
}
Dynamicaly generated pages
If you want to generate your web pages dynamicaly in your application, you have to:
- Extend the class HttpServer and reimplement the requestHandler() method
- Extend HttpRequestHandler and reimplement the service() method
#include "myclass.h"
Q_OBJECT
public:
if (request->
path().startsWith(
"/my-function")) {
controller->
service(request, response);
return;
}
}
};
Q_OBJECT
public:
Httpd(QObject *parent) : QObject(parent) { }
return new RequestMapper(connection);
}
};