Interface ApacheConnectionClosingStrategy
-
- All Known Implementing Classes:
ApacheConnectionClosingStrategy.GracefulClosingStrategy
,ApacheConnectionClosingStrategy.ImmediateClosingStrategy
public interface ApacheConnectionClosingStrategy
/** Strategy that defines the way the Apache client releases resources. The client enables closing the content stream and the response. From the Apache documentation: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.
With Apache Client before 4.5.1, it was ok to close the response and the content stream. This is the default for Apache Client 4.5 and older. For Apache Client 4.5.1+, first the content stream and the response is should be closed. In the case of Chunk content stream, the stream is not closed on the server side, and the client can hung on reading the closing chunk. Using theClientProperties.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 not close its chunk stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ApacheConnectionClosingStrategy.GracefulClosingStrategy
Strategy that aborts Apache HttpRequests for the case of Chunked Stream, closes the stream, and response next.static class
ApacheConnectionClosingStrategy.ImmediateClosingStrategy
Strategy that closes the response and content stream next.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close(ClientRequest clientRequest, org.apache.http.client.methods.HttpUriRequest request, org.apache.http.client.methods.CloseableHttpResponse response, InputStream stream)
Method to close the connection.
-
-
-
Method Detail
-
close
void close(ClientRequest clientRequest, org.apache.http.client.methods.HttpUriRequest request, org.apache.http.client.methods.CloseableHttpResponse response, InputStream stream) throws IOException
Method to close the connection.- Parameters:
clientRequest
- TheClientRequest
to getconfiguration
, andresolve properties
.request
- ApacheHttpUriRequest
that can beabort
ed.response
- ApacheCloseableHttpResponse
that can beclose
d.stream
- The entity stream that can beclosed
.- Throws:
IOException
- In case of some of the closing methods throwsIOException
-
-