public interface Apache5ConnectionClosingStrategy
The difference between closing the content stream and closing the response is that the former will attempt to keep the underlying connection alive by consuming the entity content while the latter immediately shuts down and discards the connection.In the case of Chunk content stream, the stream is not closed on the server side, and the client can hang on reading the closing chunk. Using the
ClientProperties.READ_TIMEOUT
property can prevent
this hanging forever and the reading of the closing chunk is terminated when the time is out. The other option, when
the timeout is not set, is to abort the Apache client request. This is the default for Apache Client 4.5.1+ when the
read timeout is not set.
Another option is not to close the content stream, which is possible by the Apache client documentation. In this case,
however, the server side may not be notified and would not close its chunk stream.Modifier and Type | Interface and Description |
---|---|
static class |
Apache5ConnectionClosingStrategy.Apache5GracefulClosingStrategy
Strategy that aborts Apache HttpRequests for the case of Chunked Stream, closes the stream, and response next.
|
Modifier and Type | Method and Description |
---|---|
void |
close(ClientRequest clientRequest,
org.apache.hc.client5.http.classic.methods.HttpUriRequest request,
org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response,
InputStream stream)
Method to close the connection.
|
void close(ClientRequest clientRequest, org.apache.hc.client5.http.classic.methods.HttpUriRequest request, org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response, InputStream stream) throws IOException
clientRequest
- The ClientRequest
to get configuration
,
and resolve properties
.request
- Apache HttpUriRequest
that can be abort
ed.response
- Apache CloseableHttpResponse
that can be close
d.stream
- The entity stream that can be closed
.IOException
- In case of some of the closing methods throws IOException
Copyright © 2007-2023, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.