|
|
|
|
@ -5,15 +5,47 @@
@@ -5,15 +5,47 @@
|
|
|
|
|
|
|
|
|
|
#include "httpconnectionhandler.h" |
|
|
|
|
#include "httpresponse.h" |
|
|
|
|
#include "httplistenersettings.h" |
|
|
|
|
|
|
|
|
|
using namespace qtwebapp; |
|
|
|
|
|
|
|
|
|
HttpConnectionHandler::HttpConnectionHandler(QSettings* settings, HttpRequestHandler* requestHandler, QSslConfiguration* sslConfiguration) |
|
|
|
|
: QThread() |
|
|
|
|
: QThread(), useQtSettings(true) |
|
|
|
|
{ |
|
|
|
|
Q_ASSERT(settings!=0); |
|
|
|
|
Q_ASSERT(requestHandler!=0); |
|
|
|
|
this->settings=settings; |
|
|
|
|
this->listenerSettings=0; |
|
|
|
|
this->requestHandler=requestHandler; |
|
|
|
|
this->sslConfiguration=sslConfiguration; |
|
|
|
|
currentRequest=0; |
|
|
|
|
busy=false; |
|
|
|
|
|
|
|
|
|
// Create TCP or SSL socket
|
|
|
|
|
createSocket(); |
|
|
|
|
|
|
|
|
|
// execute signals in my own thread
|
|
|
|
|
moveToThread(this); |
|
|
|
|
socket->moveToThread(this); |
|
|
|
|
readTimer.moveToThread(this); |
|
|
|
|
|
|
|
|
|
// Connect signals
|
|
|
|
|
connect(socket, SIGNAL(readyRead()), SLOT(read())); |
|
|
|
|
connect(socket, SIGNAL(disconnected()), SLOT(disconnected())); |
|
|
|
|
connect(&readTimer, SIGNAL(timeout()), SLOT(readTimeout())); |
|
|
|
|
readTimer.setSingleShot(true); |
|
|
|
|
|
|
|
|
|
qDebug("HttpConnectionHandler (%p): constructed", this); |
|
|
|
|
this->start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HttpConnectionHandler::HttpConnectionHandler(HttpListenerSettings* settings, HttpRequestHandler* requestHandler, QSslConfiguration* sslConfiguration) |
|
|
|
|
: QThread(), useQtSettings(false) |
|
|
|
|
{ |
|
|
|
|
Q_ASSERT(settings!=0); |
|
|
|
|
Q_ASSERT(requestHandler!=0); |
|
|
|
|
this->settings=0; |
|
|
|
|
this->listenerSettings=settings; |
|
|
|
|
this->requestHandler=requestHandler; |
|
|
|
|
this->sslConfiguration=sslConfiguration; |
|
|
|
|
currentRequest=0; |
|
|
|
|
@ -109,7 +141,7 @@ void HttpConnectionHandler::handleConnection(tSocketDescriptor socketDescriptor)
@@ -109,7 +141,7 @@ void HttpConnectionHandler::handleConnection(tSocketDescriptor socketDescriptor)
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Start timer for read timeout
|
|
|
|
|
int readTimeout=settings->value("readTimeout",10000).toInt(); |
|
|
|
|
int readTimeout = useQtSettings ? settings->value("readTimeout",10000).toInt() : listenerSettings->readTimeout; |
|
|
|
|
readTimer.start(readTimeout); |
|
|
|
|
// delete previous request
|
|
|
|
|
delete currentRequest; |
|
|
|
|
@ -173,7 +205,7 @@ void HttpConnectionHandler::read()
@@ -173,7 +205,7 @@ void HttpConnectionHandler::read()
|
|
|
|
|
{ |
|
|
|
|
// Restart timer for read timeout, otherwise it would
|
|
|
|
|
// expire during large file uploads.
|
|
|
|
|
int readTimeout=settings->value("readTimeout",10000).toInt(); |
|
|
|
|
int readTimeout = useQtSettings ? settings->value("readTimeout",10000).toInt() : listenerSettings->readTimeout; |
|
|
|
|
readTimer.start(readTimeout); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -267,7 +299,7 @@ void HttpConnectionHandler::read()
@@ -267,7 +299,7 @@ void HttpConnectionHandler::read()
|
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Start timer for next request
|
|
|
|
|
int readTimeout=settings->value("readTimeout",10000).toInt(); |
|
|
|
|
int readTimeout = useQtSettings ? settings->value("readTimeout",10000).toInt() : listenerSettings->readTimeout; |
|
|
|
|
readTimer.start(readTimeout); |
|
|
|
|
} |
|
|
|
|
delete currentRequest; |
|
|
|
|
|