On Thu, 2006-11-09 at 04:46 +0800, [EMAIL PROTECTED] wrote:
> I am new to HttpCore and using 4.0 Alpha 2 version. I am trying to connect a
> server and request more than one pages from that server using the same
> connection. My goal is to reuse socket so that no new socket is opened on the
> Http client for the subsequent requests to the same server and port.
>
...
> System.out.println(">> Response: " + response.getStatusLine());
>
>
>
> Header[] hds = response.getAllHeaders();
>
> for (Header h: hds){
>
> System.out.println(">> Headers Name: " + h.getName() +
>
> " Value: " + h.getValue() );
>
> }
>
You should consume the entire response content in order to be able to
reuse the connection. This additional line fixes the problem
---
String stuff = EntityUtils.toString(response.getEntity());
---
Just out of curiosity why are using HttpCore and not HttpClient 3.x?
Oleg
>
>
> System.out.println("==============");
>
>
>
> if (!connStrategy.keepAlive(response)) {
>
> System.out.println("Connection closed.");
>
> conn.close();
>
> } else {
>
> conn.flush();
>
> System.out.println("Connection kept alive...");
>
> }
>
...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]