Re: [rest-assured] Proxy support

2,355 views
Skip to first unread message

Johan Haleby

unread,
Nov 10, 2012, 2:15:01 AM11/10/12
to rest-a...@googlegroups.com
Hi,

There's no built-in support for it (since I haven't had the need for it myself :)) but maybe it will work by configuring the underlying http client to use a HttpClient proxy. So if I understand it correctly it's possible to configure the http client proxy by setting the "ConnRoutePNames.DEFAULT_PROXY" parameter to the http client. In REST Assured you can access http client parameters using the http client detailed config. So after you've created your http client proxy you should be able to enable it like this (for ALL requests):

RestAssured.config = newConfig().httpClient(httpClientConfig().setParam(ConnRoutePNames.DEFAULT_PROXY, httpProxyInstance);

Please come back to us if it works.

Regards,
/Johan

On Fri, Nov 9, 2012 at 2:08 AM, ramesh arekatla <arek...@gmail.com> wrote:
Hi All,
I was wondering how to set proxy in the request. Does Rest Assured has support proxy?

Thanks
Ramesh



ramesh arekatla

unread,
Nov 12, 2012, 6:51:16 PM11/12/12
to rest-a...@googlegroups.com
Hi Joan, 
Thanks for your valuable input on http proxy support.
I have followed your steps and configured http client with proxy settings as show below
HttpHost httpProxyInstance = new HttpHost("proxyhostname",80);
RestAssured.config = newConfig().httpClient(httpClientConfig().setParam(ConnRoutePNames.DEFAULT_PROXY, httpProxyInstance));
Response res = get("some http url");
But it not not work. Not sure if I missed anything.

Thanks
Ramesh

Johan Haleby

unread,
Nov 13, 2012, 1:14:40 AM11/13/12
to rest-a...@googlegroups.com
Me neither.. Maybe they've changed something in version 4.2 of HTTP Client or there's something else that's wrong. I would probably debug into http client code and see if the "httpProxyInstance" is being picked up or not.

/Johan

Johan Haleby

unread,
Jan 23, 2013, 9:20:57 AM1/23/13
to rest-a...@googlegroups.com
Hi, 

Hmm I don't have a good answer to this.. How do you try to apply the proxy settings in Rest Assured and how do you do it with plain HTTP Client? 

Regards,
/Johan

On Wed, Jan 23, 2013 at 3:03 PM, Irene <ir.ti...@gmail.com> wrote:
Hello.

Actually I'm having the same problem with version 1.7.2... When I use HTTP Client directly (4.2.3), proxy is used ok. But not with setting config in RestAssured.
I couldn't exactly debug it, only looked at http client log - no traces of proxy.

Irene

unread,
Jan 23, 2013, 9:41:28 AM1/23/13
to rest-a...@googlegroups.com
Exactly like Ramesh above :) Also tried to apply config directly like this:
given().config(newConfig().httpClient(httpClientConfig().setParam(ConnRoutePNames.DEFAULT_PROXY, httpProxyInstance))).expect()...

With plain HTTP Client:
 HttpHost proxy = new HttpHost({proxy ip}, {proxy port}, "http");
 DefaultHttpClient httpclient = new DefaultHttpClient();
 httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
HttpHost target = new HttpHost({url here}, 80, "http");
HttpRequest req = new HttpGet("/");
HttpResponse rsp = httpclient.execute(target, req);

Johan Haleby

unread,
Jan 23, 2013, 10:05:44 AM1/23/13
to rest-a...@googlegroups.com
I have a really hard time testing/verifying since this I don't have a proxy server at hand. It would be really awesome if you could help out and track down what happens in the code to find out why the proxy parameter is ignored when using REST Assured (RA) or if there's something else that RA is missing..

Regards,
/Johan

Irene

unread,
Jan 23, 2013, 10:18:57 AM1/23/13
to rest-a...@googlegroups.com
And I can't properly understand what happens in Groovy code... I get to the method which sends request, but can't localize the code where httpclient is configured.
If it helps, you may try to use Browsermob-proxy (https://github.com/webmetrics/browsermob-proxy) - or maybe explain to me how to get to httpclient in the RA code :) Sorry for dumbness.

Johan Haleby

unread,
Jan 23, 2013, 10:30:05 AM1/23/13
to rest-a...@googlegroups.com
Hehe no problem. Thanks for the tip to the Browsermob-proxy. Could you please add an issue for this at the rest assured google code page so that I do not forget about it?

Regards,
/Johan 

Irene

unread,
Jan 23, 2013, 11:46:47 AM1/23/13
to rest-a...@googlegroups.com
Issue 214

Thank you!

Johan Haleby

unread,
Feb 6, 2013, 1:52:53 PM2/6/13
to rest-a...@googlegroups.com
I haven't had time to look at it yet. If you get something to work with the help of configuration please let us know. If you like you can also dig into the source and help out with a pull request. 

Regards,
/Johan

On Wed, Feb 6, 2013 at 7:26 PM, Johannes Becker <jonny...@googlemail.com> wrote:
Hi there,

any updates on this yet. I'm currently stuck without a working proxy.
Any workarounds appreciated.

Thanks
Jonny
--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Johannes Becker

unread,
Feb 7, 2013, 5:30:22 AM2/7/13
to rest-a...@googlegroups.com
Hi Johan,

thanks for the quick reply. Tried a little debugging in AbstractHttpClient.execute, but didn't find anything suspicious (is this the right place to look?). But I'm not deep enough in this topic, so I'm probably not the best pic for debugging this.

Jonny

Johan Haleby

unread,
Feb 12, 2013, 9:42:46 AM2/12/13
to rest-a...@googlegroups.com
I haven't had time to look at it. As I said before, please help out if it's important for you.

Regards,
/Johan

On Tue, Feb 12, 2013 at 3:35 PM, Oleg <mail.s...@gmail.com> wrote:
Hallo together,

I have the same problem with the proxy in REST-Assured.
Are there any movements?

Oleg.

Oliver Kopp

unread,
Jul 25, 2013, 2:34:19 PM7/25/13
to rest-a...@googlegroups.com
Hi,

Regarding a proxy, https://www.fiddler2.com/ might also be a good alternative if someone wants to hop on fixing the issue.

Cheers,

Oliver

skwok

unread,
May 5, 2014, 4:08:05 PM5/5/14
to rest-a...@googlegroups.com


Hi,

Can anyone please let me know if there is an update on this topic? I followed the last reply in https://code.google.com/p/rest-assured/issues/detail?id=214:
static {
	System.setProperty("https.proxyHost", "yourProxyHost");
	System.setProperty("https.proxyPort", "yourProxyPort"); 
}
and it didn't work for me. What I am trying to do is to use Rest-Assured with Charles. I used the default 8888 proxy port and either with/without enabling transparent HTTP proxy.

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages