Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect web proxy environment settings #105

Open
Massimo-B opened this issue Jul 11, 2017 · 4 comments
Open

Respect web proxy environment settings #105

Massimo-B opened this issue Jul 11, 2017 · 4 comments

Comments

@Massimo-B
Copy link

Just like https://sourceforge.net/p/gsoap2/bugs/1115/, KDSoap could respect the http_proxy https_proxy and no_proxy environment settings in order to make the user configure the proxy later. Currently this can only be done outside of KDSoap by setting the QNetworkProxy. This was mentioned in #99.

However for the kdwsdl compiler this issue becomes more inconvenient, when it tries to download included xsd code:

kdwsdl2cpp -o Extensions.h Extensions.wsdl 
Warning: Definitions: unknown tag wsp:UsingPolicy
Warning: Definitions: unknown tag wsp:Policy
Warning: Definitions: unknown tag wsp:Policy
importing schema at http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader
Downloading 'http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader'
Error downloading 'http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader': Socket operation timed out
Warning: PortType: unknown tag wsp:Policy
Warning: Operation: unknown tag wsp:Policy
No service tag found in the wsdl file, generating one service per binding 
Converting 0 simple types 
Converting 0 complex types 

However this could be worked around using some wrapper like tsocks.

@dfaure-kdab
Copy link
Member

IMHO that's Qt's job.

But actually, it looks like qtbase/src/network/kernel/qnetworkproxy_generic.cpp already queries these env vars. This just needs to be enabled.

Can you test if adding
QNetworkProxyFactory::setUseSystemConfiguration(true);
in kdwsdl2cpp's main fixes it? I guess I could merge that in.

@Massimo-B
Copy link
Author

I changed main like this:

diff --git a/kdwsdl2cpp/src/main.cpp b/kdwsdl2cpp/src/main.cpp
index 306a269..6524296 100644
--- a/kdwsdl2cpp/src/main.cpp
+++ b/kdwsdl2cpp/src/main.cpp
@@ -26,6 +26,7 @@
 #include <QTimer>
 #include <QCoreApplication>
 #include <QDebug>
+#include <QNetworkProxyFactory>
 
 static const char *WSDL2CPP_DESCRIPTION = "KDAB's WSDL to C++ compiler";
 static const char *WSDL2CPP_VERSION_STR = "2.0";
@@ -146,6 +147,8 @@ int main(int argc, char **argv)
     Settings::self()->setNameSpace(nameSpace);
     Settings::self()->setOptionalElementType(optionalElementType);
     KWSDL::Compiler compiler;
+    
+    QNetworkProxyFactory::setUseSystemConfiguration(true);
 
     // so that we have an event loop, for downloads
     QTimer::singleShot(0, &compiler, SLOT(run()));

I rerun both kdwsdl2cpp for .h and .cpp, recompiled, but it did not work eventhough the environment is set:

$ env |grep prox
https_proxy=http://proxy:8080
http_proxy=http://proxy:8080
no_proxy=10.0.0.0/8,127.0.0.1,172.16.0.0/12,192.168.20.0/24

Isn't setUseSystemConfiguration(true) the default anyway?

@Massimo-B
Copy link
Author

Hi, I still need to set the proxy manually and the environment settings are ignored:

    m_service.clientInterface()->setProxy(proxy);

@Massimo-B
Copy link
Author

Hi, in applications using QNetworkAccessManager it's possible to do

m_networkAccessManager.proxyFactory()->setUseSystemConfiguration(true);

In KDSOAP I only found

QNetworkProxy KDSoapClientInterface::proxy 	() 

Is there any way to get access to the QNetworkProxyFactory ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants