From 3976339ca9b12c7eddbc69ed3a31f85ce845ba63 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 11 May 2012 17:39:12 +0100 Subject: [PATCH] Properly handle unexpected EOF in QHttpThreadDelegate This prevents http POST/PUT from hanging if the QIODevice being uploaded returns -1 from read. Task-number: QTBUG-24738 Change-Id: I76500cc4f0101cc8e5da5f1dc105508b3f519a3c Reviewed-by: Martin Petersson --- src/network/access/qhttpthreaddelegate_p.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h index 7ac927ab1f..b2792c84a7 100644 --- a/src/network/access/qhttpthreaddelegate_p.h +++ b/src/network/access/qhttpthreaddelegate_p.h @@ -208,18 +208,21 @@ public: const char* readPointer(qint64 maximumLength, qint64 &len) { - if (m_amount == 0 && wantDataPending == false) { - len = 0; - wantDataPending = true; - emit wantData(maximumLength); - } else if (m_amount == 0 && wantDataPending == true) { - // Do nothing, we already sent a wantData signal and wait for results - len = 0; - } else if (m_amount > 0) { + if (m_amount > 0) { len = m_amount; return m_data; } - // cannot happen + + if (m_atEnd) { + len = -1; + } else if (!wantDataPending) { + len = 0; + wantDataPending = true; + emit wantData(maximumLength); + } else { + // Do nothing, we already sent a wantData signal and wait for results + len = 0; + } return 0; }