SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
|
#include <httpconnectionhandlerpool.h>
Inherits QObject.
Public Member Functions | |
HttpConnectionHandlerPool (QSettings *settings, HttpRequestHandler *requestHandler) | |
HttpConnectionHandlerPool (const HttpListenerSettings *settings, HttpRequestHandler *requestHandler) | |
virtual | ~HttpConnectionHandlerPool () |
HttpConnectionHandler * | getConnectionHandler () |
const HttpListenerSettings * | getListenerSettings () const |
Private Slots | |
void | cleanup () |
Private Member Functions | |
void | loadSslConfig () |
Private Attributes | |
QSettings * | settings |
const HttpListenerSettings * | listenerSettings |
HttpRequestHandler * | requestHandler |
QList< HttpConnectionHandler * > | pool |
QTimer | cleanupTimer |
QMutex | mutex |
QSslConfiguration * | sslConfiguration |
bool | useQtSettings |
Pool of http connection handlers. The size of the pool grows and shrinks on demand.
Example for the required configuration settings:
minThreads=4 maxThreads=100 cleanupInterval=60000 readTimeout=60000 ;sslKeyFile=ssl/my.key ;sslCertFile=ssl/my.cert maxRequestSize=16000 maxMultiPartSize=1000000
After server start, the size of the thread pool is always 0. Threads are started on demand when requests come in. The cleanup timer reduces the number of idle threads slowly by closing one thread in each interval. But the configured minimum number of threads are kept running.
For SSL support, you need an OpenSSL certificate file and a key file. Both can be created with the command
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout my.key -out my.cert
Visit http://slproweb.com/products/Win32OpenSSL.html to download the Light version of OpenSSL for Windows.
Please note that a listener with SSL settings can only handle HTTPS protocol. To support both HTTP and HTTPS simultaneously, you need to start two listeners on different ports - one with SLL and one without SSL.
Definition at line 51 of file httpconnectionhandlerpool.h.
HttpConnectionHandlerPool::HttpConnectionHandlerPool | ( | QSettings * | settings, |
HttpRequestHandler * | requestHandler | ||
) |
Constructor.
settings | Configuration settings for the HTTP server. Must not be 0. |
requestHandler | The handler that will process each received HTTP request. |
Definition at line 12 of file httpconnectionhandlerpool.cpp.
References cleanup(), cleanupTimer, listenerSettings, loadSslConfig(), requestHandler, settings, and sslConfiguration.
HttpConnectionHandlerPool::HttpConnectionHandlerPool | ( | const HttpListenerSettings * | settings, |
HttpRequestHandler * | requestHandler | ||
) |
Constructor.
settings | Configuration settings for the HTTP server as structure |
requestHandler | The handler that will process each received HTTP request. |
Definition at line 25 of file httpconnectionhandlerpool.cpp.
References cleanup(), qtwebapp::HttpListenerSettings::cleanupInterval, cleanupTimer, listenerSettings, loadSslConfig(), requestHandler, settings, and sslConfiguration.
|
virtual |
Destructor
Definition at line 38 of file httpconnectionhandlerpool.cpp.
References handler(), pool, and sslConfiguration.
|
privateslot |
Received from the clean-up timer.
Definition at line 85 of file httpconnectionhandlerpool.cpp.
References handler(), qtwebapp::HttpConnectionHandler::isBusy(), listenerSettings, qtwebapp::HttpListenerSettings::minThreads, mutex, pool, settings, and useQtSettings.
Referenced by HttpConnectionHandlerPool().
HttpConnectionHandler * HttpConnectionHandlerPool::getConnectionHandler | ( | ) |
Get a free connection handler, or 0 if not available.
Definition at line 50 of file httpconnectionhandlerpool.cpp.
References handler(), qtwebapp::HttpConnectionHandler::isBusy(), listenerSettings, qtwebapp::HttpListenerSettings::maxThreads, mutex, pool, requestHandler, qtwebapp::HttpConnectionHandler::setBusy(), settings, sslConfiguration, and useQtSettings.
Referenced by qtwebapp::HttpListener::incomingConnection().
|
inline |
Get a listener settings const reference. Can be changed on the HttpListener only.
Definition at line 82 of file httpconnectionhandlerpool.h.
|
private |
Load SSL configuration
Definition at line 107 of file httpconnectionhandlerpool.cpp.
References listenerSettings, settings, qtwebapp::HttpListenerSettings::sslCertFile, sslConfiguration, qtwebapp::HttpListenerSettings::sslKeyFile, and useQtSettings.
Referenced by HttpConnectionHandlerPool().
|
private |
Timer to clean-up unused connection handler
Definition at line 99 of file httpconnectionhandlerpool.h.
Referenced by HttpConnectionHandlerPool().
|
private |
Settings for this pool as structure
Definition at line 90 of file httpconnectionhandlerpool.h.
Referenced by cleanup(), getConnectionHandler(), HttpConnectionHandlerPool(), and loadSslConfig().
|
private |
Used to synchronize threads
Definition at line 102 of file httpconnectionhandlerpool.h.
Referenced by cleanup(), and getConnectionHandler().
|
private |
Pool of connection handlers
Definition at line 96 of file httpconnectionhandlerpool.h.
Referenced by cleanup(), getConnectionHandler(), and ~HttpConnectionHandlerPool().
|
private |
Will be assigned to each Connectionhandler during their creation
Definition at line 93 of file httpconnectionhandlerpool.h.
Referenced by getConnectionHandler(), and HttpConnectionHandlerPool().
|
private |
Settings for this pool as Qt settings
Definition at line 87 of file httpconnectionhandlerpool.h.
Referenced by cleanup(), getConnectionHandler(), HttpConnectionHandlerPool(), and loadSslConfig().
|
private |
The SSL configuration (certificate, key and other settings)
Definition at line 105 of file httpconnectionhandlerpool.h.
Referenced by getConnectionHandler(), HttpConnectionHandlerPool(), loadSslConfig(), and ~HttpConnectionHandlerPool().
|
private |
Settings flag
Definition at line 111 of file httpconnectionhandlerpool.h.
Referenced by cleanup(), getConnectionHandler(), and loadSslConfig().