Update QTBUG-17223 for Qt 4.8
In Qt 4.7, http network requests are assigned to http connection channels before connecting the channel. In Qt 4.8, channels are connected "blind" as this gives a performance improvement in certain circumstances. On the assumption that User-Agent should be the same for all the requests being sent to the server in a given burst, we use the first queued request to set the user agent for a http proxy. Task-number: QTBUG-17223 Reviewed-by: Markus Goetz Reviewed-by: Martin Petersson
This commit is contained in:
parent
9c1293283e
commit
7dd503c62f
@ -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)
|
||||
{
|
||||
|
@ -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<HttpMessagePair> &queue, QHttpNetworkConnectionChannel &channel);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user