diff options
Diffstat (limited to 'examples/webengine/customdialogs/server.cpp')
-rw-r--r-- | examples/webengine/customdialogs/server.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/examples/webengine/customdialogs/server.cpp b/examples/webengine/customdialogs/server.cpp index 39520e3b6..9b05d3a17 100644 --- a/examples/webengine/customdialogs/server.cpp +++ b/examples/webengine/customdialogs/server.cpp @@ -75,11 +75,20 @@ void Server::handleReadReady() { QTcpSocket *socket = qobject_cast<QTcpSocket*>(sender()); Q_ASSERT(socket); - QByteArray msg = socket->readAll(); - if (msg.contains(QByteArrayLiteral("OPEN_AUTH"))) + m_data.append(socket->readAll()); + + // simply wait for whole request + if (!m_data.endsWith("\r\n\r\n")) + return; + if (m_data.contains(QByteArrayLiteral("OPEN_AUTH"))) { socket->write("HTTP/1.1 401 Unauthorized\nWWW-Authenticate: " "Basic realm=\"Very Restricted Area\"\r\n\r\n"); - if (msg.contains(QByteArrayLiteral("OPEN_PROXY"))) - socket->write("HTTP/1.1 407 Proxy Auth Required\nProxy-Authenticate: " - "Basic realm=\"Proxy requires authentication\"\r\n\r\n"); + m_data.clear(); + return; + } + + socket->write("HTTP/1.1 407 Proxy Auth Required\nProxy-Authenticate: " + "Basic realm=\"Proxy requires authentication\"\r\n" + "content-length: 0\r\n\r\n"); + m_data.clear(); } |