You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Dennis Heimbigner <dm...@unidata.ucar.edu> on 2013/10/29 21:14:03 UTC
Changing parameters after HttpClientBuilder.build() has been called.
After I have materialized the HttpClient
instance using HttpClientBuilder.build(),
I later may need to change the associated
information such as proxy and user agent.
I can find no non-deprecated mechanism for doing this.
What is the proper way to do this?
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Changing parameters after HttpClientBuilder.build() has been
called.
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2013-10-29 at 14:14 -0600, Dennis Heimbigner wrote:
> After I have materialized the HttpClient
> instance using HttpClientBuilder.build(),
> I later may need to change the associated
> information such as proxy and user agent.
> I can find no non-deprecated mechanism for doing this.
> What is the proper way to do this?
>
User agent is just a normal header.
---
HttpGet get = new HttpGet("/");
get.setHeader(HTTP.USER_AGENT, "blah");
---
Credentials provider, auth cache, cookie store can be set as execution
context attributes.
---
CredentialsProvider credentialsProvider = new
BasicCredentialsProvider();
HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credentialsProvider);
---
Proxy can set as a request parameter.
---
RequestConfig requestConfig = RequestConfig.custom()
.setProxy(new HttpHost("proxy"))
.build();
get.setConfig(requestConfig);
---
Hope this helps.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org