summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@rim.com>2013-02-07 17:02:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-12 13:18:24 +0100
commitd23a08c51d0f275b07668bfbc3f818c563b9b956 (patch)
tree29f467833ce77c4febfe0427cb54b6d920dd8ae0 /src/network
parent38cb37f0516ba03b062f4256bc3349c84a9da869 (diff)
BB10 systemProxyForQuery: query system proxy also for non-URL requests
... like e.g. in QAbstractSocket::connectToHost(). We can set the scheme on the query URL based on well-known ports; even if the port is not well-known, we can just query the URL anyhow and let the netstatus API resolve the right proxy for us. In addition, return early for local schemes like "file" and "qrc". Task-number: QTBUG-29425 (cherry picked from commit 28d526db74c50977215133159e565e7c15fd18e3) Change-Id: I40a4865aa7765aad9145e956c0069e78c54670e7 Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/kernel/qnetworkproxy.cpp2
-rw-r--r--src/network/kernel/qnetworkproxy_blackberry.cpp30
2 files changed, 28 insertions, 4 deletions
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index f2101f0ff3..2e6b8dd215 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -1420,7 +1420,7 @@ void QNetworkProxyFactory::setApplicationProxyFactory(QNetworkProxyFactory *fact
\o On Windows platforms, this function may take several seconds to
execute depending on the configuration of the user's system.
- \li On BlackBerry, only UrlRequest queries are supported. SOCKS is
+ \li On BlackBerry, only UrlRequest and TcpSocket queries are supported. SOCKS is
not supported. The proxy credentials are only retrieved for the
default configuration.
\endlist
diff --git a/src/network/kernel/qnetworkproxy_blackberry.cpp b/src/network/kernel/qnetworkproxy_blackberry.cpp
index cbc25336ea..ac8cfcc697 100644
--- a/src/network/kernel/qnetworkproxy_blackberry.cpp
+++ b/src/network/kernel/qnetworkproxy_blackberry.cpp
@@ -62,14 +62,36 @@ QT_BEGIN_NAMESPACE
QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &query)
{
- QNetworkProxy proxy;
+ if (query.url().scheme() == QLatin1String("file")
+ || query.url().scheme() == QLatin1String("qrc"))
+ return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy);
- if (query.queryType() != QNetworkProxyQuery::UrlRequest) {
+ if (query.queryType() != QNetworkProxyQuery::UrlRequest
+ && query.queryType() != QNetworkProxyQuery::TcpSocket) {
qWarning("Unsupported query type: %d", query.queryType());
return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy);
}
- QUrl url = query.url();
+ QUrl url;
+ if (query.queryType() == QNetworkProxyQuery::UrlRequest) {
+ url = query.url();
+ } else if (query.queryType() == QNetworkProxyQuery::TcpSocket
+ && !query.peerHostName().isEmpty()) {
+ url.setHost(query.peerHostName());
+ switch (query.peerPort()) {
+ case 443:
+ url.setScheme(QLatin1String("https"));
+ break;
+ case 21:
+ url.setScheme(QLatin1String("ftp"));
+ break;
+ default:
+ // for unknown ports, we just pretend we are dealing
+ // with a HTTP URL, otherwise we will not get a proxy
+ // from the netstatus API
+ url.setScheme(QLatin1String("http"));
+ }
+ }
if (!url.isValid()) {
qWarning("Invalid URL: %s", qPrintable(url.toString()));
@@ -111,6 +133,8 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy);
}
+ QNetworkProxy proxy;
+
QString protocol = query.protocolTag();
if (protocol.startsWith(QLatin1String("http"), Qt::CaseInsensitive)) { // http, https
proxy.setType((QNetworkProxy::HttpProxy));