Add debug logging for netrc

This commit is contained in:
Florian Bruhin 2018-11-05 14:52:18 +01:00
parent b3493efc80
commit 6931f17f13
2 changed files with 14 additions and 3 deletions

View File

@ -1246,15 +1246,21 @@ class WebEngineTab(browsertab.AbstractTab):
@pyqtSlot(QUrl, 'QAuthenticator*')
def _on_authentication_required(self, url, authenticator):
log.network.debug("Authentication requested for {}, netrc_used {}"
.format(url.toDisplayString(), self.data.netrc_used))
netrc_success = False
if not self.data.netrc_used:
self.data.netrc_used = True
netrc_success = shared.netrc_authentication(url, authenticator)
if not netrc_success:
log.network.debug("Asking for credentials")
abort_on = [self.shutting_down, self.load_started]
answer = shared.authentication_required(url, authenticator,
abort_on)
if not netrc_success and answer is None:
log.network.debug("Aborting auth")
try:
# pylint: disable=no-member, useless-suppression
sip.assign(authenticator, QAuthenticator())

View File

@ -275,14 +275,19 @@ class NetworkManager(QNetworkAccessManager):
@pyqtSlot('QNetworkReply*', 'QAuthenticator*')
def on_authentication_required(self, reply, authenticator):
"""Called when a website needs authentication."""
url = reply.url()
log.network.debug("Authentication requested for {}, netrc_used {}"
.format(url.toDisplayString(), self.netrc_used))
netrc_success = False
if not self.netrc_used:
self.netrc_used = True
netrc_success = shared.netrc_authentication(reply.url(),
authenticator)
netrc_success = shared.netrc_authentication(url, authenticator)
if not netrc_success:
log.network.debug("Asking for credentials")
abort_on = self._get_abort_signals(reply)
shared.authentication_required(reply.url(), authenticator,
shared.authentication_required(url, authenticator,
abort_on=abort_on)
@pyqtSlot('QNetworkProxy', 'QAuthenticator*')