From 1ed4c52dd7ad3cb6b0d846464b69489031ab68a5 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 13 Jul 2009 13:31:36 +0200 Subject: QNAM: Fix double sending of a HTTP request In some cases, weird timing issues could occur. In those cases, an EOF was sent twice for the upload data, leading to the HTTP code being confused and sending the request headers twice. Task-number: 257662 Reviewed-by: Thiago Macieira --- src/network/access/qnetworkaccesshttpbackend.cpp | 4 ++++ src/network/access/qnetworkreplyimpl.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index ce800c2..c57157e 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -628,6 +628,10 @@ void QNetworkAccessHttpBackend::closeUpstreamChannel() { // this indicates that the user finished uploading the data for POST Q_ASSERT(uploadDevice); + + if (uploadDevice->eof) + return; // received a 2nd time. should fix 257662 and 256369 + uploadDevice->eof = true; emit uploadDevice->readChannelFinished(); } diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 63a9c2d..98944fd 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -92,6 +92,9 @@ void QNetworkReplyImplPrivate::_q_startOperation() void QNetworkReplyImplPrivate::_q_sourceReadyRead() { + if (state != Working) + return; + // read data from the outgoingData QIODevice into our internal buffer enum { DesiredBufferSize = 32 * 1024 }; @@ -131,6 +134,8 @@ void QNetworkReplyImplPrivate::_q_sourceReadChannelFinished() void QNetworkReplyImplPrivate::_q_copyReadyRead() { Q_Q(QNetworkReplyImpl); + if (state != Working) + return; if (!copyDevice || !q->isOpen()) return; -- cgit v0.12