WebBrowser/Network/NetworkManager.py

branch
QtWebEngine
changeset 4786
b149def67c6e
parent 4766
5f8d08aa2217
child 4817
0a4e2fb0e93c
equal deleted inserted replaced
4785:61c9b8004864 4786:b149def67c6e
13 from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkProxy 13 from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkProxy
14 14
15 from E5Gui import E5MessageBox 15 from E5Gui import E5MessageBox
16 16
17 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired 17 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired
18 try:
19 from E5Network.E5SslErrorHandler import E5SslErrorHandler
20 SSL_AVAILABLE = True
21 except ImportError:
22 SSL_AVAILABLE = False
18 23
19 from WebBrowser.WebBrowserWindow import WebBrowserWindow 24 from WebBrowser.WebBrowserWindow import WebBrowserWindow
20 25
21 import Preferences 26 import Preferences
22 27
41 QNetworkProxyFactory.setApplicationProxyFactory( 46 QNetworkProxyFactory.setApplicationProxyFactory(
42 self.__proxyFactory) 47 self.__proxyFactory)
43 48
44 self.languagesChanged() 49 self.languagesChanged()
45 50
51 if SSL_AVAILABLE:
52 self.__sslErrorHandler = E5SslErrorHandler(self)
53 self.sslErrors.connect(self.__sslErrorHandler.sslErrorsReplySlot)
54
46 self.__ignoredSslErrors = {} 55 self.__ignoredSslErrors = {}
47 # dictionary of temporarily ignore SSL errors 56 # dictionary of temporarily ignored SSL errors
48 57
49 self.proxyAuthenticationRequired.connect( 58 self.proxyAuthenticationRequired.connect(proxyAuthenticationRequired)
50 lambda proxy, auth: self.proxyAuthentication(
51 proxy.hostName(), auth))
52 self.authenticationRequired.connect( 59 self.authenticationRequired.connect(
53 lambda reply, auth: self.authentication(reply.url(), auth)) 60 lambda reply, auth: self.authentication(reply.url(), auth))
54 61
55 def certificateError(self, error, view): 62 def certificateError(self, error, view):
56 """ 63 """
124 auth.setPassword(password) 131 auth.setPassword(password)
125 if Preferences.getUser("SavePasswords"): 132 if Preferences.getUser("SavePasswords"):
126 WebBrowser.WebBrowserWindow.WebBrowserWindow.passwordManager()\ 133 WebBrowser.WebBrowserWindow.WebBrowserWindow.passwordManager()\
127 .setLogin(url, realm, username, password) 134 .setLogin(url, realm, username, password)
128 135
129 def proxyAuthentication(self, hostname, auth): 136 def proxyAuthentication(self, requestUrl, auth, proxyHost):
130 """ 137 """
131 Public slot to handle a proxy authentication request. 138 Public slot to handle a proxy authentication request.
132 139
140 @param requestUrl requested URL
141 @type QUrl
142 @param auth reference to the authenticator object
143 @type QAuthenticator
133 @param hostname name of the proxy host 144 @param hostname name of the proxy host
134 @type str 145 @type str
135 @param auth reference to the authenticator object
136 @type QAuthenticator
137 """ 146 """
138 proxy = QNetworkProxy.applicationProxy() 147 proxy = QNetworkProxy.applicationProxy()
139 if proxy.user() and proxy.password(): 148 if proxy.user() and proxy.password():
140 auth.setUser(proxy.user()) 149 auth.setUser(proxy.user())
141 auth.setPassword(proxy.password()) 150 auth.setPassword(proxy.password())

eric ide

mercurial