sdmxdzb / rest-client

Automatically exported from code.google.com/p/rest-client
Apache License 2.0
0 stars 0 forks source link

How set a Http/Https proxy in CLI rest-client ? #180

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Download restclient-cli-3.2-jar-with-dependencies.jar
2. Create a request file : re1.rcq
3. Start  /usr/java/jre-1.7/bin/java -DproxySet=true -Dhttp.proxyHost=proxy-XXX 
-Dhttp.proxyPort=3129 -Dhttps.proxyHost=proxy-XXX -Dhttps.proxyPort=3129 -jar 
/home/XXXX/rest-client/lib/restclient-cli-3.2-jar-with-dependencies.jar -o 
responses requests/re1.rcq

What is the expected output? What do you see instead?

I expected rest-client connect to Url include in re1.rcq (made from store from 
GUI version)
Instead, I obtain a org.apache.http.conn.ConnectTimeoutException: Connect to 
XXXXX.com:443 timed out

What version of the product are you using? On what operating system?
3.2 - Linux RH 5.9

Please provide any additional information below.

Original issue reported on code.google.com by rodolphe...@gmail.com on 4 Jul 2013 at 12:42

GoogleCodeExporter commented 8 years ago
Both CLI and GUI version use the same configuration: 
~/.rest-client/rest-client.properties

Use the GUI tool to configure the proxy details and quit it. This will update 
this property file. After that when you run the CLI tool (without the -D proxy 
details you have mentioned), it will read the proxy details from 
~/.rest-client/rest-client.properties and use it.

Try it out and let me know.

Original comment by subwiz on 4 Jul 2013 at 5:17

GoogleCodeExporter commented 8 years ago
Thank you for your response.

I have tested this way yet - KO.

I have take a look in sources...I think in CLI mode, proxy config is ...never 
set..compared to GUI way ;-)

I think a fix is needed - thanks in advance

Original comment by rodolphe...@gmail.com on 5 Jul 2013 at 1:38

GoogleCodeExporter commented 8 years ago
Thanks for letting me know. I will look into the code.

Original comment by subwiz on 5 Jul 2013 at 3:41

GoogleCodeExporter commented 8 years ago
This is the code:

http://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/
org/wiztools/restclient/HTTPClientRequestExecuter.java

Line 126 onwards, you see that proxy is being considered. This is the same code 
that is executed by both GUI and CLI version. Do you suspect any error over 
here?

I don't have a proxy to test the scenario now.

Original comment by subwiz on 5 Jul 2013 at 3:57

GoogleCodeExporter commented 8 years ago
Yes, this code use ProxyConfig.getInstance(), and if enabled use it.

But, any method does init/set proxy parameters before...(instead of GUI mode)

Original comment by rodolphe...@gmail.com on 8 Jul 2013 at 9:16

GoogleCodeExporter commented 8 years ago
> any method does init/set proxy parameters before...(instead of GUI mode)

Sorry, right now, we do not have.

Original comment by subwiz on 8 Jul 2013 at 9:26

GoogleCodeExporter commented 8 years ago
I (on my own local clone) add these lines in 
http://code.google.com/p/rest-client/source/browse/restclient-lib/src/main/java/
org/wiztools/restclient/HTTPClientRequestExecuter.java

and it works well !

IGlobalOptions options = (IGlobalOptions) 
ServiceLocator.getInstance(IGlobalOptions.class);

options.acquire();

options.release();

ProxyConfig proxy = ProxyConfig.getInstance();

proxy.acquire();

try {

proxy.setEnabled(Boolean.valueOf(

options.getProperty("proxy.options.is_enabled"))

.booleanValue());

proxy.setHost(options.getProperty("proxy.options.host"));

proxy.setPort(Integer.parseInt(options

.getProperty("proxy.options.port")));

proxy.setAuthEnabled(Boolean.valueOf(

options.getProperty("proxy.options.is_auth_enabled"))

.booleanValue());

proxy.setUsername(options.getProperty("proxy.options.username"));

proxy.setPassword(options.getProperty("proxy.options.password")

.toCharArray());

} catch (Exception ex) {

ex.printStackTrace();

}

proxy.release();

Original comment by rodolphe...@gmail.com on 8 Jul 2013 at 11:30

GoogleCodeExporter commented 8 years ago
Can you attach your code to the issue? I will patch my code accordingly...

Original comment by subwiz on 8 Jul 2013 at 4:16

GoogleCodeExporter commented 8 years ago
Fixed:

https://code.google.com/p/rest-client/source/detail?r=1841388fbcabfd481d08dfe6aa
e459b8ff44e995

Can you please verify if my fix works for you? As I said earlier, I don't have 
a proxy environment to test right now...

Original comment by subwiz on 9 Jul 2013 at 6:36

GoogleCodeExporter commented 8 years ago
Thanks. I think it should work !

How can I obtain a fixed JAR CLI ?

Original comment by rodolphe...@gmail.com on 11 Jul 2013 at 11:13

GoogleCodeExporter commented 8 years ago
Is it possible to get Guide Quick and Dirty pdf ;-) ?

Original comment by rodolphe...@gmail.com on 11 Jul 2013 at 11:15

GoogleCodeExporter commented 8 years ago
Fixed cli:

http://download.wiztools.org/rest-client/restclient-cli-3.2.1-SNAPSHOT-jar-with-
dependencies.jar

Let me know if it works.

Many of the content in the book is available here:

http://code.google.com/p/rest-client/w/list

Original comment by subwiz on 11 Jul 2013 at 11:50