commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Charles Huey" <stephenh...@fastmail.fm>
Subject Re: Will HttpClient wait for response before continuing?
Date Mon, 07 Feb 2005 17:54:59 GMT
Ok, I was just hoping that executeMethod would automatically retrieve
all of the response so that when getResponseBodyAsString is called, it
is only retrieving it from storage, but I understand from you that only
if a method like that is called does it bother to wait around for the
rest of the bytes.  

So, to consume it, is this sufficient?

int result = hc.executeMethod(getLogin);
String text = hc.getResponseBodyAsString();
getLogin.releaseConnection();


Or do I need to do more with it, like this?

int result = hc.executeMethod(getLogin);
String text = hc.getResponseBodyAsString();
int count = text.length();
getLogin.releaseConnection();


I know this is probably pretty basic stuff, but I'm just trying to make
sure that the compiler doesn't optimize this junk and in some weird
annoying way let the getResponseBodyAsString method know that actually,
it's not really needed, so we're not going to wait for even you to
finish because we're not actually doing anything with the String text...


Thanks,
Stephen


----- Original message -----
From: "Oleg Kalnichevski" <olegk@apache.org>
To: "Commons Net User list" <commons-user@jakarta.apache.org>
Date: Mon, 7 Feb 2005 18:16:59 +0100
Subject: Re: Will HttpClient wait for response before continuing?

Stephen,

No it won't. The releaseConnection method among obvious things such as
returning the connection back to the connection manager also makes sure
that the connection is actually reusable if it is kept alive (open).
That pretty much implies making sure that the response body is fully
consumed. If your application does not consume the response body in its
entirety, the releaseConnection method will do it for it.

Hope this answers your question.

Oleg


On Mon, Feb 07, 2005 at 10:18:49AM -0600, Stephen Charles Huey wrote:
> If you do a GET or POST and call getResponseBodyAsString, HttpClient
> obviously has to wait for the response.  If you don't call that, will it
> just continue on to the next request before finishing getting the
> response from the first one?  I'm trying to debug some connection
> pooling stuff on our web app.  Here's some sample code from my load
> tester:
> 
> 
> 
> int result = hc.executeMethod(getLogin);
> getLogin.releaseConnection();
>                 
> doNothing(2000);  // wait 2 seconds
> 
> hc.executeMethod(getCreate);
> getCreate.releaseConnection();
> 
> doNothing(2000);  // wait 2 seconds
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message