diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2018-08-21 09:44:52 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-05-20 20:31:05 +0200 |
commit | ea3a4a50039443c8370e43cf46be5748177d6875 (patch) | |
tree | 0567e1b7f8664eae45ec60275ad3c86f46ee2123 /src/network/access/qhttpnetworkconnection.cpp | |
parent | 55feb0d08a1c0ffc8721cbfd3defa359bc593358 (diff) |
QHttpNetworkConnectionPrivate::createAuthorization: refactor
Grab a reference to the channel instead of indexing into the array
repeatedly.
Change-Id: I114d571fcfcfd3a751346b513cec728dc2fcda0a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/access/qhttpnetworkconnection.cpp')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 14 |
1 files 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) |