summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2018-04-05 15:51:36 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2018-04-12 14:02:20 +0000
commit9917eb2ec69c2d5cc1db408660df43af34fe63fb (patch)
tree3285c2425ceaa6c4801a5da031221298ab030be2 /src/network
parent144ee494b774fdc0fcdfdda53ebd8d4807a270dc (diff)
HTTP/2 - reset uploadByteDevice if necessary
1. If a request was redirected or some error was encountered, we try to reset the uploading byte-device. 2. Disconnecting from the byte-device is not enough, since we have a queued connection, _q_uploadDataReadyRead() gets called even if byte-device was deleted and thus sender() can return null - we have to check this condition. 3. Update auto-test with a case where our server immediately replies with a redirect status code. Task-number: QTBUG-67469 Task-number: QTBUG-66913 Change-Id: I9b364cf3dee1717940ddbe50cba37c3398cc9c95 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttp2protocolhandler.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp
index 5420e713b5..22541e83ba 100644
--- a/src/network/access/qhttp2protocolhandler.cpp
+++ b/src/network/access/qhttp2protocolhandler.cpp
@@ -212,6 +212,9 @@ QHttp2ProtocolHandler::QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *chan
void QHttp2ProtocolHandler::_q_uploadDataReadyRead()
{
+ if (!sender()) // QueuedConnection, firing after sender (byte device) was deleted.
+ return;
+
auto data = qobject_cast<QNonContiguousByteDevice *>(sender());
Q_ASSERT(data);
const qint32 streamID = data->property("HTTP2StreamID").toInt();
@@ -1110,6 +1113,17 @@ void QHttp2ProtocolHandler::updateStream(Stream &stream, const HPack::HttpHeader
if (QHttpNetworkReply::isHttpRedirect(statusCode) && redirectUrl.isValid())
httpReply->setRedirectUrl(redirectUrl);
+ if (QHttpNetworkReply::isHttpRedirect(statusCode)
+ || statusCode == 401 || statusCode == 407) {
+ // These are the status codes that can trigger uploadByteDevice->reset()
+ // in QHttpNetworkConnectionChannel::handleStatus. Alas, we have no
+ // single request/reply, we multiplex several requests and thus we never
+ // simply call 'handleStatus'. If we have byte-device - we try to reset
+ // it here, we don't (and can't) handle any error during reset operation.
+ if (stream.data())
+ stream.data()->reset();
+ }
+
if (connectionType == Qt::DirectConnection)
emit httpReply->headerChanged();
else