NuriaProject Framework
0.1
The NuriaProject Framework
|
Server for the HyperText Transfer Protocol. More...
#include <httpserver.hpp>
Public Types | |
enum | ThreadingMode { NoThreading = 0, OneThreadPerCore = -1 } |
Public Member Functions | |
HttpServer (QObject *parent=0) | |
~HttpServer () | |
void | addBackend (HttpBackend *backend) |
QVector< HttpBackend * > | backends () const |
QString | fqdn () const |
bool | listen (const QHostAddress &interface=QHostAddress::Any, quint16 port=80) |
bool | listenSecure (const QSslCertificate &certificate, const QSslKey &privateKey, const QHostAddress &interface=QHostAddress::Any, quint16 port=443) |
int | maxThreads () const |
HttpNode * | root () const |
void | setFqdn (const QString &fqdn) |
void | setMaxThreads (int amount) |
void | setRoot (HttpNode *node) |
void | stopListening (int port) |
Friends | |
class | HttpClient |
class | HttpNode |
class | HttpTransport |
Server for the HyperText Transfer Protocol.
This is a implementation of a server for HTTP. The server class itself is responsible for managing the "root node" (The equivalent to the document root in other HTTP servers).
Please see HttpNode and HttpClient
Please see HttpNode for further information.
A HttpServer can either do all request execution in the thread it lifes in, which is the default setting, or use threading to offload requests. If threading is active (By using setMaxThreads), all request handling will be done in threads and none will be handled in the HttpServer thread.
Tip: You can use DependencyManager to manage resources
Additional threading options for setMaxThreads().
Enumerator | |
---|---|
NoThreading |
Uses no threads. All processing is done in the thread of the HttpServer instance. |
OneThreadPerCore |
When passed to setMaxThreads(), one thread per CPU core will be created. maxThreads() will return the chosen value instead of OneThreadPerCore. |
Nuria::HttpServer::HttpServer | ( | QObject * | parent = 0 | ) |
Constructor.
Nuria::HttpServer::~HttpServer | ( | ) |
Destructor.
void Nuria::HttpServer::addBackend | ( | HttpBackend * | backend | ) |
Adds server to the list of back-ends. Use this when you write a server implementation. Ownership of server is transferred to the HttpServer.
QVector< HttpBackend * > Nuria::HttpServer::backends | ( | ) | const |
Returns a list of currently installed back-ends.
QString Nuria::HttpServer::fqdn | ( | ) | const |
Returns the fully-qualified domain name of this server.
bool Nuria::HttpServer::listen | ( | const QHostAddress & | interface = QHostAddress::Any , |
quint16 | port = 80 |
||
) |
Adds a TCP server, listening on interface and port. Returns true
on success.
bool Nuria::HttpServer::listenSecure | ( | const QSslCertificate & | certificate, |
const QSslKey & | privateKey, | ||
const QHostAddress & | interface = QHostAddress::Any , |
||
quint16 | port = 443 |
||
) |
Adds a SSL server, listening on interface and port. Returns true
on success.
int Nuria::HttpServer::maxThreads | ( | ) | const |
Returns the amount of threads used to process requests. The default result is NoThreading
.
HttpNode* Nuria::HttpServer::root | ( | ) | const |
Returns the root node.
void Nuria::HttpServer::setFqdn | ( | const QString & | fqdn | ) |
Sets the fully-qualified domain name of this server.
void Nuria::HttpServer::setMaxThreads | ( | int | amount | ) |
Sets the amount of threads to be used for processing requests. See ThreadingMode for other values that can be passed.
If the new value is less than the current one, requests running in the affected will be processed, after which they're destroyed.
void Nuria::HttpServer::setRoot | ( | HttpNode * | node | ) |
Replaces the current root node with node. The old root node will be deleted. HttpServer will take ownership of node.
void Nuria::HttpServer::stopListening | ( | int | port | ) |
Removes the back-end which is listening on port.