Convert URL to proxy correctly.

Before, user/password was set to an empty string even when not set in
the URL, causing Qt to reread this information all the time and
call proxyAuthenticationRequired even when the entered info was correct.
This commit is contained in:
Florian Bruhin 2014-05-20 04:23:24 +02:00
parent d4c90b4a60
commit f33f2e0a0f

View File

@ -677,7 +677,14 @@ class Proxy(BaseType):
url = QUrl(value)
if (url.isValid() and not url.isEmpty() and
url.scheme() in self.PROXY_TYPES):
return
if url.userName() and url.password():
pass
elif not url.userName() and not url.password():
pass
else:
raise ValidationError(value, "must either have user and "
"password or none of both")
else:
raise ValidationError(value, "must be a proxy URL (http://... or "
"socks://...) or system/none!")
@ -696,8 +703,14 @@ class Proxy(BaseType):
return QNetworkProxy(QNetworkProxy.NoProxy)
url = QUrl(value)
typ = self.PROXY_TYPES[url.scheme()]
return QNetworkProxy(typ, url.host(), url.port(), url.userName(),
url.password())
proxy = QNetworkProxy(typ, url.host())
if url.port() != -1:
proxy.setPort(url.port())
if url.userName():
proxy.setUser(url.userName())
if url.password():
proxy.setPassword(url.password())
return proxy
class SearchEngineName(BaseType):