diff --git a/src/webui/httpconnection.cpp b/src/webui/httpconnection.cpp index 68b0b3257..097ebe85d 100644 --- a/src/webui/httpconnection.cpp +++ b/src/webui/httpconnection.cpp @@ -78,21 +78,20 @@ void HttpConnection::handleDownloadFailure(const QString& url, } void HttpConnection::read() { - static QByteArray input; - input.append(m_socket->readAll()); + m_receivedData.append(m_socket->readAll()); // Parse HTTP request header - int header_end = input.indexOf("\r\n\r\n"); + int header_end = m_receivedData.indexOf("\r\n\r\n"); if (header_end < 0) { - qDebug() << "Partial request: \n" << input; + qDebug() << "Partial request: \n" << m_receivedData; // Partial request waiting for the rest return; } - QByteArray header = input.left(header_end); + QByteArray header = m_receivedData.left(header_end); m_parser.writeHeader(header); if (m_parser.isError()) { qWarning() << Q_FUNC_INFO << "header parsing error"; - input.clear(); + m_receivedData.clear(); m_generator.setStatusLine(400, "Bad Request"); write(); return; @@ -101,12 +100,12 @@ void HttpConnection::read() { // Parse HTTP request message if (m_parser.header().hasContentLength()) { const int expected_length = m_parser.header().contentLength(); - QByteArray message = input.mid(header_end + 4, expected_length); + QByteArray message = m_receivedData.mid(header_end + 4, expected_length); if (expected_length > 10000000) { qWarning() << "Bad request: message too long"; m_generator.setStatusLine(400, "Bad Request"); - input.clear(); + m_receivedData.clear(); write(); return; } @@ -119,9 +118,9 @@ void HttpConnection::read() { m_parser.writeMessage(message); - input = input.mid(header_end + 4 + expected_length); + m_receivedData = m_receivedData.mid(header_end + 4 + expected_length); } else { - input.clear(); + m_receivedData.clear(); } if (m_parser.isError()) { diff --git a/src/webui/httpconnection.h b/src/webui/httpconnection.h index 970768617..1af5fcc04 100644 --- a/src/webui/httpconnection.h +++ b/src/webui/httpconnection.h @@ -88,6 +88,7 @@ private: HttpServer *m_httpserver; HttpRequestParser m_parser; HttpResponseGenerator m_generator; + QByteArray m_receivedData; }; #endif