That makes sense.
In my case, there is long time connection and client waiting for the
terminating chunk to close the inputstream. Is there any approach that we
can
force to set the data stream chunk is terminating and this connection can
be released to pool ?


On Fri, Apr 13, 2018 at 4:27 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2018-04-13 at 10:50 +0800, Jim Ma wrote:
> > Thanks, Oleg. Can you please explain it more ?  Do you mean  the
> > state of a connection is inconsistent when the chunked inputstream
> > isn't fully consumed ?
> >
>
> If the connection were to be returned back to the pool and re-used for
> another message exchange, the new consumer would get chunks of the
> previous data stream in response to its request instead of a valid HTTP
> response message.
>
> Oleg
>
>
>
> > On Thu, Apr 12, 2018 at 5:38 PM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> > > On Thu, 2018-04-12 at 15:44 +0800, Jim Ma wrote:
> > > > Hi,
> > > > When I tried to create http client with
> > > > a PoolingHttpClientConnectionManager and send get request to read
> > > the
> > > > chunk
> > > > body with the following lines:
> > > >   httpClient = HttpClientBuilder.create()
> > > >
> > >                  .setConnectionManager(poolingHttpClientConnectionM
> > > an
> > > > ager)
> > > >                  .disableContentCompression().build();
> > > >   ...
> > > >  HttpResposne res = httpClient.execute(httpGetMethod, ctx);
> > > >  InputStream inputStream = res.getEntity().getContent();
> > > >  //read inputstream
> > > >
> > > >  After read several bytes or not even read from InputStream, I'd
> > > like
> > > > to
> > > > drop the response message and  release the connection at any time
> > > > without
> > > > waiting the empty chunk arrives.
> > > >  But the inputstream here is an EofSensorInputStream which can
> > > only
> > > > release
> > > > the connection after the response is consumed, so when I call
> > > > inputstream.close()  it actually blocks there and wait the
> > > > terminating
> > > > chunk.
> > > > Is there any approach that I can force to release this connection
> > > to
> > > > pool
> > > > without discard it and make keep-alive work ?
> > > >
> > >
> > > Connection whose state is inconsistent cannot be re-used / kept
> > > alive.
> > >
> > > Oleg
> > >
> >
> >
>

Reply via email to