Package org.apache.http.params
Class HttpConnectionParams
java.lang.Object
org.apache.http.params.HttpConnectionParams
- All Implemented Interfaces:
CoreConnectionPNames
public final class HttpConnectionParams extends Object implements CoreConnectionPNames
An adaptor for accessing connection parameters in
Note that the implements relation to
HttpParams.
Note that the implements relation to
CoreConnectionPNames
is for compatibility with existing application code only. References to
the parameter names should use the interface, not this class.- Since:
- 4.0
- Version:
- $Revision: 576089 $
- Author:
- Oleg Kalnichevski
-
Field Summary
Fields inherited from interface org.apache.http.params.CoreConnectionPNames
CONNECTION_TIMEOUT, MAX_HEADER_COUNT, MAX_LINE_LENGTH, SO_LINGER, SO_TIMEOUT, SOCKET_BUFFER_SIZE, STALE_CONNECTION_CHECK, TCP_NODELAY -
Method Summary
Modifier and Type Method Description static intgetConnectionTimeout(HttpParams params)Returns the timeout until a connection is etablished.static intgetLinger(HttpParams params)Returns linger-on-close timeout.static intgetSocketBufferSize(HttpParams params)static intgetSoTimeout(HttpParams params)Returns the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data.static booleangetTcpNoDelay(HttpParams params)Tests if Nagle's algorithm is to be used.static booleanisStaleCheckingEnabled(HttpParams params)Tests whether stale connection check is to be used.static voidsetConnectionTimeout(HttpParams params, int timeout)Sets the timeout until a connection is etablished.static voidsetLinger(HttpParams params, int value)Returns linger-on-close timeout.static voidsetSocketBufferSize(HttpParams params, int size)static voidsetSoTimeout(HttpParams params, int timeout)Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data.static voidsetStaleCheckingEnabled(HttpParams params, boolean value)Defines whether stale connection check is to be used.static voidsetTcpNoDelay(HttpParams params, boolean value)Determines whether Nagle's algorithm is to be used.
-
Method Details
-
getSoTimeout
Returns the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout. This value is used when no socket timeout is set in the method parameters.- Returns:
- timeout in milliseconds
-
setSoTimeout
Sets the default socket timeout (SO_TIMEOUT) in milliseconds which is the timeout for waiting for data. A timeout value of zero is interpreted as an infinite timeout. This value is used when no socket timeout is set in the method parameters.- Parameters:
timeout- Timeout in milliseconds
-
getTcpNoDelay
Tests if Nagle's algorithm is to be used.- Returns:
- true if the Nagle's algorithm is to NOT be used (that is enable TCP_NODELAY), false otherwise.
-
setTcpNoDelay
Determines whether Nagle's algorithm is to be used. The Nagle's algorithm tries to conserve bandwidth by minimizing the number of segments that are sent. When applications wish to decrease network latency and increase performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data will be sent earlier, at the cost of an increase in bandwidth consumption.- Parameters:
value- true if the Nagle's algorithm is to NOT be used (that is enable TCP_NODELAY), false otherwise.
-
getSocketBufferSize
-
setSocketBufferSize
-
getLinger
Returns linger-on-close timeout. Value 0 implies that the option is disabled. Value -1 implies that the JRE default is used.- Returns:
- the linger-on-close timeout
-
setLinger
Returns linger-on-close timeout. This option disables/enables immediate return from a close() of a TCP Socket. Enabling this option with a non-zero Integer timeout means that a close() will block pending the transmission and acknowledgement of all data written to the peer, at which point the socket is closed gracefully. Value 0 implies that the option is disabled. Value -1 implies that the JRE default is used.- Parameters:
value- the linger-on-close timeout
-
getConnectionTimeout
Returns the timeout until a connection is etablished. A value of zero means the timeout is not used. The default value is zero.- Returns:
- timeout in milliseconds.
-
setConnectionTimeout
Sets the timeout until a connection is etablished. A value of zero means the timeout is not used. The default value is zero.- Parameters:
timeout- Timeout in milliseconds.
-
isStaleCheckingEnabled
Tests whether stale connection check is to be used. Disabling stale connection check may result in slight performance improvement at the risk of getting an I/O error when executing a request over a connection that has been closed at the server side.- Returns:
- true if stale connection check is to be used, false otherwise.
-
setStaleCheckingEnabled
Defines whether stale connection check is to be used. Disabling stale connection check may result in slight performance improvement at the risk of getting an I/O error when executing a request over a connection that has been closed at the server side.- Parameters:
value- true if stale connection check is to be used, false otherwise.
-