hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Changing parameters after HttpClientBuilder.build() has been called.
Date Tue, 29 Oct 2013 20:40:48 GMT
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


Mime
View raw message