hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joan Balagueró <joan.balagu...@grupoventus.com>
Subject SOME QUESTIONS ABOUT HTTPCLIENT 4
Date Fri, 30 Jan 2009 11:24:04 GMT
Hello,

 

I’ve just migrated the code from HttpClient3 to HttpClient4, and before
starting tests I’d like to make you some questions:

 

1.	When I set the Schema “new Scheme("http",
PlainSocketFactory.getSocketFactory(), 80)”, what does it mean? It means
that the “ThreadSafeClientConnManager” can only send http requests, or it
can only send http requests to destination port 80?

 

 

2.	With HttpClient3, I set the ‘retryHandler’ at method level with:

      objPost.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new
HttpRetryHandler(3));

 

      With HttpClient4, this is similar but at connection level:

this.objHttp.setHttpRequestRetryHandler(new
DefaultHttpRequestRetryHandler(3, false));

 

Is it right? For every get/post HttpClient will retry the request 3 times
for any non-fatal error? Or should I set the retry handler at method level
like I used to do with HttpClient3? (I’ve not seen a method to do this).

 

 

3.	With HttpClient3, I used ‘HttpState’ for managing cookies. 

With HttpClient4, I set a cookieStore to a HttpContext in this way: 

 

  HttpContext localContext = new BasicHttpContext();

  CookieStore cookieStore  = new BasicCookieStore();

 

  // Set cookies.

  for (int j = 0; j < cookieSize; j++) 

  {

   BasicClientCookie bcc = new
BasicClientCookie(this.arrCookies[j].getName(),
this.arrCookies[j].getValue());

   cookieStore.addCookie(bcc);

  }

 

  localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

  this.objHttp.execute(objGet, localContext) 

 

And, when I receive the server response, I get cookies using the same
HttpContext:

List<Cookie> auxCookies =
((CookieStore)localContext.getAttribute(ClientContext.COOKIE_STORE)).getCook
ies();

 

Is this the right way to do this?

 

 

4.	In HttpClient3, the documentation says that a small performance can
be gained by disabling cookies. The same for HttpClient4? If I want to
disable cookies, what I should to do? I saw this piece of code on Internet,
but I’m not sure if it’s right: 

 

this.objHttp.setCookieStore(null); 

this.objHttp.setCookieSpecs(null);

 

 

5.	Receive a null HttpEntity means that the server sent an empty
response?

 

 

Thanks for your time. 




JOAN BALAGUERÓ 

GRUPO VENTUS

C/ Balmes 195, 4º 4ª // 08006 BCN
Telf.: 902 43 05 75 // Fax: 93 292 01 49

 <http://www.grupoventus.com> www.grupoventus.com

 

 

 

 


Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message