diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 83156c6a35..478bef0a3c 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -520,6 +520,15 @@ bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket) return false; } +QHttpNetworkRequest QHttpNetworkConnectionPrivate::predictNextRequest() +{ + if (!highPriorityQueue.isEmpty()) + return highPriorityQueue.last().first; + if (!lowPriorityQueue.isEmpty()) + return lowPriorityQueue.last().first; + return QHttpNetworkRequest(); +} + // this is called from _q_startNextRequest and when a request has been sent down a socket from the channel void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) { diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index adb779f473..329d3626fa 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -169,6 +169,7 @@ public: void requeueRequest(const HttpMessagePair &pair); // e.g. after pipeline broke bool dequeueRequest(QAbstractSocket *socket); void prepareRequest(HttpMessagePair &request); + QHttpNetworkRequest predictNextRequest(); void fillPipeline(QAbstractSocket *socket); bool fillPipeline(QList &queue, QHttpNetworkConnectionChannel &channel); diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index b738ccf361..f44010100f 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -581,7 +581,12 @@ bool QHttpNetworkConnectionChannel::ensureConnection() } if (socket->proxy().type() == QNetworkProxy::HttpProxy) { // Make user-agent field available to HTTP proxy socket engine (QTBUG-17223) - QByteArray value = request.headerField("user-agent"); + QByteArray value; + // ensureConnection is called before any request has been assigned, but can also be called again if reconnecting + if (request.url().isEmpty()) + value = connection->d_func()->predictNextRequest().headerField("user-agent"); + else + value = request.headerField("user-agent"); if (!value.isEmpty()) socket->setProperty("_q_user-agent", value); }