You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2003/10/22 21:35:34 UTC
cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params HttpConnectionManagerParams.java HttpConnectionParams.java
olegk 2003/10/22 12:35:34
Added: httpclient/src/java/org/apache/commons/httpclient/params
HttpConnectionManagerParams.java
HttpConnectionParams.java
Log:
PR #15435 (New Preferences Architecture)
- HttpConnection & HttpConnectionManager classes updated to take advantage of
the new preference architecute.
Contributed by Oleg Kalnichevski
Reviewed by Michael Becke
Revision Changes Path
1.1 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java
Index: HttpConnectionManagerParams.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java,v 1.1 2003/10/22 19:35:33 olegk Exp $
* $Revision: 1.1 $
* $Date: 2003/10/22 19:35:33 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.commons.httpclient.params;
/**
* This class represents a collection of HTTP protocol parameters applicable to
* {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection managers}.
* Protocol parameters may be linked together to form a hierarchy. If a particular
* parameter value has not been explicitly defined in the collection itself, its
* value will be drawn from the parent collection of parameters.
*
* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
*
* @version $Revision: 1.1 $
*/
public class HttpConnectionManagerParams extends HttpConnectionParams {
}
1.1 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java
Index: HttpConnectionParams.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java,v 1.1 2003/10/22 19:35:33 olegk Exp $
* $Revision: 1.1 $
* $Date: 2003/10/22 19:35:33 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.commons.httpclient.params;
/**
* This class represents a collection of HTTP protocol parameters applicable to
* {@link org.apache.commons.httpclient.HttpConnection HTTP connections}.
* Protocol parameters may be linked together to form a hierarchy. If a particular
* parameter value has not been explicitly defined in the collection itself, its
* value will be drawn from the parent collection of parameters.
*
* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
*
* @version $Revision: 1.1 $
*/
public class HttpConnectionParams extends DefaultHttpParams {
/**
* Sets the socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the
* timeout for waiting for data. A timeout value of zero is interpreted as an
* infinite timeout.
* <p>
* This parameter expects a value of type {@link Integer}.
* </p>
* @see java.net.SocketOptions#SO_TIMEOUT
*/
public static final String SO_TIMEOUT = "http.socket.timeout";
/**
* 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.
* <p>
* This parameter expects a value of type {@link Boolean}.
* </p>
* @see java.net.SocketOptions#TCP_NODELAY
*/
public static final String TCP_NODELAY = "http.tcp.nodelay";
/**
* Determines a hint the size of the underlying buffers used by the platform
* for outgoing network I/O. This value is a suggestion to the kernel from
* the application about the size of buffers to use for the data to be sent
* over the socket.
* <p>
* This parameter expects a value of type {@link Integer}.
* </p>
* @see java.net.SocketOptions#SO_SNDBUF
*/
public static final String SO_SNDBUF = "http.socket.sendbuffer";
/**
* Determines a hint the size of the underlying buffers used by the platform
* for incoming network I/O. This value is a suggestion to the kernel from
* the application about the size of buffers to use for the data to be received
* over the socket.
* <p>
* This parameter expects a value of type {@link Integer}.
* </p>
* @see java.net.SocketOptions#SO_RCVBUF
*/
public static final String SO_RCVBUF = "http.socket.receivebuffer";
/**
* Determines the timeout until a connection is etablished. A value of zero
* means the timeout is not used. The default value is zero.
* <p>
* This parameter expects a value of type {@link Integer}.
* </p>
*/
public static final String CONNECTION_TIMEOUT = "http.connection.timeout";
/**
* Determines 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.
* <p>
* This parameter expects a value of type {@link Boolean}.
* </p>
*/
public static final String STALE_CONNECTION_CHECK = "http.connection.stalecheck";
/**
* Creates a new collection of parameters with the collection returned
* by {@link #getDefaultParams()} as a parent. The collection will defer
* to its parent for a default value if a particular parameter is not
* explicitly set in the collection itself.
*
* @see #getDefaultParams()
*/
public HttpConnectionParams() {
super();
}
/**
* Returns the socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the
* timeout for waiting for data. A timeout value of zero is interpreted as an
* infinite timeout.
*
* @return timeout in milliseconds
*/
public int getSoTimeout() {
return getIntParameter(SO_TIMEOUT, 0);
}
/**
* Sets the socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the
* timeout for waiting for data. A timeout value of zero is interpreted as an
* infinite timeout.
*
* @param timeout Timeout in milliseconds
*/
public void setSoTimeout(int timeout) {
setIntParameter(SO_TIMEOUT, timeout);
}
/**
* 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.
*
* @param value <tt>true</tt> if the Nagle's algorithm is to NOT be used
* (that is enable TCP_NODELAY), <tt>false</tt> otherwise.
*/
public void setTcpNoDelay(boolean value) {
setBooleanParameter(TCP_NODELAY, value);
}
/**
* Tests if Nagle's algorithm is to be used.
*
* @return <tt>true</tt> if the Nagle's algorithm is to NOT be used
* (that is enable TCP_NODELAY), <tt>false</tt> otherwise.
*/
public boolean getTcpNoDelay() {
return getBooleanParameter(TCP_NODELAY, true);
}
/**
* Returns a hint the size of the underlying buffers used by the platform for
* outgoing network I/O. This value is a suggestion to the kernel from the
* application about the size of buffers to use for the data to be sent over
* the socket.
*
* @return the hint size of the send buffer
*/
public int getSendBufferSize() {
return getIntParameter(SO_SNDBUF, -1);
}
/**
* Sets a hint the size of the underlying buffers used by the platform for
* outgoing network I/O. This value is a suggestion to the kernel from the
* application about the size of buffers to use for the data to be sent over
* the socket.
*
* @param size the hint size of the send buffer
*/
public void setSendBufferSize(int size) {
setIntParameter(SO_SNDBUF, size);
}
/**
* Returns a hint the size of the underlying buffers used by the platform
* for incoming network I/O. This value is a suggestion to the kernel from
* the application about the size of buffers to use for the data to be received
* over the socket.
*
* @return the hint size of the send buffer
*/
public int getReceiveBufferSize() {
return getIntParameter(SO_RCVBUF, -1);
}
/**
* Sets a hint the size of the underlying buffers used by the platform
* for incoming network I/O. This value is a suggestion to the kernel from
* the application about the size of buffers to use for the data to be received
* over the socket.
*
* @param size the hint size of the send buffer
*/
public void setReceiveBufferSize(int size) {
setIntParameter(SO_RCVBUF, size);
}
/**
* Returns the timeout until a connection is etablished. A value of zero
* means the timeout is not used. The default value is zero.
*
* @return timeout in milliseconds.
*/
public int getConnectionTimeout() {
return getIntParameter(CONNECTION_TIMEOUT, 0);
}
/**
* Sets the timeout until a connection is etablished. A value of zero
* means the timeout is not used. The default value is zero.
*
* @param timeout Timeout in milliseconds.
*/
public void setConnectionTimeout(int timeout) {
setIntParameter(CONNECTION_TIMEOUT, timeout);
}
/**
* 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.
*
* @return <tt>true</tt> if stale connection check is to be used,
* <tt>false</tt> otherwise.
*/
public boolean isStaleCheckingEnabled() {
return getBooleanParameter(STALE_CONNECTION_CHECK, true);
}
/**
* 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.
*
* @param value <tt>true</tt> if stale connection check is to be used,
* <tt>false</tt> otherwise.
*/
public void setStaleCheckingEnabled(boolean value) {
setBooleanParameter(STALE_CONNECTION_CHECK, value);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org