diff --git a/thirdparty/qxt/qxtweb-standalone/network/qxtsslserver.cpp b/thirdparty/qxt/qxtweb-standalone/network/qxtsslserver.cpp index e4a818122..f6dd23115 100644 --- a/thirdparty/qxt/qxtweb-standalone/network/qxtsslserver.cpp +++ b/thirdparty/qxt/qxtweb-standalone/network/qxtsslserver.cpp @@ -65,6 +65,7 @@ public: QSslCertificate localCertificate; QSslKey privateKey; bool autoEncrypt; + QSsl::SslProtocol proto; QQueue pendingConnections; }; @@ -75,6 +76,7 @@ QxtSslServer::QxtSslServer(QObject* parent) : QTcpServer(parent) { QXT_INIT_PRIVATE(QxtSslServer); qxt_d().autoEncrypt = true; + qxt_d().proto = QSsl::TlsV1SslV3; } /*! @@ -194,16 +196,34 @@ bool QxtSslServer::autoEncrypt() const return qxt_d().autoEncrypt; } +/*! + * Sets the protocol used when \a autoEncrypt is enabled. + * + * \sa protocol + */ +void QxtSslServer::setProtocol(QSsl::SslProtocol proto) +{ + qxt_d().proto = proto; +} + +/*! + * Returns the protocol used when \a autoEncrypt is enabled. + * \sa setProtocol + */ +QSsl::SslProtocol QxtSslServer::protocol() const +{ + return qxt_d().proto; +} + /*! * \reimp */ -#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) +#if QT_VERSION >= 0x050000 void QxtSslServer::incomingConnection(qintptr socketDescriptor) #else void QxtSslServer::incomingConnection(int socketDescriptor) #endif { - qWarning() << Q_FUNC_INFO << socketDescriptor; QSslSocket* socket = new QSslSocket(this); if(socket->setSocketDescriptor(socketDescriptor)) { socket->setLocalCertificate(qxt_d().localCertificate); diff --git a/thirdparty/qxt/qxtweb-standalone/network/qxtsslserver.h b/thirdparty/qxt/qxtweb-standalone/network/qxtsslserver.h index e32251024..7ea474b26 100644 --- a/thirdparty/qxt/qxtweb-standalone/network/qxtsslserver.h +++ b/thirdparty/qxt/qxtweb-standalone/network/qxtsslserver.h @@ -60,9 +60,12 @@ public: void setAutoEncrypt(bool on); bool autoEncrypt() const; + void setProtocol(QSsl::SslProtocol proto); + QSsl::SslProtocol protocol() const; + protected: -#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) - virtual void incomingConnection(qintptr socketDescriptor); +#if QT_VERSION >= 0x050000 + virtual void incomingConnection(qintptr socketDescriptor); #else virtual void incomingConnection(int socketDescriptor); #endif diff --git a/thirdparty/qxt/qxtweb-standalone/web/qxtscgiserverconnector.cpp b/thirdparty/qxt/qxtweb-standalone/web/qxtscgiserverconnector.cpp index 7458420d2..150419357 100644 --- a/thirdparty/qxt/qxtweb-standalone/web/qxtscgiserverconnector.cpp +++ b/thirdparty/qxt/qxtweb-standalone/web/qxtscgiserverconnector.cpp @@ -131,7 +131,9 @@ bool QxtScgiServerConnector::canParseRequest(const QByteArray& buffer) return false; } - return (buffer.size() > expectedsize.toInt()); + // The SCGI header is [len]":"[key/value pairs]"," + int headersize = expectedsize.count() + expectedsize.toInt() + 2; + return (buffer.size() >= headersize); } /*! @@ -159,25 +161,26 @@ QHttpRequestHeader QxtScgiServerConnector::parseRequest(QByteArray& buffer) } - buffer = buffer.right(buffer.size() - (expectedsize_s.count() + 1)); - + int expectedsize = expectedsize_s.toInt(); + QByteArray requestheaders = buffer.mid(expectedsize_s.count() + 1, expectedsize); + buffer = buffer.mid(expectedsize_s.count() + expectedsize + 2); QHttpRequestHeader request_m; QByteArray name; int i = 0; - while ((i = buffer.indexOf('\0')) > -1) + while ((i = requestheaders.indexOf('\0')) > -1) { if (name.isEmpty()) { - name = buffer.left(i); + name = requestheaders.left(i); } else { - request_m.setValue(QString::fromLatin1(name).toLower(), QString::fromLatin1(buffer.left(i))); + request_m.setValue(QString::fromLatin1(name).toLower(), QString::fromLatin1(requestheaders.left(i))); name = ""; } - buffer = buffer.mid(i + 1); + requestheaders = requestheaders.mid(i + 1); } @@ -188,16 +191,13 @@ QHttpRequestHeader QxtScgiServerConnector::parseRequest(QByteArray& buffer) { if (key.startsWith(QString("http_"))) { - request_m.setValue(key.right(key.size() - 5), request_m.value(key)); + QString realKey = key.right(key.size() - 5).replace(QLatin1Char('_'), QLatin1Char('-')); + request_m.setValue(realKey, request_m.value(key)); } } request_m.setValue("Connection", "close"); - - buffer.chop(1); - - return request_m; }