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 <httpconnectionhandler.h>
Inherits QThread.
Public Slots | |
void | handleConnection (tSocketDescriptor socketDescriptor) |
Public Member Functions | |
HttpConnectionHandler (QSettings *settings, HttpRequestHandler *requestHandler, QSslConfiguration *sslConfiguration=NULL) | |
HttpConnectionHandler (const HttpListenerSettings *settings, HttpRequestHandler *requestHandler, QSslConfiguration *sslConfiguration=NULL) | |
virtual | ~HttpConnectionHandler () |
bool | isBusy () |
void | setBusy () |
const HttpListenerSettings * | getListenerSettings () const |
Private Slots | |
void | readTimeout () |
void | read () |
void | disconnected () |
Private Member Functions | |
void | run () |
void | createSocket () |
Private Attributes | |
QSettings * | settings |
const HttpListenerSettings * | listenerSettings |
QTcpSocket * | socket |
QTimer | readTimer |
HttpRequest * | currentRequest |
HttpRequestHandler * | requestHandler |
bool | busy |
QSslConfiguration * | sslConfiguration |
bool | useQtSettings |
Alias for QSslConfiguration if OpenSSL is not supported The connection handler accepts incoming connections and dispatches incoming requests to to a request mapper. Since HTTP clients can send multiple requests before waiting for the response, the incoming requests are queued and processed one after the other.
Example for the required configuration settings:
readTimeout=60000 maxRequestSize=16000 maxMultiPartSize=1000000
The readTimeout value defines the maximum time to wait for a complete HTTP request.
Definition at line 52 of file httpconnectionhandler.h.
HttpConnectionHandler::HttpConnectionHandler | ( | QSettings * | settings, |
HttpRequestHandler * | requestHandler, | ||
QSslConfiguration * | sslConfiguration = NULL |
||
) |
Constructor.
settings | Configuration settings of the HTTP webserver as Qt settings |
requestHandler | Handler that will process each incoming HTTP request |
sslConfiguration | SSL (HTTPS) will be used if not NULL |
Definition at line 11 of file httpconnectionhandler.cpp.
References busy, createSocket(), currentRequest, disconnected(), listenerSettings, read(), readTimeout(), readTimer, requestHandler, settings, socket, and sslConfiguration.
HttpConnectionHandler::HttpConnectionHandler | ( | const HttpListenerSettings * | settings, |
HttpRequestHandler * | requestHandler, | ||
QSslConfiguration * | sslConfiguration = NULL |
||
) |
Constructor.
settings | Configuration settings of the HTTP webserver as a structure |
requestHandler | Handler that will process each incoming HTTP request |
sslConfiguration | SSL (HTTPS) will be used if not NULL |
Definition at line 41 of file httpconnectionhandler.cpp.
References busy, createSocket(), currentRequest, disconnected(), listenerSettings, read(), readTimeout(), readTimer, requestHandler, settings, socket, and sslConfiguration.
|
virtual |
Destructor
Definition at line 72 of file httpconnectionhandler.cpp.
|
private |
Create SSL or TCP socket
Definition at line 80 of file httpconnectionhandler.cpp.
References socket, and sslConfiguration.
Referenced by HttpConnectionHandler().
|
privateslot |
Received from the socket when a connection has been closed
Definition at line 182 of file httpconnectionhandler.cpp.
References busy, readTimer, and socket.
Referenced by HttpConnectionHandler().
|
inline |
Get a listener settings constant reference. Can be changed on the HttpListener only.
Definition at line 87 of file httpconnectionhandler.h.
|
slot |
Received from from the listener, when the handler shall start processing a new connection.
socketDescriptor | references the accepted connection. |
Definition at line 120 of file httpconnectionhandler.cpp.
References busy, currentRequest, listenerSettings, qtwebapp::HttpListenerSettings::readTimeout, readTimeout(), readTimer, settings, socket, sslConfiguration, and useQtSettings.
bool HttpConnectionHandler::isBusy | ( | ) |
Returns true, if this handler is in use.
Definition at line 157 of file httpconnectionhandler.cpp.
References busy.
Referenced by qtwebapp::HttpConnectionHandlerPool::cleanup(), and qtwebapp::HttpConnectionHandlerPool::getConnectionHandler().
|
privateslot |
Received from the socket when incoming data can be read
Definition at line 190 of file httpconnectionhandler.cpp.
References qtwebapp::HttpRequest::abort, qtwebapp::HttpRequest::complete, currentRequest, qtwebapp::HttpRequest::getHeader(), qtwebapp::HttpRequest::getMethod(), qtwebapp::HttpRequest::getPath(), qtwebapp::HttpRequest::getPeerAddress(), qtwebapp::HttpRequest::getStatus(), qtwebapp::HttpRequest::getVersion(), listenerSettings, qtwebapp::HttpRequest::readFromSocket(), qtwebapp::HttpListenerSettings::readTimeout, readTimeout(), readTimer, requestHandler, qtwebapp::HttpRequestHandler::service(), settings, socket, useQtSettings, and qtwebapp::HttpRequest::waitForBody.
Referenced by HttpConnectionHandler().
|
privateslot |
Received from the socket when a read-timeout occurred
Definition at line 168 of file httpconnectionhandler.cpp.
References currentRequest, and socket.
Referenced by handleConnection(), HttpConnectionHandler(), and read().
|
private |
Executes the threads own event loop
Definition at line 98 of file httpconnectionhandler.cpp.
References readTimer, and socket.
void HttpConnectionHandler::setBusy | ( | ) |
Mark this handler as busy
Definition at line 162 of file httpconnectionhandler.cpp.
References busy.
Referenced by qtwebapp::HttpConnectionHandlerPool::getConnectionHandler().
|
private |
This shows the busy-state from a very early time
Definition at line 111 of file httpconnectionhandler.h.
Referenced by disconnected(), handleConnection(), HttpConnectionHandler(), isBusy(), and setBusy().
|
private |
Storage for the current incoming HTTP request
Definition at line 105 of file httpconnectionhandler.h.
Referenced by handleConnection(), HttpConnectionHandler(), read(), and readTimeout().
|
private |
Configuration settings
Definition at line 96 of file httpconnectionhandler.h.
Referenced by handleConnection(), HttpConnectionHandler(), and read().
|
private |
Time for read timeout detection
Definition at line 102 of file httpconnectionhandler.h.
Referenced by disconnected(), handleConnection(), HttpConnectionHandler(), read(), and run().
|
private |
Dispatches received requests to services
Definition at line 108 of file httpconnectionhandler.h.
Referenced by HttpConnectionHandler(), and read().
|
private |
Configuration settings
Definition at line 93 of file httpconnectionhandler.h.
Referenced by handleConnection(), HttpConnectionHandler(), and read().
|
private |
TCP socket of the current connection
Definition at line 99 of file httpconnectionhandler.h.
Referenced by createSocket(), disconnected(), handleConnection(), HttpConnectionHandler(), read(), readTimeout(), and run().
|
private |
Configuration for SSL
Definition at line 114 of file httpconnectionhandler.h.
Referenced by createSocket(), handleConnection(), and HttpConnectionHandler().
|
private |
Settings flag
Definition at line 123 of file httpconnectionhandler.h.
Referenced by handleConnection(), and read().