You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2005/03/24 23:47:47 UTC
svn commit: r158965 -
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/params/HttpConnectionParams.java
Author: olegk
Date: Thu Mar 24 14:47:46 2005
New Revision: 158965
URL: http://svn.apache.org/viewcvs?view=rev&rev=158965
Log:
HttpConnectionParams implements an adaptor around the HttpParams interface to simplify manipulation of the HTTP connection specific parameters
Added:
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/params/HttpConnectionParams.java
- copied, changed from r158959, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java
Copied: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/params/HttpConnectionParams.java (from r158959, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java)
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/params/HttpConnectionParams.java?view=diff&rev=158965&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java&r1=158959&p2=jakarta/httpclient/trunk/http-common/src/java/org/apache/http/params/HttpConnectionParams.java&r2=158965
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/params/HttpConnectionParams.java Thu Mar 24 14:47:46 2005
@@ -1,5 +1,5 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionParams.java,v 1.6 2004/09/15 20:32:21 olegk Exp $
+ * $HeadURL$
* $Revision$
* $Date$
*
@@ -27,22 +27,19 @@
*
*/
-package org.apache.commons.httpclient.params;
+package org.apache.http.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.
+ * This class implements an adaptor around the {@link HttpParams} interface
+ * to simplify manipulation of the HTTP connection specific parameters.
*
- * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
*
* @version $Revision$
*
* @since 3.0
*/
-public class HttpConnectionParams extends DefaultHttpParams {
+public class HttpConnectionParams {
/**
* Defines the default socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the
@@ -125,18 +122,63 @@
*/
public static final String STALE_CONNECTION_CHECK = "http.connection.stalecheck";
+ private final HttpParams params;
+
/**
- * 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() {
+ public HttpConnectionParams(final HttpParams params) {
super();
+ if (params == null) {
+ throw new IllegalArgumentException("HTTP parameters may not be null");
+ }
+ this.params = params;
+ }
+
+ public Object getParameter(final String name) {
+ return this.params.getParameter(name);
+ }
+
+ public HttpConnectionParams setParameter(final String name, final Object value) {
+ this.params.setParameter(name, value);
+ return this;
+ }
+
+ public long getLongParameter(final String name, long defaultValue) {
+ return this.params.getLongParameter(name, defaultValue);
+ }
+
+ public HttpConnectionParams setLongParameter(final String name, long value) {
+ this.params.setLongParameter(name, value);
+ return this;
+ }
+
+ public int getIntParameter(final String name, int defaultValue) {
+ return this.params.getIntParameter(name, defaultValue);
}
+ public HttpConnectionParams setIntParameter(final String name, int value) {
+ this.params.setIntParameter(name, value);
+ return this;
+ }
+
+ public double getDoubleParameter(final String name, double defaultValue) {
+ return this.params.getDoubleParameter(name, defaultValue);
+ }
+
+ public HttpConnectionParams setDoubleParameter(final String name, double value) {
+ this.params.setDoubleParameter(name, value);
+ return this;
+ }
+
+ public boolean getBooleanParameter(final String name, boolean defaultValue) {
+ return this.params.getBooleanParameter(name, defaultValue);
+ }
+
+ public HttpConnectionParams setBooleanParameter(final String name, boolean value) {
+ this.params.setBooleanParameter(name, value);
+ return this;
+ }
+
/**
* Returns the default 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
@@ -157,32 +199,32 @@
*
* @param timeout Timeout in milliseconds
*/
- public void setSoTimeout(int timeout) {
- setIntParameter(SO_TIMEOUT, timeout);
+ public HttpConnectionParams setSoTimeout(int timeout) {
+ return 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.
+ * Tests if Nagle's algorithm is to be used.
*
- * @param value <tt>true</tt> if the Nagle's algorithm is to NOT 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 void setTcpNoDelay(boolean value) {
- setBooleanParameter(TCP_NODELAY, value);
+ public boolean getTcpNoDelay() {
+ return getBooleanParameter(TCP_NODELAY, true);
}
/**
- * Tests if Nagle's algorithm is to be used.
+ * 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.
*
- * @return <tt>true</tt> if the Nagle's algorithm is to NOT be used
+ * @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 boolean getTcpNoDelay() {
- return getBooleanParameter(TCP_NODELAY, true);
+ public HttpConnectionParams setTcpNoDelay(boolean value) {
+ return setBooleanParameter(TCP_NODELAY, value);
}
/**
@@ -205,8 +247,8 @@
*
* @param size the hint size of the send buffer
*/
- public void setSendBufferSize(int size) {
- setIntParameter(SO_SNDBUF, size);
+ public HttpConnectionParams setSendBufferSize(int size) {
+ return setIntParameter(SO_SNDBUF, size);
}
/**
@@ -229,8 +271,8 @@
*
* @param size the hint size of the send buffer
*/
- public void setReceiveBufferSize(int size) {
- setIntParameter(SO_RCVBUF, size);
+ public HttpConnectionParams setReceiveBufferSize(int size) {
+ return setIntParameter(SO_RCVBUF, size);
}
/**
@@ -253,8 +295,8 @@
*
* @param value the linger-on-close timeout
*/
- public void setLinger(int value) {
- setIntParameter(SO_LINGER, value);
+ public HttpConnectionParams setLinger(int value) {
+ return setIntParameter(SO_LINGER, value);
}
/**
@@ -273,8 +315,8 @@
*
* @param timeout Timeout in milliseconds.
*/
- public void setConnectionTimeout(int timeout) {
- setIntParameter(CONNECTION_TIMEOUT, timeout);
+ public HttpConnectionParams setConnectionTimeout(int timeout) {
+ return setIntParameter(CONNECTION_TIMEOUT, timeout);
}
/**
@@ -299,7 +341,7 @@
* @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);
+ public HttpConnectionParams setStaleCheckingEnabled(boolean value) {
+ return setBooleanParameter(STALE_CONNECTION_CHECK, value);
}
}