From ea3a4a50039443c8370e43cf46be5748177d6875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 21 Aug 2018 09:44:52 +0200 Subject: [PATCH] QHttpNetworkConnectionPrivate::createAuthorization: refactor Grab a reference to the channel instead of indexing into the array repeatedly. Change-Id: I114d571fcfcfd3a751346b513cec728dc2fcda0a Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- src/network/access/qhttpnetworkconnection.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 73510e6bef..18134dda13 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -584,32 +584,32 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, { Q_ASSERT(socket); - int i = indexOf(socket); + QHttpNetworkConnectionChannel &channel = channels[indexOf(socket)]; - QAuthenticator *authenticator = &channels[i].authenticator; + QAuthenticator *authenticator = &channel.authenticator; QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*authenticator); // Send "Authorization" header, but not if it's NTLM and the socket is already authenticated. if (priv && priv->method != QAuthenticatorPrivate::None) { if ((priv->method != QAuthenticatorPrivate::Ntlm && request.headerField("Authorization").isEmpty()) - || channels[i].lastStatus == 401) { + || channel.lastStatus == 401) { QByteArray response = priv->calculateResponse(request.methodName(), request.uri(false), request.url().host()); request.setHeaderField("Authorization", response); - channels[i].authenticationCredentialsSent = true; + channel.authenticationCredentialsSent = true; } } #if QT_CONFIG(networkproxy) - authenticator = &channels[i].proxyAuthenticator; + authenticator = &channel.proxyAuthenticator; priv = QAuthenticatorPrivate::getPrivate(*authenticator); // Send "Proxy-Authorization" header, but not if it's NTLM and the socket is already authenticated. if (priv && priv->method != QAuthenticatorPrivate::None) { - if (priv->method != QAuthenticatorPrivate::Ntlm || channels[i].lastStatus == 407) { + if (priv->method != QAuthenticatorPrivate::Ntlm || channel.lastStatus == 407) { QByteArray response = priv->calculateResponse(request.methodName(), request.uri(false), networkProxy.hostName()); request.setHeaderField("Proxy-Authorization", response); - channels[i].proxyCredentialsSent = true; + channel.proxyCredentialsSent = true; } } #endif // QT_CONFIG(networkproxy)