diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/.classpath commons-httpclient/.classpath --- commons-httpclient.orig/.classpath Wed Jan 4 05:45:14 2006 +++ commons-httpclient/.classpath Tue Jan 3 21:57:57 2006 @@ -1,6 +1,10 @@ - + + + + + diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/.project commons-httpclient/.project --- commons-httpclient.orig/.project Wed Jan 4 05:45:14 2006 +++ commons-httpclient/.project Tue Jan 3 01:44:55 2006 @@ -1,6 +1,6 @@ - commons-httpclient.orig + commons-httpclient diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/build.xml commons-httpclient/build.xml --- commons-httpclient.orig/build.xml Mon Dec 19 05:29:32 2005 +++ commons-httpclient/build.xml Wed Jan 4 06:55:54 2006 @@ -9,6 +9,13 @@ author: Mark Paquette ( mailto:mpaquett@covansys.com ) author: Jeff Dever ( mailto:jsdever@apache.org ) author: Oleg Kalnichevski ( mailto:oleg@ural.ru ) + + "Forked" by: Jens Elkner + - removed all deprecated stuff + - type safety using tiger features + - removed JVM < 1.5 backward compat (i.e. unused) stuff + - fixed uneccessary nested stuff (cosmetics) + - SO FINALLY YES: It does not run with a JVM < 1.5 ;-) --> @@ -16,18 +23,22 @@ + + + + - + - + @@ -59,8 +70,8 @@ - - + + @@ -149,6 +160,7 @@ @@ -159,9 +171,6 @@ - - - @@ -170,6 +179,9 @@ description="Clean build and distribution directories"> + + + + + @@ -200,9 +216,11 @@ + @@ -217,7 +235,7 @@ - + @@ -225,11 +243,11 @@ - - + @@ -238,9 +256,9 @@ description="Create component Javadoc documentation"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/methods/multipart/ContentType.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/methods/multipart/ContentType.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/methods/multipart/ContentType.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/methods/multipart/ContentType.java Tue Jan 3 20:07:36 2006 @@ -183,6 +183,7 @@ /** The constructor is intentionally private as the class only provides static methods. */ private ContentType() { + // singleton } /** @@ -221,9 +222,6 @@ * * @return the content type for the file or null if no mapping was * possible. - * - * @throws IOException if the construction of the canonical path for - * the file fails. */ public static String get(File file) { String contentType = null; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java Sat Jul 23 12:36:30 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyTestApplet.java Tue Jan 3 02:05:43 2006 @@ -43,6 +43,7 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import org.apache.commons.httpclient.ProxyHost; @@ -118,17 +119,17 @@ private JLabel getHeaderLabel(String text) { JLabel result = new JLabel("" + text + ""); - result.setHorizontalAlignment(JLabel.CENTER); + result.setHorizontalAlignment(SwingConstants.CENTER); return result; } private JLabel getLabel(String text) { JLabel result = new JLabel(text); - result.setHorizontalAlignment(JLabel.CENTER); + result.setHorizontalAlignment(SwingConstants.CENTER); return result; } - private void detectProxy() { + void detectProxy() { String urlString = urlTextField.getText(); if (urlString == null || "".equals(urlString)) { JOptionPane.showMessageDialog(super.getRootPane(), diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java Tue Jul 19 23:16:56 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/proxy/PluginProxyUtil.java Tue Jan 3 20:08:15 2006 @@ -32,10 +32,9 @@ import java.lang.reflect.Method; import java.net.URL; import java.util.Properties; - import org.apache.commons.httpclient.ProxyHost; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A utility class that gives applets the ability to detect proxy host settings. @@ -63,7 +62,8 @@ public class PluginProxyUtil { /** Log object for this class */ - private static final Log LOG = LogFactory.getLog(PluginProxyUtil.class); + private static final Logger LOG = LoggerFactory + .getLogger(PluginProxyUtil.class); /** * This is used internally to indicate that no proxy detection succeeded @@ -140,10 +140,8 @@ * * @param sampleURL the URL to check proxy settings for * @return ProxyHost the host and port of the proxy that should be used - * @throws ProxyDetectionException if detection failed */ private static ProxyHost detectProxySettingsJDK13(URL sampleURL) - throws ProxyDetectionException { ProxyHost result = null; try { @@ -152,10 +150,9 @@ Class pluginProxyHandler = Class.forName("sun.plugin.protocol.PluginProxyHandler"); Method getDefaultProxyHandlerMethod = - pluginProxyHandler.getDeclaredMethod("getDefaultProxyHandler", - null); + pluginProxyHandler.getDeclaredMethod("getDefaultProxyHandler"); Object proxyHandlerObj = - getDefaultProxyHandlerMethod.invoke(null, null); + getDefaultProxyHandlerMethod.invoke(null); if (proxyHandlerObj != null) { Class proxyHandlerClass = proxyHandlerObj.getClass(); Method getProxyInfoMethod = @@ -167,16 +164,16 @@ if (proxyInfoObject != null) { Class proxyInfoClass = proxyInfoObject.getClass(); Method getProxyMethod = - proxyInfoClass.getDeclaredMethod("getProxy", null); + proxyInfoClass.getDeclaredMethod("getProxy"); boolean useProxy = - (getProxyMethod.invoke(proxyInfoObject, null) != null); + (getProxyMethod.invoke(proxyInfoObject) != null); if (useProxy) { String proxyIP = - (String)getProxyMethod.invoke(proxyInfoObject, null); + (String)getProxyMethod.invoke(proxyInfoObject); Method getProxyPortMethod = - proxyInfoClass.getDeclaredMethod("getPort", null); + proxyInfoClass.getDeclaredMethod("getPort"); Integer portInteger = - (Integer)getProxyPortMethod.invoke(proxyInfoObject, null); + (Integer)getProxyPortMethod.invoke(proxyInfoObject); int proxyPort = portInteger.intValue(); if (LOG.isDebugEnabled()) { LOG.debug("1.3.X: proxy=" + proxyIP+ @@ -242,13 +239,13 @@ Object proxyInfoObject = Array.get(proxyInfoArrayObj, 0); Class proxyInfoClass = proxyInfoObject.getClass(); Method getHostMethod = - proxyInfoClass.getDeclaredMethod("getHost",null); + proxyInfoClass.getDeclaredMethod("getHost"); String proxyIP = - (String)getHostMethod.invoke(proxyInfoObject, null); + (String)getHostMethod.invoke(proxyInfoObject); Method getPortMethod = - proxyInfoClass.getDeclaredMethod("getPort",null); + proxyInfoClass.getDeclaredMethod("getPort"); Integer portInteger = - (Integer)getPortMethod.invoke(proxyInfoObject, null); + (Integer)getPortMethod.invoke(proxyInfoObject); int proxyPort = portInteger.intValue(); if (LOG.isDebugEnabled()) { LOG.debug("1.4.X Proxy info geProxy:"+proxyIP+ diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java Tue Jul 19 23:16:56 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/proxy/ProxyDetectionException.java Tue Jan 3 18:42:41 2006 @@ -28,7 +28,6 @@ */ package org.apache.commons.httpclient.contrib.proxy; -import org.apache.commons.httpclient.util.ExceptionUtil; /** * Signals a problem with auto-detecting the proxy information using the java @@ -69,7 +68,7 @@ */ public ProxyDetectionException(String message, Throwable cause) { super(message); - ExceptionUtil.initCause(this, cause); + initCause(cause); } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java Tue Jan 3 02:34:53 2006 @@ -43,20 +43,18 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Enumeration; - +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.sun.net.ssl.KeyManager; -import com.sun.net.ssl.KeyManagerFactory; -import com.sun.net.ssl.SSLContext; -import com.sun.net.ssl.TrustManager; -import com.sun.net.ssl.TrustManagerFactory; -import com.sun.net.ssl.X509TrustManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

@@ -173,7 +171,8 @@ public class AuthSSLProtocolSocketFactory implements SecureProtocolSocketFactory { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(AuthSSLProtocolSocketFactory.class); + private static final Logger LOG = LoggerFactory + .getLogger(AuthSSLProtocolSocketFactory.class); private URL keystoreUrl = null; private String keystorePassword = null; @@ -334,8 +333,8 @@ * * @param host the host name/IP * @param port the port on the host - * @param clientHost the local host name/IP to bind the socket to - * @param clientPort the port on the local machine + * @param localAddress the local host name/IP to bind the socket to + * @param localPort the port on the local machine * @param params {@link HttpConnectionParams Http connection parameters} * * @return Socket a new socket @@ -343,6 +342,7 @@ * @throws IOException if an I/O error occurs while creating the socket * @throws UnknownHostException if the IP address of the host cannot be * determined + * @throws ConnectTimeoutException */ public Socket createSocket( final String host, @@ -357,11 +357,10 @@ int timeout = params.getConnectionTimeout(); if (timeout == 0) { return createSocket(host, port, localAddress, localPort); - } else { + } // To be eventually deprecated when migrated to Java 1.4 or above return ControllerThreadSocketFactory.createSocket( this, host, port, localAddress, localPort, timeout); - } } /** diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLX509TrustManager.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLX509TrustManager.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLX509TrustManager.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLX509TrustManager.java Tue Jan 3 02:34:12 2006 @@ -30,10 +30,9 @@ package org.apache.commons.httpclient.contrib.ssl; import java.security.cert.X509Certificate; - -import com.sun.net.ssl.X509TrustManager; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import javax.net.ssl.X509TrustManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

@@ -55,10 +54,12 @@ private X509TrustManager defaultTrustManager = null; /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(AuthSSLX509TrustManager.class); + private static final Logger LOG = LoggerFactory + .getLogger(AuthSSLX509TrustManager.class); /** * Constructor for AuthSSLX509TrustManager. + * @param defaultTrustManager */ public AuthSSLX509TrustManager(final X509TrustManager defaultTrustManager) { super(); @@ -69,9 +70,11 @@ } /** - * @see com.sun.net.ssl.X509TrustManager#isClientTrusted(X509Certificate[]) + * @throws java.security.cert.CertificateException + * @see X509TrustManager#checkClientTrusted(java.security.cert.X509Certificate[], java.lang.String) */ - public boolean isClientTrusted(X509Certificate[] certificates) { + public void checkClientTrusted(X509Certificate[] certificates, String authType) throws java.security.cert.CertificateException + { if (LOG.isInfoEnabled() && certificates != null) { for (int c = 0; c < certificates.length; c++) { X509Certificate cert = certificates[c]; @@ -83,13 +86,15 @@ LOG.info(" Issuer: " + cert.getIssuerDN()); } } - return this.defaultTrustManager.isClientTrusted(certificates); + this.defaultTrustManager.checkClientTrusted(certificates, authType); } /** - * @see com.sun.net.ssl.X509TrustManager#isServerTrusted(X509Certificate[]) + * {@inheritDoc} */ - public boolean isServerTrusted(X509Certificate[] certificates) { + public void checkServerTrusted(X509Certificate[] certificates, String authType) + throws java.security.cert.CertificateException + { if (LOG.isInfoEnabled() && certificates != null) { for (int c = 0; c < certificates.length; c++) { X509Certificate cert = certificates[c]; @@ -101,11 +106,11 @@ LOG.info(" Issuer: " + cert.getIssuerDN()); } } - return this.defaultTrustManager.isServerTrusted(certificates); + this.defaultTrustManager.checkServerTrusted(certificates, authType); } /** - * @see com.sun.net.ssl.X509TrustManager#getAcceptedIssuers() + * {@inheritDoc} */ public X509Certificate[] getAcceptedIssuers() { return this.defaultTrustManager.getAcceptedIssuers(); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java Tue Jan 3 02:21:55 2006 @@ -33,17 +33,15 @@ import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; - +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.HttpClientError; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.sun.net.ssl.SSLContext; -import com.sun.net.ssl.TrustManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

@@ -93,7 +91,8 @@ public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(EasySSLProtocolSocketFactory.class); + private static final Logger LOG = LoggerFactory + .getLogger(EasySSLProtocolSocketFactory.class); private SSLContext sslcontext = null; @@ -154,8 +153,8 @@ * * @param host the host name/IP * @param port the port on the host - * @param clientHost the local host name/IP to bind the socket to - * @param clientPort the port on the local machine + * @param localAddress the local host name/IP to bind the socket to + * @param localPort the port on the local machine * @param params {@link HttpConnectionParams Http connection parameters} * * @return Socket a new socket @@ -163,6 +162,7 @@ * @throws IOException if an I/O error occurs while creating the socket * @throws UnknownHostException if the IP address of the host cannot be * determined + * @throws ConnectTimeoutException */ public Socket createSocket( final String host, @@ -177,12 +177,11 @@ int timeout = params.getConnectionTimeout(); if (timeout == 0) { return createSocket(host, port, localAddress, localPort); - } else { + } // To be eventually deprecated when migrated to Java 1.4 or above return ControllerThreadSocketFactory.createSocket( this, host, port, localAddress, localPort, timeout); } - } /** * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) @@ -212,10 +211,18 @@ ); } + /** + * {@inheritDoc} + */ + @Override public boolean equals(Object obj) { return ((obj != null) && obj.getClass().equals(EasySSLProtocolSocketFactory.class)); } + /** + * {@inheritDoc} + */ + @Override public int hashCode() { return EasySSLProtocolSocketFactory.class.hashCode(); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java Tue Jan 3 02:29:11 2006 @@ -30,12 +30,12 @@ import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import com.sun.net.ssl.TrustManagerFactory; -import com.sun.net.ssl.TrustManager; -import com.sun.net.ssl.X509TrustManager; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** *

@@ -64,10 +64,14 @@ private X509TrustManager standardTrustManager = null; /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(EasyX509TrustManager.class); + private static final Logger LOG = LoggerFactory + .getLogger(EasyX509TrustManager.class); /** * Constructor for EasyX509TrustManager. + * @param keystore + * @throws NoSuchAlgorithmException + * @throws KeyStoreException */ public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super(); @@ -81,16 +85,20 @@ } /** - * @see com.sun.net.ssl.X509TrustManager#isClientTrusted(X509Certificate[]) + * {@inheritDoc} */ - public boolean isClientTrusted(X509Certificate[] certificates) { - return this.standardTrustManager.isClientTrusted(certificates); + public void checkClientTrusted(X509Certificate[] certificates, String authType) + throws CertificateException + { + this.standardTrustManager.checkClientTrusted(certificates, authType); } /** - * @see com.sun.net.ssl.X509TrustManager#isServerTrusted(X509Certificate[]) + * {@inheritDoc} */ - public boolean isServerTrusted(X509Certificate[] certificates) { + public void checkServerTrusted(X509Certificate[] certificates, String authType) + throws CertificateException + { if ((certificates != null) && LOG.isDebugEnabled()) { LOG.debug("Server certificate chain:"); for (int i = 0; i < certificates.length; i++) { @@ -104,16 +112,14 @@ } catch (CertificateException e) { LOG.error(e.toString()); - return false; } - return true; } else { - return this.standardTrustManager.isServerTrusted(certificates); + this.standardTrustManager.checkServerTrusted(certificates, authType); } } /** - * @see com.sun.net.ssl.X509TrustManager#getAcceptedIssuers() + * {@inheritDoc} */ public X509Certificate[] getAcceptedIssuers() { return this.standardTrustManager.getAcceptedIssuers(); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/StrictSSLProtocolSocketFactory.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/StrictSSLProtocolSocketFactory.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/ssl/StrictSSLProtocolSocketFactory.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/StrictSSLProtocolSocketFactory.java Tue Jan 3 02:37:47 2006 @@ -47,20 +47,18 @@ import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; - import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.security.cert.X509Certificate; - import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory; import org.apache.commons.httpclient.protocol.ReflectionSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -83,8 +81,8 @@ implements SecureProtocolSocketFactory { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(StrictSSLProtocolSocketFactory.class); - + private static final Logger LOG = LoggerFactory + .getLogger(StrictSSLProtocolSocketFactory.class); /** Host name verify flag. */ private boolean verifyHostname = true; @@ -178,8 +176,8 @@ * * @param host the host name/IP * @param port the port on the host - * @param clientHost the local host name/IP to bind the socket to - * @param clientPort the port on the local machine + * @param localAddress the local host name/IP to bind the socket to + * @param localPort the port on the local machine * @param params {@link HttpConnectionParams Http connection parameters} * * @return Socket a new socket @@ -187,6 +185,7 @@ * @throws IOException if an I/O error occurs while creating the socket * @throws UnknownHostException if the IP address of the host cannot be * determined + * @throws ConnectTimeoutException */ public Socket createSocket( final String host, @@ -201,7 +200,7 @@ int timeout = params.getConnectionTimeout(); if (timeout == 0) { return createSocket(host, port, localAddress, localPort); - } else { + } // To be eventually deprecated when migrated to Java 1.4 or above SSLSocket sslSocket = (SSLSocket) ReflectionSocketFactory.createSocket( "javax.net.ssl.SSLSocketFactory", host, port, localAddress, localPort, timeout); @@ -212,7 +211,6 @@ verifyHostname(sslSocket); return sslSocket; } - } /** * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) @@ -260,7 +258,7 @@ SSLSession session = socket.getSession(); String hostname = session.getPeerHost(); try { - InetAddress addr = InetAddress.getByName(hostname); + InetAddress.getByName(hostname); } catch (UnknownHostException uhe) { throw new UnknownHostException("Could not resolve SSL sessions " + "server hostname: " + hostname); @@ -321,15 +319,22 @@ return dn.substring(0, i); } + /** + * {@inheritDoc} + */ + @Override public boolean equals(Object obj) { if ((obj != null) && obj.getClass().equals(StrictSSLProtocolSocketFactory.class)) { return ((StrictSSLProtocolSocketFactory) obj).getHostnameVerification() == this.verifyHostname; - } else { - return false; } + return false; } + /** + * {@inheritDoc} + */ + @Override public int hashCode() { return StrictSSLProtocolSocketFactory.class.hashCode(); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/utils/HttpMethodCloner.java commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/utils/HttpMethodCloner.java --- commons-httpclient.orig/src/contrib/org/apache/commons/httpclient/contrib/utils/HttpMethodCloner.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/contrib/org/apache/commons/httpclient/contrib/utils/HttpMethodCloner.java Thu Jan 1 01:00:00 1970 @@ -1,120 +0,0 @@ -/* - * ==================================================================== - * - * Copyright 2002-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - * [Additional notices, if required by prior licensing conditions] - * - */ - -package org.apache.commons.httpclient.contrib.utils; - -import org.apache.commons.httpclient.Header; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.HttpMethodBase; -import org.apache.commons.httpclient.methods.EntityEnclosingMethod; -import org.apache.commons.httpclient.params.HttpMethodParams; - -/** - * In this class are only methods to copy a HttpMethod: - * PUT, GET, POST,DELETE, TRACE, ... - * - * @author Thomas Mathis - * - * @deprecated - * - * DISCLAIMER: HttpClient developers DO NOT actively support this component. - * The component is provided as a reference material, which may be inappropriate - * to be used without additional customization. - */ - -public class HttpMethodCloner { - - private static void copyEntityEnclosingMethod( - EntityEnclosingMethod m, EntityEnclosingMethod copy ) - throws java.io.IOException - { - copy.setRequestEntity(m.getRequestEntity()); - } - - private static void copyHttpMethodBase( - HttpMethodBase m, HttpMethodBase copy) { - try { - copy.setParams((HttpMethodParams)m.getParams().clone()); - } catch (CloneNotSupportedException e) { - // Should never happen - } - } - - /** - * Clones a HttpMethod.
- * Attention: You have to clone a method before it has - * been executed, because the URI can change if followRedirects - * is set to true. - * - * @param m the HttpMethod to clone - * - * @return the cloned HttpMethod, null if the HttpMethod could - * not be instantiated - * - * @throws java.io.IOException if the request body couldn't be read - */ - public static HttpMethod clone(HttpMethod m) - throws java.io.IOException - { - HttpMethod copy = null; - - // copy the HttpMethod - try { - copy = (HttpMethod) m.getClass().newInstance(); - } catch (InstantiationException iEx) { - } catch (IllegalAccessException iaEx) { - } - if ( copy == null ) { - return null; - } - copy.setDoAuthentication(m.getDoAuthentication()); - copy.setFollowRedirects(m.getFollowRedirects()); - copy.setPath( m.getPath() ); - copy.setQueryString(m.getQueryString()); - - // clone the headers - Header[] h = m.getRequestHeaders(); - int size = (h == null) ? 0 : h.length; - - for (int i = 0; i < size; i++) { - copy.setRequestHeader( - new Header(h[i].getName(), h[i].getValue())); - } - copy.setStrictMode(m.isStrictMode()); - if (m instanceof HttpMethodBase) { - copyHttpMethodBase( - (HttpMethodBase)m, - (HttpMethodBase)copy); - } - if (m instanceof EntityEnclosingMethod) { - copyEntityEnclosingMethod( - (EntityEnclosingMethod)m, - (EntityEnclosingMethod)copy); - } - return copy; - } -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/AlternateAuthenticationExample.java commons-httpclient/src/examples/AlternateAuthenticationExample.java --- commons-httpclient.orig/src/examples/AlternateAuthenticationExample.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/AlternateAuthenticationExample.java Tue Jan 3 15:40:16 2006 @@ -58,6 +58,10 @@ super(); } + /** + * @param args + * @throws Exception + */ public static void main(String[] args) throws Exception { HttpClient client = new HttpClient(); client.getState().setCredentials( @@ -68,7 +72,7 @@ // is used per default // This is to make HttpClient pick the Basic authentication scheme over NTLM & Digest - List authPrefs = new ArrayList(3); + List authPrefs = new ArrayList(3); authPrefs.add(AuthPolicy.BASIC); authPrefs.add(AuthPolicy.NTLM); authPrefs.add(AuthPolicy.DIGEST); @@ -77,7 +81,7 @@ GetMethod httpget = new GetMethod("http://myhost/protected/auth-required.html"); try { - int status = client.executeMethod(httpget); + client.executeMethod(httpget); // print the status and response System.out.println(httpget.getStatusLine()); System.out.println(httpget.getResponseBodyAsString()); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/BasicAuthenticationExample.java commons-httpclient/src/examples/BasicAuthenticationExample.java --- commons-httpclient.orig/src/examples/BasicAuthenticationExample.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/BasicAuthenticationExample.java Tue Jan 3 15:40:27 2006 @@ -50,6 +50,10 @@ super(); } + /** + * @param args + * @throws Exception + */ public static void main(String[] args) throws Exception { HttpClient client = new HttpClient(); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/ChunkEncodedPost.java commons-httpclient/src/examples/ChunkEncodedPost.java --- commons-httpclient.orig/src/examples/ChunkEncodedPost.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/ChunkEncodedPost.java Tue Jan 3 15:40:35 2006 @@ -41,7 +41,11 @@ */ public class ChunkEncodedPost { - public static void main(String[] args) throws Exception { + /** + * @param args + * @throws Exception + */ +public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("Usage: ChunkEncodedPost "); System.out.println(" - full path to a file to be posted"); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/ClientApp.java commons-httpclient/src/examples/ClientApp.java --- commons-httpclient.orig/src/examples/ClientApp.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/ClientApp.java Tue Jan 3 15:41:52 2006 @@ -65,12 +65,16 @@ */ public class ClientApp { + /** + * @param args + */ public static void main(String[] args) { HttpClientFrame f = new HttpClientFrame(); f.setTitle("HttpClient demo application"); f.setSize(700, 500); f.addWindowListener( new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { System.exit(0); } @@ -79,14 +83,19 @@ f.setVisible(true); } + /** + */ public static class HttpClientFrame extends JFrame { - private JComboBox cmbURL; + JComboBox cmbURL; private JTextArea taTextResponse; private JEditorPane htmlPane; - private HttpClient client; + HttpClient client; + /** + * + */ public HttpClientFrame() { client = new HttpClient(new MultiThreadedHttpConnectionManager()); client.getHttpConnectionManager(). @@ -155,7 +164,7 @@ * * @param content an HTML document */ - private void setDocumentContent(String content) { + void setDocumentContent(String content) { HTMLDocument doc = new HTMLDocument(); try { @@ -183,15 +192,16 @@ * Loads the page at the given URL from a separate thread. * @param url */ - private void loadPage(final String url) { + void loadPage(final String url) { // create a new thread to load the URL from new Thread() { + @Override public void run() { GetMethod get = new GetMethod(url); get.setFollowRedirects(true); try { - int iGetResultCode = client.executeMethod(get); + client.executeMethod(get); final String strGetResponseBody = get.getResponseBodyAsString(); if (strGetResponseBody != null) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/CookieDemoApp.java commons-httpclient/src/examples/CookieDemoApp.java --- commons-httpclient.orig/src/examples/CookieDemoApp.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/CookieDemoApp.java Tue Jan 3 15:42:05 2006 @@ -56,6 +56,7 @@ * * @param args command line arguments * Argument 0 is a URL to a web server + * @throws Exception * * */ diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/CustomAuthenticationExample.java commons-httpclient/src/examples/CustomAuthenticationExample.java --- commons-httpclient.orig/src/examples/CustomAuthenticationExample.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/CustomAuthenticationExample.java Tue Jan 3 20:07:06 2006 @@ -28,13 +28,10 @@ */ import java.util.ArrayList; import java.util.Collection; - import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.auth.AuthPolicy; import org.apache.commons.httpclient.auth.AuthScheme; -import org.apache.commons.httpclient.auth.AuthenticationException; -import org.apache.commons.httpclient.auth.MalformedChallengeException; import org.apache.commons.httpclient.params.DefaultHttpParams; import org.apache.commons.httpclient.params.HttpParams; @@ -45,6 +42,10 @@ */ public class CustomAuthenticationExample { + /** + * @param args + */ + @SuppressWarnings("unchecked") public static void main(String[] args) { // register the auth scheme @@ -69,41 +70,57 @@ */ private class SecretAuthScheme implements AuthScheme { + /** nae of the schee */ public static final String NAME = "Secret"; + /** + * Default constructor. + */ public SecretAuthScheme() { // All auth schemes must have a no arg constructor. } - public String authenticate(Credentials credentials, HttpMethod method) - throws AuthenticationException { - return "Open Sesame"; - } - public String authenticate(Credentials credentials, String method, - String uri) throws AuthenticationException { + /** + * {@inheritDoc} + */ + public String authenticate(Credentials credentials, HttpMethod method) { return "Open Sesame"; } - public String getID() { - return NAME; - } + /** + * {@inheritDoc} + */ public String getParameter(String name) { // this scheme does not use parameters, see RFC2617Scheme for an example return null; } + /** + * {@inheritDoc} + */ public String getRealm() { // this scheme does not use realms return null; } + /** + * {@inheritDoc} + */ public String getSchemeName() { return NAME; } + /** + * {@inheritDoc} + */ public boolean isConnectionBased() { return false; } - public void processChallenge(String challenge) - throws MalformedChallengeException { + /** + * {@inheritDoc} + */ + public void processChallenge(String challenge) { // Nothing to do here, this is not a challenge based // auth scheme. See NTLMScheme for a good example. } + /** + * {@inheritDoc} + */ public boolean isComplete() { // again we're not a challenge based scheme so this is always true return true; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/FormLoginDemo.java commons-httpclient/src/examples/FormLoginDemo.java --- commons-httpclient.orig/src/examples/FormLoginDemo.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/FormLoginDemo.java Tue Jan 3 15:45:51 2006 @@ -44,10 +44,17 @@ static final String LOGON_SITE = "developer.java.sun.com"; static final int LOGON_PORT = 80; + /** + * + */ public FormLoginDemo() { super(); } + /** + * @param args + * @throws Exception + */ public static void main(String[] args) throws Exception { HttpClient client = new HttpClient(); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/InteractiveAuthenticationExample.java commons-httpclient/src/examples/InteractiveAuthenticationExample.java --- commons-httpclient.orig/src/examples/InteractiveAuthenticationExample.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/InteractiveAuthenticationExample.java Tue Jan 3 15:46:29 2006 @@ -58,6 +58,10 @@ super(); } + /** + * @param args + * @throws Exception + */ public static void main(String[] args) throws Exception { InteractiveAuthenticationExample demo = new InteractiveAuthenticationExample(); @@ -73,7 +77,7 @@ httpget.setDoAuthentication(true); try { // execute the GET - int status = client.executeMethod(httpget); + client.executeMethod(httpget); // print the status and response System.out.println(httpget.getStatusLine().toString()); System.out.println(httpget.getResponseBodyAsString()); @@ -83,9 +87,14 @@ } } + /** + */ public class ConsoleAuthPrompter implements CredentialsProvider { private BufferedReader in = null; + /** + * + */ public ConsoleAuthPrompter() { super(); this.in = new BufferedReader(new InputStreamReader(System.in)); @@ -95,6 +104,9 @@ return this.in.readLine(); } + /** + * {@inheritDoc} + */ public Credentials getCredentials( final AuthScheme authscheme, final String host, diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/MultiThreadedExample.java commons-httpclient/src/examples/MultiThreadedExample.java --- commons-httpclient.orig/src/examples/MultiThreadedExample.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/MultiThreadedExample.java Tue Jan 3 15:47:41 2006 @@ -47,6 +47,9 @@ super(); } + /** + * @param args + */ public static void main(String[] args) { // Create an HttpClient with the MultiThreadedHttpConnectionManager. @@ -89,6 +92,11 @@ private GetMethod method; private int id; + /** + * @param httpClient + * @param method + * @param id + */ public GetThread(HttpClient httpClient, GetMethod method, int id) { this.httpClient = httpClient; this.method = method; @@ -98,6 +106,7 @@ /** * Executes the GetMethod and prints some satus information. */ + @Override public void run() { try { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/MultipartFileUploadApp.java commons-httpclient/src/examples/MultipartFileUploadApp.java --- commons-httpclient.orig/src/examples/MultipartFileUploadApp.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/MultipartFileUploadApp.java Tue Jan 3 15:47:24 2006 @@ -68,6 +68,9 @@ */ public class MultipartFileUploadApp { + /** + * @param args + */ public static void main(String[] args) { MultipartFileUploadFrame f = new MultipartFileUploadFrame(); @@ -75,6 +78,7 @@ f.pack(); f.addWindowListener( new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { System.exit(0); } @@ -83,12 +87,17 @@ f.setVisible(true); } + /** + */ public static class MultipartFileUploadFrame extends JFrame { - private File targetFile; + File targetFile; private JTextArea taTextResponse; - private DefaultComboBoxModel cmbURLModel; + DefaultComboBoxModel cmbURLModel; + /** + * + */ public MultipartFileUploadFrame() { String[] aURLs = { "http://localhost:8080/httpclienttest/fileupload" @@ -256,7 +265,7 @@ getContentPane().add(new JScrollPane(taTextResponse), c); } - private void appendMessage(String m) { + void appendMessage(String m) { taTextResponse.append(m + "\n"); } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/PostXML.java commons-httpclient/src/examples/PostXML.java --- commons-httpclient.orig/src/examples/PostXML.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/PostXML.java Tue Jan 3 15:47:50 2006 @@ -57,6 +57,7 @@ * @param args command line arguments * Argument 0 is a URL to a web server * Argument 1 is a local filename + * @throws Exception * */ public static void main(String[] args) throws Exception { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/ProxyTunnelDemo.java commons-httpclient/src/examples/ProxyTunnelDemo.java --- commons-httpclient.orig/src/examples/ProxyTunnelDemo.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/ProxyTunnelDemo.java Tue Jan 3 15:48:01 2006 @@ -46,6 +46,10 @@ */ public class ProxyTunnelDemo { + /** + * @param args + * @throws Exception + */ public static void main(String[] args) throws Exception { ProxyClient proxyclient = new ProxyClient(); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/TrivialApp.java commons-httpclient/src/examples/TrivialApp.java --- commons-httpclient.orig/src/examples/TrivialApp.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/TrivialApp.java Tue Jan 3 15:48:10 2006 @@ -63,6 +63,9 @@ System.out.println(); } + /** + * @param args + */ public static void main(String[] args) { if ((args.length != 1) && (args.length != 3)) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/examples/UnbufferedPost.java commons-httpclient/src/examples/UnbufferedPost.java --- commons-httpclient.orig/src/examples/UnbufferedPost.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/examples/UnbufferedPost.java Tue Jan 3 15:48:25 2006 @@ -41,7 +41,11 @@ */ public class UnbufferedPost { - public static void main(String[] args) throws Exception { + /** + * @param args + * @throws Exception + */ +public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("Usage: ChunkEncodedPost "); System.out.println(" - full path to a file to be posted"); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/AutoCloseInputStream.java commons-httpclient/src/java/org/apache/commons/httpclient/AutoCloseInputStream.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/AutoCloseInputStream.java Fri Sep 23 20:13:25 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/AutoCloseInputStream.java Tue Jan 3 04:59:27 2006 @@ -79,6 +79,7 @@ * @throws IOException when there is an error reading * @return the character read, or -1 for EOF */ + @Override public int read() throws IOException { int l = -1; @@ -100,6 +101,7 @@ * @return the number of bytes read or -1 for EOF * @throws IOException if there are errors reading */ + @Override public int read(byte[] b, int off, int len) throws IOException { int l = -1; @@ -119,6 +121,7 @@ * @return the number of bytes read or -1 for EOF * @throws IOException if there are errors reading */ + @Override public int read(byte[] b) throws IOException { int l = -1; @@ -134,6 +137,7 @@ * already closed. * @throws IOException If an IO problem occurs. */ + @Override public void close() throws IOException { if (!selfClosed) { selfClosed = true; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/ChunkedInputStream.java commons-httpclient/src/java/org/apache/commons/httpclient/ChunkedInputStream.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/ChunkedInputStream.java Fri Sep 23 20:13:25 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/ChunkedInputStream.java Tue Jan 3 18:40:56 2006 @@ -32,11 +32,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; - import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.httpclient.util.ExceptionUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -83,7 +81,8 @@ private HttpMethod method = null; /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(ChunkedInputStream.class); + private static final Logger LOG = LoggerFactory + .getLogger(ChunkedInputStream.class); /** * ChunkedInputStream constructor that associates the chunked input stream with a @@ -94,11 +93,9 @@ * * @param in the raw input stream * @param method the HTTP method to associate this input stream with. Can be null. - * - * @throws IOException If an IO error occurs */ public ChunkedInputStream( - final InputStream in, final HttpMethod method) throws IOException { + final InputStream in, final HttpMethod method) { if (in == null) { throw new IllegalArgumentException("InputStream parameter may not be null"); @@ -112,10 +109,8 @@ * ChunkedInputStream constructor * * @param in the raw input stream - * - * @throws IOException If an IO error occurs */ - public ChunkedInputStream(final InputStream in) throws IOException { + public ChunkedInputStream(final InputStream in) { this(in, null); } @@ -133,6 +128,7 @@ * * @see HttpMethod#getResponseFooters() */ + @Override public int read() throws IOException { if (closed) { @@ -162,6 +158,7 @@ * @see java.io.InputStream#read(byte[], int, int) * @throws IOException if an IO problem occurs. */ + @Override public int read (byte[] b, int off, int len) throws IOException { if (closed) { @@ -191,6 +188,7 @@ * @see java.io.InputStream#read(byte[]) * @throws IOException if an IO problem occurs. */ + @Override public int read (byte[] b) throws IOException { return read(b, 0, b.length); } @@ -322,7 +320,7 @@ } catch(HttpException e) { LOG.error("Error parsing trailer headers", e); IOException ioe = new IOException(e.getMessage()); - ExceptionUtil.initCause(ioe, e); + ioe.initCause(e); throw ioe; } if (this.method != null) { @@ -338,6 +336,7 @@ * next response without scanning. * @throws IOException If an IO problem occurs. */ + @Override public void close() throws IOException { if (!closed) { try { @@ -366,7 +365,7 @@ // read and discard the remainder of the message byte buffer[] = new byte[1024]; while (inStream.read(buffer) >= 0) { - ; + // do nothing } } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java commons-httpclient/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java Thu Jul 21 22:29:45 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/ChunkedOutputStream.java Tue Jan 3 05:02:42 2006 @@ -65,11 +65,9 @@ * Wraps a stream and chunks the output. * @param stream to wrap * @param bufferSize minimum chunk size (excluding last chunk) - * @throws IOException - * * @since 3.0 */ - public ChunkedOutputStream(OutputStream stream, int bufferSize) throws IOException { + public ChunkedOutputStream(OutputStream stream, int bufferSize) { this.cache = new byte[bufferSize]; this.stream = stream; } @@ -78,9 +76,8 @@ * Wraps a stream and chunks the output. The default buffer size of 2048 was chosen because * the chunk overhead is less than 0.5% * @param stream - * @throws IOException */ - public ChunkedOutputStream(OutputStream stream) throws IOException { + public ChunkedOutputStream(OutputStream stream) { this(stream, 2048); } @@ -122,6 +119,9 @@ cachePosition = 0; } + /** + * @throws IOException + */ protected void writeClosingChunk() throws IOException { // Write the final chunk. @@ -155,6 +155,7 @@ * @param b The byte to be written * @throws IOException if an input/output error occurs */ + @Override public void write(int b) throws IOException { cache[cachePosition] = (byte) b; cachePosition++; @@ -169,10 +170,15 @@ * * @since 3.0 */ + @Override public void write(byte b[]) throws IOException { this.write(b, 0, b.length); } + /** + * {@inheritDoc} + */ + @Override public void write(byte src[], int off, int len) throws IOException { if (len >= cache.length - cachePosition) { flushCacheWithAppend(src, off, len); @@ -186,6 +192,7 @@ * Flushes the underlying stream, but leaves the internal buffer alone. * @throws IOException */ + @Override public void flush() throws IOException { stream.flush(); } @@ -194,6 +201,7 @@ * Finishes writing to the underlying stream, but does NOT close the underlying stream. * @throws IOException */ + @Override public void close() throws IOException { finish(); super.close(); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/ConnectMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/ConnectMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java Tue Jan 3 20:49:48 2006 @@ -30,9 +30,8 @@ package org.apache.commons.httpclient; import java.io.IOException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Establishes a tunneled HTTP connection via the CONNECT method. @@ -55,19 +54,7 @@ * @since 3.0 */ public ConnectMethod() { - LOG.trace("enter ConnectMethod()"); - } - - /** - * @deprecated the wrapped method is no longer used - * - * Create a connect method wrapping the existing method - * - * @param method the {@link HttpMethod method} to execute after connecting - * to the server - */ - public ConnectMethod(HttpMethod method) { - LOG.trace("enter ConnectMethod(HttpMethod)"); + LOG.debug("enter ConnectMethod()"); } /** @@ -75,6 +62,7 @@ * * @return the String "CONNECT" */ + @Override public String getName() { return NAME; } @@ -86,14 +74,10 @@ * @param state current state of http requests * @param conn the connection to use for I/O * - * @throws IOException when errors occur reading or writing to/from the - * connection - * @throws HttpException when a recoverable error occurs - * * @see HttpMethodBase#addCookieRequestHeader(HttpState, HttpConnection) */ - protected void addCookieRequestHeader(HttpState state, HttpConnection conn) - throws IOException, HttpException { + @Override + protected void addCookieRequestHeader(HttpState state, HttpConnection conn) { // Do nothing. Not applicable to CONNECT method } @@ -110,14 +94,10 @@ * @param state the client state * @param conn the {@link HttpConnection} the headers will eventually be * written to - * @throws IOException when an error occurs writing the request - * @throws HttpException when a HTTP protocol error occurs - * - * @see #writeRequestHeaders */ - protected void addRequestHeaders(HttpState state, HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter ConnectMethod.addRequestHeaders(HttpState, " + @Override + protected void addRequestHeaders(HttpState state, HttpConnection conn) { + LOG.debug("enter ConnectMethod.addRequestHeaders(HttpState, " + "HttpConnection)"); addUserAgentRequestHeader(state, conn); addHostRequestHeader(state, conn); @@ -137,10 +117,11 @@ * * @see HttpConnection#tunnelCreated() */ + @Override public int execute(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace("enter ConnectMethod.execute(HttpState, HttpConnection)"); + LOG.debug("enter ConnectMethod.execute(HttpState, HttpConnection)"); int code = super.execute(state, conn); if (LOG.isDebugEnabled()) { LOG.debug("CONNECT status code " + code); @@ -156,6 +137,7 @@ * @throws IOException when an error occurs writing the request * @throws HttpException when an error occurs writing the request */ + @Override protected void writeRequestLine(HttpState state, HttpConnection conn) throws IOException, HttpException { int port = conn.getPort(); @@ -188,6 +170,7 @@ * * @return true if the connection should be closed */ + @Override protected boolean shouldCloseConnection(HttpConnection conn) { if (getStatusCode() == HttpStatus.SC_OK) { Header connectionHeader = null; @@ -206,12 +189,11 @@ } } return false; - } else { - return super.shouldCloseConnection(conn); } + return super.shouldCloseConnection(conn); } /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(ConnectMethod.class); - + private static final Logger LOG = LoggerFactory + .getLogger(ConnectMethod.class); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java commons-httpclient/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java Tue Jan 3 18:41:43 2006 @@ -31,8 +31,6 @@ import java.io.InterruptedIOException; -import org.apache.commons.httpclient.util.ExceptionUtil; - /** * A timeout while connecting to an HTTP server or waiting for an * available connection from an HttpConnectionManager. @@ -68,8 +66,7 @@ */ public ConnectTimeoutException(String message, Throwable cause) { super(message); - // If we're running on JDK 1.4 or later, tell Throwable what the cause was - ExceptionUtil.initCause(this, cause); + initCause(cause); } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/ContentLengthInputStream.java commons-httpclient/src/java/org/apache/commons/httpclient/ContentLengthInputStream.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/ContentLengthInputStream.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/ContentLengthInputStream.java Tue Jan 3 18:58:11 2006 @@ -77,19 +77,6 @@ private InputStream wrappedStream = null; /** - * @deprecated use {@link #ContentLengthInputStream(InputStream, long)} - * - * Creates a new length limited stream - * - * @param in The stream to wrap - * @param contentLength The maximum number of bytes that can be read from - * the stream. Subsequent read operations will return -1. - */ - public ContentLengthInputStream(InputStream in, int contentLength) { - this(in, (long)contentLength); - } - - /** * Creates a new length limited stream * * @param in The stream to wrap @@ -111,6 +98,7 @@ * primed to parse the next response.

* @throws IOException If an IO problem occurs. */ + @Override public void close() throws IOException { if (!closed) { try { @@ -130,6 +118,7 @@ * @throws IOException If an IO problem occurs * @see java.io.InputStream#read() */ + @Override public int read() throws IOException { if (closed) { throw new IOException("Attempted read from closed stream."); @@ -154,6 +143,7 @@ * * @throws java.io.IOException Should an error occur on the wrapped stream. */ + @Override public int read (byte[] b, int off, int len) throws java.io.IOException { if (closed) { throw new IOException("Attempted read from closed stream."); @@ -179,6 +169,7 @@ * @throws IOException If an IO problem occurs * @see java.io.InputStream#read(byte[]) */ + @Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); } @@ -191,6 +182,7 @@ * @throws IOException If an error occurs while skipping bytes. * @see InputStream#skip(long) */ + @Override public long skip(long n) throws IOException { // make sure we don't skip more bytes than are // still available diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/Cookie.java commons-httpclient/src/java/org/apache/commons/httpclient/Cookie.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/Cookie.java Mon Mar 14 21:23:16 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/Cookie.java Tue Jan 3 05:09:04 2006 @@ -30,16 +30,16 @@ package org.apache.commons.httpclient; import java.io.Serializable; +import java.text.Collator; import java.text.RuleBasedCollator; import java.util.Comparator; import java.util.Date; import java.util.Locale; - import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.cookie.CookieSpec; import org.apache.commons.httpclient.util.LangUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

@@ -105,7 +105,7 @@ String path, Date expires, boolean secure) { super(name, value); - LOG.trace("enter Cookie(String, String, String, String, Date, boolean)"); + LOG.debug("enter Cookie(String, String, String, String, Date, boolean)"); if (name == null) { throw new IllegalArgumentException("Cookie name may not be null"); } @@ -400,6 +400,7 @@ * {@link Object#hashCode} general hashCode contract. * @return A hash code */ + @Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.getName()); @@ -414,6 +415,7 @@ * @param obj The object to compare against. * @return true if the two objects are equal. */ + @Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; @@ -422,9 +424,8 @@ return LangUtils.equals(this.getName(), that.getName()) && LangUtils.equals(this.cookieDomain, that.cookieDomain) && LangUtils.equals(this.cookiePath, that.cookiePath); - } else { - return false; } + return false; } @@ -454,7 +455,7 @@ * @return See {@link java.util.Comparator#compare(Object,Object)} */ public int compare(Object o1, Object o2) { - LOG.trace("enter Cookie.compare(Object, Object)"); + LOG.debug("enter Cookie.compare(Object, Object)"); if (!(o1 instanceof Cookie)) { throw new ClassCastException(o1.getClass().getName()); @@ -468,18 +469,10 @@ return 0; } else if (c1.getPath() == null) { // null is assumed to be "/" - if (c2.getPath().equals(CookieSpec.PATH_DELIM)) { - return 0; - } else { - return -1; - } + return (c2.getPath().equals(CookieSpec.PATH_DELIM)) ? 0 : -1; } else if (c2.getPath() == null) { // null is assumed to be "/" - if (c1.getPath().equals(CookieSpec.PATH_DELIM)) { - return 0; - } else { - return 1; - } + return (c1.getPath().equals(CookieSpec.PATH_DELIM)) ? 0 : 1; } else { return STRING_COLLATOR.compare(c1.getPath(), c2.getPath()); } @@ -492,6 +485,7 @@ * * @see #toExternalForm */ + @Override public String toString() { return toExternalForm(); } @@ -535,11 +529,11 @@ * specific Locales. */ private static final RuleBasedCollator STRING_COLLATOR = - (RuleBasedCollator) RuleBasedCollator.getInstance( + (RuleBasedCollator) Collator.getInstance( new Locale("en", "US", "")); /** Log object for this class */ - private static final Log LOG = LogFactory.getLog(Cookie.class); + private static final Logger LOG = LoggerFactory.getLogger(Cookie.class); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/Credentials.java commons-httpclient/src/java/org/apache/commons/httpclient/Credentials.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/Credentials.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/Credentials.java Tue Jan 3 18:58:50 2006 @@ -40,4 +40,5 @@ * @version $Revision: 155418 $ $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ */ public interface Credentials { + // empty } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/DefaultHttpMethodRetryHandler.java commons-httpclient/src/java/org/apache/commons/httpclient/DefaultHttpMethodRetryHandler.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/DefaultHttpMethodRetryHandler.java Tue Sep 13 20:41:21 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/DefaultHttpMethodRetryHandler.java Tue Jan 3 18:59:04 2006 @@ -49,6 +49,7 @@ try { SSL_HANDSHAKE_EXCEPTION = Class.forName("javax.net.ssl.SSLHandshakeException"); } catch (ClassNotFoundException ignore) { + // ignored } } /** the number of times a method will be retried */ diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/DefaultMethodRetryHandler.java commons-httpclient/src/java/org/apache/commons/httpclient/DefaultMethodRetryHandler.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/DefaultMethodRetryHandler.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/DefaultMethodRetryHandler.java Thu Jan 1 01:00:00 1970 @@ -1,101 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/DefaultMethodRetryHandler.java,v 1.4 2004/07/05 22:46:58 olegk Exp $ - * $Revision: 155418 $ - * $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - * - * ==================================================================== - * - * Copyright 1999-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient; - -/** - * The default MethodRetryHandler used by HttpMethodBase. - * - * @author Michael Becke - * - * @see HttpMethodBase#setMethodRetryHandler(MethodRetryHandler) - * - * @deprecated use {@link org.apache.commons.httpclient.DefaultHttpMethodRetryHandler} - */ -public class DefaultMethodRetryHandler implements MethodRetryHandler { - - /** the number of times a method will be retried */ - private int retryCount; - - /** Whether or not methods that have successfully sent their request will be retried */ - private boolean requestSentRetryEnabled; - - /** - */ - public DefaultMethodRetryHandler() { - this.retryCount = 3; - this.requestSentRetryEnabled = false; - } - - /** - * Used retryCount and requestSentRetryEnabled to determine - * if the given method should be retried. - * - * @see MethodRetryHandler#retryMethod(HttpMethod, HttpConnection, HttpRecoverableException, int, boolean) - */ - public boolean retryMethod( - HttpMethod method, - HttpConnection connection, - HttpRecoverableException recoverableException, - int executionCount, - boolean requestSent - ) { - return ((!requestSent || requestSentRetryEnabled) && (executionCount <= retryCount)); - } - /** - * @return true if this handler will retry methods that have - * successfully sent their request, false otherwise - */ - public boolean isRequestSentRetryEnabled() { - return requestSentRetryEnabled; - } - - /** - * @return the maximum number of times a method will be retried - */ - public int getRetryCount() { - return retryCount; - } - - /** - * @param requestSentRetryEnabled a flag indicating if methods that have - * successfully sent their request should be retried - */ - public void setRequestSentRetryEnabled(boolean requestSentRetryEnabled) { - this.requestSentRetryEnabled = requestSentRetryEnabled; - } - - /** - * @param retryCount the maximum number of times a method can be retried - */ - public void setRetryCount(int retryCount) { - this.retryCount = retryCount; - } - -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/Header.java commons-httpclient/src/java/org/apache/commons/httpclient/Header.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/Header.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/Header.java Tue Jan 3 19:00:06 2006 @@ -97,22 +97,9 @@ * * @return stringHEAD */ + @Override public String toString() { return toExternalForm(); - } - - /** - * Returns an array of {@link HeaderElement}s - * constructed from my value. - * - * @see HeaderElement#parse - * @throws HttpException if the header cannot be parsed - * @return an array of header elements - * - * @deprecated Use #getElements - */ - public HeaderElement[] getValues() throws HttpException { - return HeaderElement.parse(getValue()); } /** diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HeaderElement.java commons-httpclient/src/java/org/apache/commons/httpclient/HeaderElement.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HeaderElement.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HeaderElement.java Tue Jan 3 19:00:58 2006 @@ -31,10 +31,9 @@ import java.util.ArrayList; import java.util.List; - import org.apache.commons.httpclient.util.ParameterParser; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

One element of an HTTP header's value.

@@ -69,7 +68,7 @@ * a set of additional parameters. *

*

- * This class also exposes a {@link #parse} method for parsing a + * This class also exposes a {@link #parseElements(String)} method for parsing a * {@link Header} value into an array of elements. *

* @@ -131,13 +130,13 @@ return; } ParameterParser parser = new ParameterParser(); - List params = parser.parse(chars, offset, length, ';'); + List params = parser.parse(chars, offset, length, ';'); if (params.size() > 0) { - NameValuePair element = (NameValuePair) params.remove(0); + NameValuePair element = params.remove(0); setName(element.getName()); setValue(element.getValue()); if (params.size() > 0) { - this.parameters = (NameValuePair[]) + this.parameters = params.toArray(new NameValuePair[params.size()]); } } @@ -157,7 +156,8 @@ // -------------------------------------------------------- Constants /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HeaderElement.class); + private static final Logger LOG = LoggerFactory + .getLogger(HeaderElement.class); // ----------------------------------------------------- Instance Variables @@ -190,12 +190,12 @@ */ public static final HeaderElement[] parseElements(char[] headerValue) { - LOG.trace("enter HeaderElement.parseElements(char[])"); + LOG.debug("enter HeaderElement.parseElements(char[])"); if (headerValue == null) { return new HeaderElement[] {}; } - List elements = new ArrayList(); + List elements = new ArrayList(); int i = 0; int from = 0; @@ -218,8 +218,7 @@ } i++; } - return (HeaderElement[]) - elements.toArray(new HeaderElement[elements.size()]); + return elements.toArray(new HeaderElement[elements.size()]); } /** @@ -234,7 +233,7 @@ */ public static final HeaderElement[] parseElements(String headerValue) { - LOG.trace("enter HeaderElement.parseElements(String)"); + LOG.debug("enter HeaderElement.parseElements(String)"); if (headerValue == null) { return new HeaderElement[] {}; @@ -243,29 +242,6 @@ } /** - * This parses the value part of a header. The result is an array of - * HeaderElement objects. - * - * @param headerValue the string representation of the header value - * (as received from the web server). - * @return array of {@link HeaderElement}s. - * @throws HttpException if the above syntax rules are violated. - * - * @deprecated Use #parseElements(String). - */ - public static final HeaderElement[] parse(String headerValue) - throws HttpException { - - LOG.trace("enter HeaderElement.parse(String)"); - - if (headerValue == null) { - return new HeaderElement[] {}; - } - return parseElements(headerValue.toCharArray()); - } - - - /** * Returns parameter with the given name, if found. Otherwise null * is returned * @@ -275,7 +251,7 @@ public NameValuePair getParameterByName(String name) { - LOG.trace("enter HeaderElement.getParameterByName(String)"); + LOG.debug("enter HeaderElement.getParameterByName(String)"); if (name == null) { throw new IllegalArgumentException("Name may not be null"); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HeaderGroup.java commons-httpclient/src/java/org/apache/commons/httpclient/HeaderGroup.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HeaderGroup.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HeaderGroup.java Tue Jan 3 05:16:06 2006 @@ -45,13 +45,13 @@ public class HeaderGroup { /** The list of headers for this group, in the order in which they were added */ - private List headers; + private List
headers; /** * Constructor for HeaderGroup. */ public HeaderGroup() { - this.headers = new ArrayList(); + this.headers = new ArrayList
(); } /** @@ -136,16 +136,15 @@ * @return an array of length >= 0 */ public Header[] getHeaders(String name) { - ArrayList headersFound = new ArrayList(); + ArrayList
headersFound = new ArrayList
(); - for (Iterator headerIter = headers.iterator(); headerIter.hasNext();) { - Header header = (Header) headerIter.next(); + for (Header header : headers) { if (header.getName().equalsIgnoreCase(name)) { headersFound.add(header); } } - return (Header[]) headersFound.toArray(new Header[headersFound.size()]); + return headersFound.toArray(new Header[headersFound.size()]); } /** @@ -178,7 +177,7 @@ public Header getLastHeader(String name) { // start at the end of the list and work backwards for (int i = headers.size() - 1; i >= 0; i--) { - Header header = (Header) headers.get(i); + Header header = headers.get(i); if (header.getName().equalsIgnoreCase(name)) { return header; } @@ -193,7 +192,7 @@ * @return an array of length >= 0 */ public Header[] getAllHeaders() { - return (Header[]) headers.toArray(new Header[headers.size()]); + return headers.toArray(new Header[headers.size()]); } /** diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HostConfiguration.java commons-httpclient/src/java/org/apache/commons/httpclient/HostConfiguration.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HostConfiguration.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HostConfiguration.java Tue Jan 3 19:03:54 2006 @@ -105,6 +105,7 @@ /** * @see java.lang.Object#clone() */ + @Override public Object clone() { return new HostConfiguration(this); } @@ -112,6 +113,7 @@ /** * @see java.lang.Object#toString() */ + @Override public synchronized String toString() { boolean appendComma = false; @@ -183,9 +185,8 @@ } } return true; - } else { - return false; } + return false; } /** @@ -206,19 +207,8 @@ return this.proxyHost.getHostName().equalsIgnoreCase(connection.getProxyHost()) && this.proxyHost.getPort() == connection.getProxyPort(); - } else { - return connection.getProxyHost() == null; - } } - - /** - * Returns true if the host is set. - * @return true if the host is set. - * - * @deprecated no longer used - */ - public synchronized boolean isHostSet() { - return this.host != null; + return connection.getProxyHost() == null; } /** @@ -242,22 +232,6 @@ } /** - * Sets the given host, virtual host, port and protocol. - * - * @param host the host(IP or DNS name) - * @param virtualHost the virtual host name or null - * @param port the host port or -1 to use protocol default - * @param protocol the protocol - * - * @deprecated #setHost(String, int, Protocol) - */ - public synchronized void setHost(final String host, final String virtualHost, int port, - final Protocol protocol) { - setHost(host, port, protocol); - this.params.setVirtualHost(virtualHost); - } - - /** * Sets the given host, port and protocol. * * @param host the host(IP or DNS name) @@ -314,50 +288,26 @@ public synchronized String getHostURL() { if (this.host == null) { throw new IllegalStateException("Host must be set to create a host URL"); - } else { - return this.host.toURI(); } + return this.host.toURI(); } /** * Returns the host. * * @return the host(IP or DNS name), or null if not set - * - * @see #isHostSet() */ public synchronized String getHost() { - if (this.host != null) { - return this.host.getHostName(); - } else { - return null; - } - } - - /** - * Returns the virtual host. - * - * @return the virtual host name, or null if not set - * - * @deprecated use HostParams - */ - public synchronized String getVirtualHost() { - return this.params.getVirtualHost(); + return (this.host != null) ? this.host.getHostName() : null; } /** * Returns the port. * * @return the host port, or -1 if not set - * - * @see #isHostSet() */ public synchronized int getPort() { - if (this.host != null) { - return this.host.getPort(); - } else { - return -1; - } + return (this.host != null) ? this.host.getPort() : -1; } /** @@ -365,24 +315,7 @@ * @return The protocol. */ public synchronized Protocol getProtocol() { - if (this.host != null) { - return this.host.getProtocol(); - } else { - return null; - } - } - - /** - * Tests if the proxy host/port have been set. - * - * @return true if a proxy server has been set. - * - * @see #setProxy(String, int) - * - * @deprecated no longer used - */ - public synchronized boolean isProxySet() { - return this.proxyHost != null; + return (this.host != null) ? this.host.getProtocol() : null; } /** @@ -407,30 +340,18 @@ * Returns the proxyHost. * * @return the proxy host, or null if not set - * - * @see #isProxySet() */ public synchronized String getProxyHost() { - if (this.proxyHost != null) { - return this.proxyHost.getHostName(); - } else { - return null; - } + return (this.proxyHost != null) ? this.proxyHost.getHostName() : null; } /** * Returns the proxyPort. * * @return the proxy port, or -1 if not set - * - * @see #isProxySet() */ public synchronized int getProxyPort() { - if (this.proxyHost != null) { - return this.proxyHost.getPort(); - } else { - return -1; - } + return (this.proxyHost != null) ? this.proxyHost.getPort() : -1; } /** @@ -469,6 +390,7 @@ /** * Assigns {@link HostParams HTTP protocol parameters} specific to this host. + * @param params params to set. Cannot be null * * @since 3.0 * @@ -484,6 +406,7 @@ /** * @see java.lang.Object#equals(java.lang.Object) */ + @Override public synchronized boolean equals(final Object o) { if (o instanceof HostConfiguration) { // shortcut if we're comparing with ourselves @@ -494,15 +417,14 @@ return LangUtils.equals(this.host, that.host) && LangUtils.equals(this.proxyHost, that.proxyHost) && LangUtils.equals(this.localAddress, that.localAddress); - } else { - return false; } - + return false; } /** * @see java.lang.Object#hashCode() */ + @Override public synchronized int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.host); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpClient.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpClient.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpClient.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpClient.java Tue Jan 3 19:05:41 2006 @@ -32,10 +32,9 @@ import java.io.IOException; import java.security.Provider; import java.security.Security; - import org.apache.commons.httpclient.params.HttpClientParams; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

@@ -62,7 +61,7 @@ // -------------------------------------------------------------- Constants /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpClient.class); + private static final Logger LOG = LoggerFactory.getLogger(HttpClient.class); static { @@ -82,6 +81,7 @@ + ": " + provider.getInfo()); } } catch (SecurityException ignore) { + // ignore } } } @@ -216,93 +216,6 @@ this.state = state; } - /** - * Defines how strictly the method follows the HTTP protocol specification - * (see RFC 2616 and other relevant RFCs). - * - * In the strict mode the method precisely - * implements the requirements of the specification, whereas in non-strict mode - * it attempts to mimic the exact behaviour of commonly used HTTP agents, - * which many HTTP servers expect. - * - * @param strictMode true for strict mode, false otherwise - * - * @see #isStrictMode() - * - * @deprecated Use {@link HttpClientParams#setParameter(String, Object)} - * to exercise a more granular control over HTTP protocol strictness. - */ - public synchronized void setStrictMode(boolean strictMode) { - if (strictMode) { - this.params.makeStrict(); - } else { - this.params.makeLenient(); - } - } - - /** - * Returns the value of the strict mode flag. - * - * @return true if strict mode is enabled, false otherwise - * - * @see #setStrictMode(boolean) - * - * @deprecated Use - * {@link org.apache.commons.httpclient.params.HttpClientParams#getParameter(String)} - * to exercise a more granular control over HTTP protocol strictness. - */ - public synchronized boolean isStrictMode() { - return false; - } - - /** - * Sets the 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. - * - * @param newTimeoutInMilliseconds Timeout in milliseconds - * - * @deprecated Use - * {@link org.apache.commons.httpclient.params.HttpConnectionManagerParams#setSoTimeout(int)}, - * {@link HttpConnectionManager#getParams()}. - * - */ - public synchronized void setTimeout(int newTimeoutInMilliseconds) { - this.params.setSoTimeout(newTimeoutInMilliseconds); - } - - /** - * Sets the timeout in milliseconds used when retrieving an - * {@link HttpConnection HTTP connection} from the - * {@link HttpConnectionManager HTTP connection manager}. - * - * @param timeout the timeout in milliseconds - * - * @see HttpConnectionManager#getConnection(HostConfiguration, long) - * - * @deprecated Use - * {@link org.apache.commons.httpclient.params.HttpClientParams#setConnectionManagerTimeout(long)}, - * {@link HttpClient#getParams()} - */ - public synchronized void setHttpConnectionFactoryTimeout(long timeout) { - this.params.setConnectionManagerTimeout(timeout); - } - - /** - * Sets the timeout until a connection is etablished. A value of zero - * means the timeout is not used. The default value is zero. - * - * @see HttpConnection#setConnectionTimeout(int) - * @param newTimeoutInMilliseconds Timeout in milliseconds. - * - * @deprecated Use - * {@link org.apache.commons.httpclient.params.HttpConnectionManagerParams#setConnectionTimeout(int)}, - * {@link HttpConnectionManager#getParams()}. - */ - public synchronized void setConnectionTimeout(int newTimeoutInMilliseconds) { - this.httpConnectionManager.getParams().setConnectionTimeout(newTimeoutInMilliseconds); - } - // --------------------------------------------------------- Public Methods /** @@ -319,7 +232,7 @@ public int executeMethod(HttpMethod method) throws IOException, HttpException { - LOG.trace("enter HttpClient.executeMethod(HttpMethod)"); + LOG.debug("enter HttpClient.executeMethod(HttpMethod)"); // execute this method and use its host configuration, if it has one return executeMethod(null, method, null); } @@ -341,7 +254,7 @@ public int executeMethod(final HostConfiguration hostConfiguration, final HttpMethod method) throws IOException, HttpException { - LOG.trace("enter HttpClient.executeMethod(HostConfiguration,HttpMethod)"); + LOG.debug("enter HttpClient.executeMethod(HostConfiguration,HttpMethod)"); return executeMethod(hostConfiguration, method, null); } @@ -370,7 +283,7 @@ final HttpMethod method, final HttpState state) throws IOException, HttpException { - LOG.trace("enter HttpClient.executeMethod(HostConfiguration,HttpMethod,HttpState)"); + LOG.debug("enter HttpClient.executeMethod(HostConfiguration,HttpMethod,HttpState)"); if (method == null) { throw new IllegalArgumentException("HttpMethod parameter may not be null"); @@ -398,28 +311,6 @@ } /** - * Returns the default host. - * - * @return The default host. - * - * @deprecated use #getHostConfiguration() - */ - public String getHost() { - return hostConfiguration.getHost(); - } - - /** - * Returns the default port. - * - * @return The default port. - * - * @deprecated use #getHostConfiguration() - */ - public int getPort() { - return hostConfiguration.getPort(); - } - - /** * Returns the {@link HostConfiguration host configuration} associated with the * HttpClient. * @@ -475,6 +366,7 @@ /** * Returns {@link HttpClientParams HTTP protocol parameters} associated with this HttpClient. + * @return currently params set * * @since 3.0 * @@ -486,6 +378,7 @@ /** * Assigns {@link HttpClientParams HTTP protocol parameters} for this HttpClient. + * @param params params to set. Cannot be null * * @since 3.0 * diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpConnection.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpConnection.java Sun Oct 23 15:34:28 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java Tue Jan 3 19:23:47 2006 @@ -35,19 +35,17 @@ import java.io.InputStream; import java.io.InterruptedIOException; import java.io.OutputStream; -import java.lang.reflect.Method; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; - import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; import org.apache.commons.httpclient.util.EncodingUtil; import org.apache.commons.httpclient.util.ExceptionUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * An abstraction of an HTTP {@link InputStream} and {@link OutputStream} @@ -100,7 +98,7 @@ * @param port the port to connect to */ public HttpConnection(String host, int port) { - this(null, -1, host, null, port, Protocol.getProtocol("http")); + this(null, -1, host, port, Protocol.getProtocol("http")); } /** @@ -112,20 +110,7 @@ * @param protocol the protocol to use */ public HttpConnection(String host, int port, Protocol protocol) { - this(null, -1, host, null, port, protocol); - } - - /** - * Creates a new HTTP connection for the given host with the virtual - * alias and port using given protocol. - * - * @param host the host to connect to - * @param virtualHost the virtual host requests will be sent to - * @param port the port to connect to - * @param protocol the protocol to use - */ - public HttpConnection(String host, String virtualHost, int port, Protocol protocol) { - this(null, -1, host, virtualHost, port, protocol); + this(null, -1, host, port, protocol); } /** @@ -142,7 +127,7 @@ int proxyPort, String host, int port) { - this(proxyHost, proxyPort, host, null, port, Protocol.getProtocol("http")); + this(proxyHost, proxyPort, host, port, Protocol.getProtocol("http")); } /** @@ -167,30 +152,6 @@ * @param proxyHost the host to proxy via * @param proxyPort the port to proxy via * @param host the host to connect to. Parameter value must be non-null. - * @param virtualHost No longer applicable. - * @param port the port to connect to - * @param protocol The protocol to use. Parameter value must be non-null. - * - * @deprecated use #HttpConnection(String, int, String, int, Protocol) - */ - public HttpConnection( - String proxyHost, - int proxyPort, - String host, - String virtualHost, - int port, - Protocol protocol) { - this(proxyHost, proxyPort, host, port, protocol); - } - - /** - * Creates a new HTTP connection for the given host with the virtual - * alias and port via the given proxy host and port using the given - * protocol. - * - * @param proxyHost the host to proxy via - * @param proxyPort the port to proxy via - * @param host the host to connect to. Parameter value must be non-null. * @param port the port to connect to * @param protocol The protocol to use. Parameter value must be non-null. */ @@ -252,35 +213,6 @@ } /** - * Returns the target virtual host. - * - * @return the virtual host. - * - * @deprecated no longer applicable - */ - - public String getVirtualHost() { - return this.hostName; - } - - /** - * Sets the virtual host to target. - * - * @param host the virtual host name that should be used instead of - * physical host name when sending HTTP requests. Virtual host - * name can be set to null if virtual host name is not - * to be used - * - * @throws IllegalStateException if the connection is already open - * - * @deprecated no longer applicable - */ - - public void setVirtualHost(String host) throws IllegalStateException { - assertNotOpen(); - } - - /** * Returns the port of the host. * * If the port is -1 (or less than 0) the default port for @@ -289,11 +221,7 @@ * @return the port. */ public int getPort() { - if (portNumber < 0) { - return isSecure() ? 443 : 80; - } else { - return portNumber; - } + return (portNumber < 0) ? (isSecure() ? 443 : 80) : portNumber; } /** @@ -421,6 +349,7 @@ * * @return true if the connection was stale and therefore closed, * false otherwise. + * @throws IOException * * @see #isStale() * @@ -436,40 +365,6 @@ } /** - * Tests if stale checking is enabled. - * - * @return true if enabled - * - * @see #isStale() - * - * @deprecated Use {@link HttpConnectionParams#isStaleCheckingEnabled()}, - * {@link HttpConnection#getParams()}. - */ - public boolean isStaleCheckingEnabled() { - return this.params.isStaleCheckingEnabled(); - } - - /** - * Sets whether or not isStale() will be called when testing if this connection is open. - * - *

Setting this flag to false will increase performance when reusing - * connections, but it will also make them less reliable. Stale checking ensures that - * connections are viable before they are used. When set to false some - * method executions will result in IOExceptions and they will have to be retried.

- * - * @param staleCheckEnabled true to enable isStale() - * - * @see #isStale() - * @see #isOpen() - * - * @deprecated Use {@link HttpConnectionParams#setStaleCheckingEnabled(boolean)}, - * {@link HttpConnection#getParams()}. - */ - public void setStaleCheckingEnabled(boolean staleCheckEnabled) { - this.params.setStaleCheckingEnabled(staleCheckEnabled); - } - - /** * Determines whether this connection is "stale", which is to say that either * it is no longer open, or an attempt to read the connection would fail. * @@ -561,7 +456,7 @@ * Returns the stream used to read the last response's body. * *

Clients will generally not need to call this function unless - * using HttpConnection directly, instead of calling {@link HttpClient#executeMethod}. + * using HttpConnection directly, instead of calling {@link HttpClient#executeMethod(HttpMethod)}. * For those clients, call this function, and if it returns a non-null stream, * close the stream before attempting to execute a method. Note that * calling "close" on the stream returned by this function may close @@ -589,6 +484,7 @@ /** * Assigns {@link HttpConnectionParams HTTP protocol parameters} for this method. + * @param params params to set. Cannot be null * * @since 3.0 * @@ -602,28 +498,6 @@ } /** - * Set the {@link Socket}'s timeout, via {@link Socket#setSoTimeout}. If the - * connection is already open, the SO_TIMEOUT is changed. If no connection - * is open, then subsequent connections will use the timeout value. - *

- * Note: This is not a connection timeout but a timeout on network traffic! - * - * @param timeout the timeout value - * @throws SocketException - if there is an error in the underlying - * protocol, such as a TCP error. - * - * @deprecated Use {@link HttpConnectionParams#setSoTimeout(int)}, - * {@link HttpConnection#getParams()}. - */ - public void setSoTimeout(int timeout) - throws SocketException, IllegalStateException { - this.params.setSoTimeout(timeout); - if (this.socket != null) { - this.socket.setSoTimeout(timeout); - } - } - - /** * Sets SO_TIMEOUT value directly on the underlying {@link Socket socket}. * This method does not change the default read timeout value set via * {@link HttpConnectionParams}. @@ -644,35 +518,6 @@ } /** - * Returns the {@link Socket}'s timeout, via {@link Socket#getSoTimeout}, if the - * connection is already open. If no connection is open, return the value subsequent - * connection will use. - *

- * Note: This is not a connection timeout but a timeout on network traffic! - * - * @return the timeout value - * - * @deprecated Use {@link HttpConnectionParams#getSoTimeout()}, - * {@link HttpConnection#getParams()}. - */ - public int getSoTimeout() throws SocketException { - return this.params.getSoTimeout(); - } - - /** - * Sets the connection timeout. This is the maximum time that may be spent - * until a connection is established. The connection will fail after this - * amount of time. - * @param timeout The timeout in milliseconds. 0 means timeout is not used. - * - * @deprecated Use {@link HttpConnectionParams#setConnectionTimeout(int)}, - * {@link HttpConnection#getParams()}. - */ - public void setConnectionTimeout(int timeout) { - this.params.setConnectionTimeout(timeout); - } - - /** * Establishes a connection to the specified host and port * (via a proxy if specified). * The underlying socket is created from the {@link ProtocolSocketFactory}. @@ -681,7 +526,7 @@ * I/O error. */ public void open() throws IOException { - LOG.trace("enter HttpConnection.open()"); + LOG.debug("enter HttpConnection.open()"); final String host = (proxyHostName == null) ? hostName : proxyHostName; final int port = (proxyHostName == null) ? portNumber : proxyPortNumber; @@ -763,7 +608,7 @@ * I/O error. */ public void tunnelCreated() throws IllegalStateException, IOException { - LOG.trace("enter HttpConnection.tunnelCreated()"); + LOG.debug("enter HttpConnection.tunnelCreated()"); if (!isSecure() || !isProxied()) { throw new IllegalStateException( @@ -822,7 +667,7 @@ * @throws IOException if an I/O problem occurs */ public void flushRequestOutputStream() throws IOException { - LOG.trace("enter HttpConnection.flushRequestOutputStream()"); + LOG.debug("enter HttpConnection.flushRequestOutputStream()"); assertOpen(); outputStream.flush(); } @@ -831,12 +676,11 @@ * Returns an {@link OutputStream} suitable for writing the request. * * @throws IllegalStateException if the connection is not open - * @throws IOException if an I/O problem occurs * @return a stream to write the request to */ public OutputStream getRequestOutputStream() - throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.getRequestOutputStream()"); + throws IllegalStateException { + LOG.debug("enter HttpConnection.getRequestOutputStream()"); assertOpen(); OutputStream out = this.outputStream; if (Wire.CONTENT_WIRE.enabled()) { @@ -848,12 +692,11 @@ /** * Return a {@link InputStream} suitable for reading the response. * @return InputStream The response input stream. - * @throws IOException If an IO problem occurs * @throws IllegalStateException If the connection isn't open. */ public InputStream getResponseInputStream() - throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.getResponseInputStream()"); + throws IllegalStateException { + LOG.debug("enter HttpConnection.getResponseInputStream()"); assertOpen(); return inputStream; } @@ -870,12 +713,8 @@ */ public boolean isResponseAvailable() throws IOException { - LOG.trace("enter HttpConnection.isResponseAvailable()"); - if (this.isOpen) { - return this.inputStream.available() > 0; - } else { - return false; - } + LOG.debug("enter HttpConnection.isResponseAvailable()"); + return (this.isOpen) ? this.inputStream.available() > 0 : false; } /** @@ -890,7 +729,7 @@ */ public boolean isResponseAvailable(int timeout) throws IOException { - LOG.trace("enter HttpConnection.isResponseAvailable(int)"); + LOG.debug("enter HttpConnection.isResponseAvailable(int)"); assertOpen(); boolean result = false; if (this.inputStream.available() > 0) { @@ -938,7 +777,7 @@ */ public void write(byte[] data) throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.write(byte[])"); + LOG.debug("enter HttpConnection.write(byte[])"); this.write(data, 0, data.length); } @@ -959,7 +798,7 @@ */ public void write(byte[] data, int offset, int length) throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.write(byte[], int, int)"); + LOG.debug("enter HttpConnection.write(byte[], int, int)"); if (offset < 0) { throw new IllegalArgumentException("Array offset may not be negative"); @@ -984,7 +823,7 @@ */ public void writeLine(byte[] data) throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.writeLine(byte[])"); + LOG.debug("enter HttpConnection.writeLine(byte[])"); write(data); writeLine(); } @@ -997,26 +836,11 @@ */ public void writeLine() throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.writeLine()"); + LOG.debug("enter HttpConnection.writeLine()"); write(CRLF); } /** - * @deprecated Use {@link #print(String, String)} - * - * Writes the specified String (as bytes) to the output stream. - * - * @param data the string to be written - * @throws IllegalStateException if the connection is not open - * @throws IOException if an I/O problem occurs - */ - public void print(String data) - throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.print(String)"); - write(EncodingUtil.getBytes(data, "ISO-8859-1")); - } - - /** * Writes the specified String (as bytes) to the output stream. * * @param data the string to be written @@ -1028,27 +852,11 @@ */ public void print(String data, String charset) throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.print(String)"); + LOG.debug("enter HttpConnection.print(String)"); write(EncodingUtil.getBytes(data, charset)); } /** - * @deprecated Use {@link #printLine(String, String)} - * - * Writes the specified String (as bytes), followed by - * "\r\n".getBytes() to the output stream. - * - * @param data the data to be written - * @throws IllegalStateException if the connection is not open - * @throws IOException if an I/O problem occurs - */ - public void printLine(String data) - throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.printLine(String)"); - writeLine(EncodingUtil.getBytes(data, "ISO-8859-1")); - } - - /** * Writes the specified String (as bytes), followed by * "\r\n".getBytes() to the output stream. * @@ -1061,7 +869,7 @@ */ public void printLine(String data, String charset) throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.printLine(String)"); + LOG.debug("enter HttpConnection.printLine(String)"); writeLine(EncodingUtil.getBytes(data, charset)); } @@ -1073,7 +881,7 @@ */ public void printLine() throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.printLine()"); + LOG.debug("enter HttpConnection.printLine()"); writeLine(); } @@ -1082,24 +890,6 @@ * If the stream ends before the line terminator is found, * the last part of the string will still be returned. * - * @throws IllegalStateException if the connection is not open - * @throws IOException if an I/O problem occurs - * @return a line from the response - * - * @deprecated use #readLine(String) - */ - public String readLine() throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.readLine()"); - - assertOpen(); - return HttpParser.readLine(inputStream); - } - - /** - * Reads up to "\n" from the (unchunked) input stream. - * If the stream ends before the line terminator is found, - * the last part of the string will still be returned. - * * @param charset the charset to use for reading the data * * @throws IllegalStateException if the connection is not open @@ -1109,42 +899,17 @@ * @since 3.0 */ public String readLine(final String charset) throws IOException, IllegalStateException { - LOG.trace("enter HttpConnection.readLine()"); + LOG.debug("enter HttpConnection.readLine()"); assertOpen(); return HttpParser.readLine(inputStream, charset); } /** - * Attempts to shutdown the {@link Socket}'s output, via Socket.shutdownOutput() - * when running on JVM 1.3 or higher. - * - * @deprecated unused - */ - public void shutdownOutput() { - LOG.trace("enter HttpConnection.shutdownOutput()"); - - try { - // Socket.shutdownOutput is a JDK 1.3 - // method. We'll use reflection in case - // we're running in an older VM - Class[] paramsClasses = new Class[0]; - Method shutdownOutput = - socket.getClass().getMethod("shutdownOutput", paramsClasses); - Object[] params = new Object[0]; - shutdownOutput.invoke(socket, params); - } catch (Exception ex) { - LOG.debug("Unexpected Exception caught", ex); - // Ignore, and hope everything goes right - } - // close output stream? - } - - /** * Closes the socket and streams. */ public void close() { - LOG.trace("enter HttpConnection.close()"); + LOG.debug("enter HttpConnection.close()"); closeSocketAndStreams(); } @@ -1170,7 +935,7 @@ * to call this method multiple times. */ public void releaseConnection() { - LOG.trace("enter HttpConnection.releaseConnection()"); + LOG.debug("enter HttpConnection.releaseConnection()"); if (locked) { LOG.debug("Connection is locked. Call to releaseConnection() ignored."); } else if (httpConnectionManager != null) { @@ -1211,7 +976,7 @@ * Closes everything out. */ protected void closeSocketAndStreams() { - LOG.trace("enter HttpConnection.closeSockedAndStreams()"); + LOG.debug("enter HttpConnection.closeSockedAndStreams()"); isOpen = false; @@ -1288,27 +1053,7 @@ * @see Socket#getSendBufferSize() */ public int getSendBufferSize() throws SocketException { - if (socket == null) { - return -1; - } else { - return socket.getSendBufferSize(); - } - } - - /** - * Sets the socket's sendBufferSize. - * - * @param sendBufferSize the size to set for the socket OutputStream - * - * @throws SocketException if an error occurs while setting the socket value - * - * @see Socket#setSendBufferSize(int) - * - * @deprecated Use {@link HttpConnectionParams#setSendBufferSize(int)}, - * {@link HttpConnection#getParams()}. - */ - public void setSendBufferSize(int sendBufferSize) throws SocketException { - this.params.setSendBufferSize(sendBufferSize); + return (socket == null) ? -1 : socket.getSendBufferSize(); } // ------------------------------------------------------- Static Variable @@ -1317,7 +1062,8 @@ private static final byte[] CRLF = new byte[] {(byte) 13, (byte) 10}; /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpConnection.class); + private static final Logger LOG = LoggerFactory + .getLogger(HttpConnection.class); // ----------------------------------------------------- Instance Variables diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpConnectionManager.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpConnectionManager.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpConnectionManager.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpConnectionManager.java Tue Jan 3 19:24:42 2006 @@ -76,31 +76,6 @@ * * @return an HttpConnection for the given configuraiton * - * @throws HttpException if no connection becomes available before the - * timeout expires - * - * @see HttpConnection#setHttpConnectionManager(HttpConnectionManager) - * - * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long) - */ - HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) - throws HttpException; - - /** - * Gets an HttpConnection for a given host configuration. If a connection is - * not available, this method will block for at most the specified number of - * milliseconds or until a connection becomes available. - * - * The connection manager should be registered with any HttpConnection that - * is created. - * - * @param hostConfiguration the host configuration to use to configure the - * connection - * @param timeout - the time (in milliseconds) to wait for a connection to - * become available, 0 to specify an infinite timeout - * - * @return an HttpConnection for the given configuraiton - * * @throws ConnectionPoolTimeoutException if no connection becomes available before the * timeout expires * @@ -131,6 +106,7 @@ /** * Returns {@link HttpConnectionManagerParams parameters} associated * with this connection manager. + * @return all associated parameters * * @since 3.0 * @@ -141,6 +117,7 @@ /** * Assigns {@link HttpConnectionManagerParams parameters} for this * connection manager. + * @param params params to set * * @since 3.0 * diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpConstants.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpConstants.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpConstants.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpConstants.java Thu Jan 1 01:00:00 1970 @@ -1,327 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpConstants.java,v 1.15 2004/04/18 23:51:35 jsdever Exp $ - * $Revision: 155418 $ - * $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - * - * ==================================================================== - * - * Copyright 1999-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient; - -import java.io.UnsupportedEncodingException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -/** - * HTTP content conversion routines. - * - * @author Oleg Kalnichevski - * @author Mike Bowler - * - * @deprecated use EncodingUtil class - */ -public class HttpConstants { - - /** Character set used to encode HTTP protocol elements */ - public static final String HTTP_ELEMENT_CHARSET = "US-ASCII"; - - /** Default content encoding chatset */ - public static final String DEFAULT_CONTENT_CHARSET = "ISO-8859-1"; - - /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpConstants.class); - - /** - * Converts the specified string to a byte array of HTTP element characters. - * This method is to be used when encoding content of HTTP elements (such as - * request headers) - * - * @param data the string to be encoded - * @return The resulting byte array. - */ - public static byte[] getBytes(final String data) { - if (data == null) { - throw new IllegalArgumentException("Parameter may not be null"); - } - - try { - return data.getBytes(HTTP_ELEMENT_CHARSET); - } catch (UnsupportedEncodingException e) { - - if (LOG.isWarnEnabled()) { - LOG.warn("Unsupported encoding: " - + HTTP_ELEMENT_CHARSET - + ". System default encoding used"); - } - - return data.getBytes(); - } - } - - /** - * Converts the byte array of HTTP element characters to a string This - * method is to be used when decoding content of HTTP elements (such as - * response headers) - * - * @param data the byte array to be encoded - * @param offset the index of the first byte to encode - * @param length the number of bytes to encode - * @return The resulting string. - */ - public static String getString(final byte[] data, int offset, int length) { - - if (data == null) { - throw new IllegalArgumentException("Parameter may not be null"); - } - - try { - return new String(data, offset, length, HTTP_ELEMENT_CHARSET); - } catch (UnsupportedEncodingException e) { - - if (LOG.isWarnEnabled()) { - LOG.warn("Unsupported encoding: " - + HTTP_ELEMENT_CHARSET - + ". System default encoding used"); - } - - return new String(data, offset, length); - } - } - - /** - * Converts the byte array of HTTP element characters to a string This - * method is to be used when decoding content of HTTP elements (such as - * response headers) - * - * @param data the byte array to be encoded - * @return The resulting string. - */ - public static String getString(final byte[] data) { - return getString(data, 0, data.length); - } - - /** - * Converts the specified string to a byte array of HTTP content charachetrs - * This method is to be used when encoding content of HTTP request/response - * If the specified charset is not supported, default HTTP content encoding - * (ISO-8859-1) is applied - * - * @param data the string to be encoded - * @param charset the desired character encoding - * @return The resulting byte array. - */ - public static byte[] getContentBytes(final String data, String charset) { - - if (data == null) { - throw new IllegalArgumentException("Parameter may not be null"); - } - - if ((charset == null) || (charset.equals(""))) { - charset = DEFAULT_CONTENT_CHARSET; - } - - try { - return data.getBytes(charset); - } catch (UnsupportedEncodingException e) { - - if (LOG.isWarnEnabled()) { - LOG.warn("Unsupported encoding: " - + charset - + ". HTTP default encoding used"); - } - - try { - return data.getBytes(DEFAULT_CONTENT_CHARSET); - } catch (UnsupportedEncodingException e2) { - - if (LOG.isWarnEnabled()) { - LOG.warn("Unsupported encoding: " - + DEFAULT_CONTENT_CHARSET - + ". System encoding used"); - } - - return data.getBytes(); - } - } - } - - /** - * Converts the byte array of HTTP content characters to a string This - * method is to be used when decoding content of HTTP request/response If - * the specified charset is not supported, default HTTP content encoding - * (ISO-8859-1) is applied - * - * @param data the byte array to be encoded - * @param offset the index of the first byte to encode - * @param length the number of bytes to encode - * @param charset the desired character encoding - * @return The result of the conversion. - */ - public static String getContentString( - final byte[] data, - int offset, - int length, - String charset - ) { - - if (data == null) { - throw new IllegalArgumentException("Parameter may not be null"); - } - - if ((charset == null) || (charset.equals(""))) { - charset = DEFAULT_CONTENT_CHARSET; - } - - try { - return new String(data, offset, length, charset); - } catch (UnsupportedEncodingException e) { - - if (LOG.isWarnEnabled()) { - LOG.warn("Unsupported encoding: " + charset + ". Default HTTP encoding used"); - } - - try { - return new String(data, offset, length, DEFAULT_CONTENT_CHARSET); - } catch (UnsupportedEncodingException e2) { - - if (LOG.isWarnEnabled()) { - LOG.warn("Unsupported encoding: " - + DEFAULT_CONTENT_CHARSET - + ". System encoding used"); - } - - return new String(data, offset, length); - } - } - } - - - /** - * Converts the byte array of HTTP content characters to a string This - * method is to be used when decoding content of HTTP request/response If - * the specified charset is not supported, default HTTP content encoding - * (ISO-8859-1) is applied - * - * @param data the byte array to be encoded - * @param charset the desired character encoding - * @return The result of the conversion. - */ - public static String getContentString(final byte[] data, String charset) { - return getContentString(data, 0, data.length, charset); - } - - /** - * Converts the specified string to a byte array of HTTP content characters - * using default HTTP content encoding (ISO-8859-1) This method is to be - * used when encoding content of HTTP request/response - * - * @param data the string to be encoded - * @return The byte array as above. - */ - public static byte[] getContentBytes(final String data) { - return getContentBytes(data, null); - } - - /** - * Converts the byte array of HTTP content characters to a string using - * default HTTP content encoding (ISO-8859-1) This method is to be used when - * decoding content of HTTP request/response - * - * @param data the byte array to be encoded - * @param offset the index of the first byte to encode - * @param length the number of bytes to encode - * @return The string representation of the byte array. - */ - public static String getContentString(final byte[] data, int offset, int length) { - return getContentString(data, offset, length, null); - } - - /** - * Converts the byte array of HTTP content characters to a string using - * default HTTP content encoding (ISO-8859-1) This method is to be used when - * decoding content of HTTP request/response - * - * @param data the byte array to be encoded - * @return The string representation of the byte array. - */ - public static String getContentString(final byte[] data) { - return getContentString(data, null); - } - - /** - * Converts the specified string to byte array of ASCII characters. - * - * @param data the string to be encoded - * @return The string as a byte array. - */ - public static byte[] getAsciiBytes(final String data) { - - if (data == null) { - throw new IllegalArgumentException("Parameter may not be null"); - } - - try { - return data.getBytes("US-ASCII"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException("HttpClient requires ASCII support"); - } - } - - /** - * Converts the byte array of ASCII characters to a string. This method is - * to be used when decoding content of HTTP elements (such as response - * headers) - * - * @param data the byte array to be encoded - * @param offset the index of the first byte to encode - * @param length the number of bytes to encode - * @return The string representation of the byte array - */ - public static String getAsciiString(final byte[] data, int offset, int length) { - - if (data == null) { - throw new IllegalArgumentException("Parameter may not be null"); - } - - try { - return new String(data, offset, length, "US-ASCII"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException("HttpClient requires ASCII support"); - } - } - - /** - * Converts the byte array of ASCII characters to a string. This method is - * to be used when decoding content of HTTP elements (such as response - * headers) - * - * @param data the byte array to be encoded - * @return The string representation of the byte array - */ - public static String getAsciiString(final byte[] data) { - return getAsciiString(data, 0, data.length); - } -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpException.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpException.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpException.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpException.java Tue Jan 3 16:25:34 2006 @@ -30,9 +30,6 @@ package org.apache.commons.httpclient; import java.io.IOException; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.lang.reflect.Method; /** * Signals that an HTTP or HttpClient exception has occurred. @@ -48,7 +45,6 @@ */ public HttpException() { super(); - this.cause = null; } /** @@ -58,7 +54,6 @@ */ public HttpException(String message) { super(message); - this.cause = null; } /** @@ -72,163 +67,6 @@ */ public HttpException(String message, Throwable cause) { super(message); - this.cause = cause; - - // If we're running on JDK 1.4 or later, tell Throwable what the cause was - try { - Class[] paramsClasses = new Class[] { Throwable.class }; - Method initCause = Throwable.class.getMethod("initCause", paramsClasses); - initCause.invoke(this, new Object[] { cause }); - } catch (Exception e) { - // The setCause method must not be available - } - } - - /** - * Return the Throwable that caused this exception, or null - * if the cause is unavailable, unknown, or not a Throwable. - * - * @return the Throwable that caused this exception, or null - * if the cause is unavailable, unknown, or not a Throwable - * - * @since 3.0 - */ - public Throwable getCause() { - return cause; - } - - /** - * Print this HttpException and its stack trace to the standard error stream. - * - * @since 3.0 - */ - public void printStackTrace() { - printStackTrace(System.err); - } - - /** - * Print this HttpException and its stack trace to the specified print stream. - * - * @param s the PrintStream to which the exception and its stack trace - * should be written - * - * @since 3.0 - */ - public void printStackTrace(PrintStream s) { - try { - // JDK 1.4 has a nice printStackTrace method that prints the cause's stack - // trace too and prunes out duplicate stack frames. Call it if possible, - // which is determined by checking whether JDK 1.4's getStackTrace method is present - Class[] paramsClasses = new Class[] { }; - this.getClass().getMethod("getStackTrace", paramsClasses); - super.printStackTrace(s); - } catch (Exception ex) { - // If that didn't work, print it out ourselves - // First print this exception's stack trace. - super.printStackTrace(s); - if (cause != null) { - // Print out the exception that caused this one. - // This will recurse if the cause is another HttpException. - s.print("Caused by: "); - cause.printStackTrace(s); - } - } - } - - /** - * Print this HttpException and its stack trace to the specified print writer. - * - * @param s the PrintWriter to which the exception and its stack trace - * should be written - * - * @since 3.0 - */ - public void printStackTrace(PrintWriter s) { - try { - // JDK 1.4 has a nice printStackTrace method that prints the cause's stack - // trace too and prunes out duplicate stack frames. Call it if possible, - // which is determined by checking whether JDK 1.4's getStackTrace method is present - Class[] paramsClasses = new Class[] { }; - this.getClass().getMethod("getStackTrace", paramsClasses); - super.printStackTrace(s); - } catch (Exception ex) { - // If that didn't work, print it out ourselves - // First print this exception's stack trace. - super.printStackTrace(s); - if (cause != null) { - // Print out the exception that caused this one. - // This will recurse if the cause is another HttpException. - s.print("Caused by: "); - cause.printStackTrace(s); - } + initCause(cause); } - } - - /** - * Sets the text description of the reason for an exception. - * - * @param reason The reason for the exception. - * - * @deprecated HttpClient no longer uses this for itself. It is only - * provided for compatibility with existing clients, and will be removed - * in a future release. - */ - public void setReason(String reason) { - this.reason = reason; - } - - /** - * Get the text description of the reason for an exception. - * - * @deprecated HttpClient no longer uses this for itself. It is only - * provided for compatibility with existing clients, and will be removed - * in a future release. - */ - public String getReason() { - return reason; - } - - /** - * Sets the status code description of the reason for an exception. - * - * @param code The reason for the exception. This is intended to be an - * HTTP status code. - * - * @deprecated HttpClient no longer uses this for itself. It is only - * provided for compatibility with existing clients, and will be removed - * in a future release. - */ - public void setReasonCode(int code) { - reasonCode = code; - } - - /** - * Get the status code description of the reason for an exception. - * - * @deprecated HttpClient no longer uses this for itself. It is only - * provided for compatibility with existing clients, and will be removed - * in a future release. - */ - public int getReasonCode() { - return this.reasonCode; - } - - /** - * A "reason" string provided for compatibility with older clients. - * - * @deprecated HttpClient no longer uses this field for itself. It - * is only provided for compatibility with existing clients. - */ - private String reason; - - /** - * Reason code for compatibility with older clients. - * - * @deprecated HttpClient no longer uses this field for itself. - * It is only provided for compatibility with existing clients. - */ - private int reasonCode = HttpStatus.SC_OK; - - /** The original Throwable representing the cause of this error */ - private final Throwable cause; } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpHost.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpHost.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpHost.java Mon Mar 14 21:23:16 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpHost.java Tue Jan 3 05:39:06 2006 @@ -101,6 +101,7 @@ * URI constructor for HttpHost. * * @param uri the URI. + * @throws URIException */ public HttpHost(final URI uri) throws URIException { this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme())); @@ -121,6 +122,7 @@ /** * @see java.lang.Object#clone() */ + @Override public Object clone() { return new HttpHost(this); } @@ -173,6 +175,7 @@ /** * @see java.lang.Object#toString() */ + @Override public String toString() { StringBuffer buffer = new StringBuffer(50); buffer.append(toURI()); @@ -182,6 +185,7 @@ /** * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(final Object o) { if (o instanceof HttpHost) { @@ -201,14 +205,14 @@ } // everything matches return true; - } else { - return false; } + return false; } /** * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.hostname); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java Tue Jan 3 19:25:40 2006 @@ -63,17 +63,6 @@ String getName(); /** - * Gets the host configuration for this method. The configuration specifies - * the server, port, protocol, and proxy server via which this method will - * send its HTTP request. - * - * @deprecated no longer applicable - * - * @return the HostConfiguration or null if none is set - */ - HostConfiguration getHostConfiguration(); - - /** * Sets the path of the HTTP method. * It is responsibility of the caller to ensure that the path is * properly encoded (URL safe). @@ -116,34 +105,6 @@ void setURI(URI uri) throws URIException; /** - * Defines how strictly the method follows the HTTP protocol specification. - * (See RFC 2616 and other relevant RFCs.) In the strict mode the method precisely - * implements the requirements of the specification, whereas in non-strict mode - * it attempts to mimic the exact behaviour of commonly used HTTP agents, - * which many HTTP servers expect. - * - * @param strictMode true for strict mode, false otherwise - * - * @deprecated Use {@link org.apache.commons.httpclient.params.HttpParams#setParameter(String, Object)} - * to exercise a more granular control over HTTP protocol strictness. - * - * @see #isStrictMode() - */ - void setStrictMode(boolean strictMode); - - /** - * Returns the value of the strict mode flag. - * - * @return true if strict mode is enabled, false otherwise - * - * @deprecated Use {@link org.apache.commons.httpclient.params.HttpParams#setParameter(String, Object)} - * to exercise a more granular control over HTTP protocol strictness. - * - * @see #setStrictMode(boolean) - */ - boolean isStrictMode(); - - /** * Sets the specified request header, overwriting any * previous value. * Note that header-name matching is case insensitive. @@ -417,8 +378,7 @@ InputStream getResponseBodyAsStream() throws IOException; /** - * Returns true if the HTTP method has been already {@link #execute executed}, - * but not {@link #recycle recycled}. + * Returns true if the HTTP method has been already {@link #execute executed}. * * @return true if the method has been executed, false otherwise */ @@ -454,19 +414,6 @@ void abort(); /** - * Recycles the HTTP method so that it can be used again. - * Note that all of the instance variables will be reset - * once this method has been called. This method will also - * release the connection being used by this HTTP method. - * - * @see #releaseConnection() - * - * @deprecated no longer supported and will be removed in the future - * version of HttpClient - */ - void recycle(); - - /** * Releases the connection being used by this HTTP method. In particular the * connection is used to read the response (if there is one) and will be held * until the response has been read. If the connection can be reused by other @@ -529,6 +476,7 @@ /** * Returns {@link HttpMethodParams HTTP protocol parameters} associated with this method. + * @return all associated parameters * * @since 3.0 * @@ -538,6 +486,7 @@ /** * Assigns {@link HttpMethodParams HTTP protocol parameters} for this method. + * @param params parameters to set. * * @since 3.0 * diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpMethodBase.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpMethodBase.java Thu Nov 17 21:20:08 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java Tue Jan 3 20:49:15 2006 @@ -35,7 +35,6 @@ import java.io.InputStream; import java.io.InterruptedIOException; import java.util.Collection; - import org.apache.commons.httpclient.auth.AuthState; import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.cookie.CookieSpec; @@ -44,8 +43,8 @@ import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.util.EncodingUtil; import org.apache.commons.httpclient.util.ExceptionUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * An abstract base implementation of HttpMethod. @@ -99,7 +98,8 @@ // -------------------------------------------------------------- Constants /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpMethodBase.class); + private static final Logger LOG = LoggerFactory + .getLogger(HttpMethodBase.class); // ----------------------------------------------------- Instance variables @@ -150,20 +150,9 @@ /** True if this method has already been executed. */ private boolean used = false; - /** Count of how many times did this HTTP method transparently handle - * a recoverable exception. */ - private int recoverableExceptionCount = 0; - /** the host for this HTTP method, can be null */ private HttpHost httphost = null; - /** - * Handles method retries - * - * @deprecated no loner used - */ - private MethodRetryHandler methodRetryHandler; - /** True if the connection must be closed when no longer needed */ private boolean connectionCloseForced = false; @@ -192,6 +181,7 @@ * No-arg constructor. */ public HttpMethodBase() { + // do nothing } /** @@ -306,20 +296,6 @@ return this.followRedirects; } - /** Sets whether version 1.1 of the HTTP protocol should be used per default. - * - * @param http11 true to use HTTP/1.1, false to use 1.0 - * - * @deprecated Use {@link HttpMethodParams#setVersion(HttpVersion)} - */ - public void setHttp11(boolean http11) { - if (http11) { - this.params.setVersion(HttpVersion.HTTP_1_1); - } else { - this.params.setVersion(HttpVersion.HTTP_1_0); - } - } - /** * Returns true if the HTTP method should automatically handle HTTP * authentication challenges (status code 401, etc.), false otherwise @@ -349,18 +325,6 @@ // ---------------------------------------------- Protected Utility Methods /** - * Returns true if version 1.1 of the HTTP protocol should be - * used per default, false if version 1.0 should be used. - * - * @return true to use HTTP/1.1, false to use 1.0 - * - * @deprecated Use {@link HttpMethodParams#getVersion()} - */ - public boolean isHttp11() { - return this.params.getVersion().equals(HttpVersion.HTTP_1_1); - } - - /** * Sets the path of the HTTP method. * It is responsibility of the caller to ensure that the path is * properly encoded (URL safe). @@ -379,7 +343,7 @@ * @param header the header to add to the request */ public void addRequestHeader(Header header) { - LOG.trace("HttpMethodBase.addRequestHeader(Header)"); + LOG.debug("HttpMethodBase.addRequestHeader(Header)"); if (header == null) { LOG.debug("null header value ignored"); @@ -435,7 +399,7 @@ * @see #setQueryString(String) */ public void setQueryString(NameValuePair[] params) { - LOG.trace("enter HttpMethodBase.setQueryString(NameValuePair[])"); + LOG.debug("enter HttpMethodBase.setQueryString(NameValuePair[])"); queryString = EncodingUtil.formUrlEncode(params, "UTF-8"); } @@ -491,11 +455,9 @@ * @since 3.0 */ public Header getRequestHeader(String headerName) { - if (headerName == null) { - return null; - } else { - return getRequestHeaderGroup().getCondensedHeader(headerName); - } + return (headerName == null) + ? null + : getRequestHeaderGroup().getCondensedHeader(headerName); } /** @@ -605,11 +567,9 @@ * @return the matching header */ public Header getResponseHeader(String headerName) { - if (headerName == null) { - return null; - } else { - return getResponseHeaderGroup().getCondensedHeader(headerName); - } + return (headerName == null) + ? null + : getResponseHeaderGroup().getCondensedHeader(headerName); } @@ -697,11 +657,8 @@ * If response body is not available, returns null * * @return The response body - * - * @throws IOException If an I/O (transport) problem occurs while obtaining the - * response body. */ - public InputStream getResponseBodyAsStream() throws IOException { + public InputStream getResponseBodyAsStream() { if (responseStream != null) { return responseStream; } @@ -734,11 +691,9 @@ if (responseAvailable()) { rawdata = getResponseBody(); } - if (rawdata != null) { - return EncodingUtil.getString(rawdata, getResponseCharSet()); - } else { - return null; - } + return (rawdata != null) + ? EncodingUtil.getString(rawdata, getResponseCharSet()) + : null; } /** @@ -764,11 +719,9 @@ * @return the matching footer */ public Header getResponseFooter(String footerName) { - if (footerName == null) { - return null; - } else { - return getResponseTrailerHeaderGroup().getCondensedHeader(footerName); - } + return (footerName == null) + ? null + : getResponseTrailerHeaderGroup().getCondensedHeader(footerName); } /** @@ -802,36 +755,6 @@ } /** - * Defines how strictly HttpClient follows the HTTP protocol specification - * (RFC 2616 and other relevant RFCs). In the strict mode HttpClient precisely - * implements the requirements of the specification, whereas in non-strict mode - * it attempts to mimic the exact behaviour of commonly used HTTP agents, - * which many HTTP servers expect. - * - * @param strictMode true for strict mode, false otherwise - * - * @deprecated Use {@link org.apache.commons.httpclient.params.HttpParams#setParameter(String, Object)} - * to exercise a more granular control over HTTP protocol strictness. - */ - public void setStrictMode(boolean strictMode) { - if (strictMode) { - this.params.makeStrict(); - } else { - this.params.makeLenient(); - } - } - - /** - * @deprecated Use {@link org.apache.commons.httpclient.params.HttpParams#setParameter(String, Object)} - * to exercise a more granular control over HTTP protocol strictness. - * - * @return false - */ - public boolean isStrictMode() { - return false; - } - - /** * Adds the specified request header, NOT overwriting any previous value. * Note that header-name matching is case insensitive. * @@ -973,7 +896,7 @@ public int execute(HttpState state, HttpConnection conn) throws HttpException, IOException { - LOG.trace("enter HttpMethodBase.execute(HttpState, HttpConnection)"); + LOG.debug("enter HttpMethodBase.execute(HttpState, HttpConnection)"); // this is our connection now, assign it to a local variable so // that it can be released later @@ -1016,8 +939,7 @@ } /** - * Returns true if the HTTP method has been already {@link #execute executed}, - * but not {@link #recycle recycled}. + * Returns true if the HTTP method has been already {@link #execute executed}. * * @return true if the method has been executed, false otherwise */ @@ -1026,43 +948,6 @@ } /** - * Recycles the HTTP method so that it can be used again. - * Note that all of the instance variables will be reset - * once this method has been called. This method will also - * release the connection being used by this HTTP method. - * - * @see #releaseConnection() - * - * @deprecated no longer supported and will be removed in the future - * version of HttpClient - */ - public void recycle() { - LOG.trace("enter HttpMethodBase.recycle()"); - - releaseConnection(); - - path = null; - followRedirects = false; - doAuthentication = true; - queryString = null; - getRequestHeaderGroup().clear(); - getResponseHeaderGroup().clear(); - getResponseTrailerHeaderGroup().clear(); - statusLine = null; - effectiveVersion = null; - aborted = false; - used = false; - params = new HttpMethodParams(); - responseBody = null; - recoverableExceptionCount = 0; - connectionCloseForced = false; - hostAuthState.invalidate(); - proxyAuthState.invalidate(); - cookiespec = null; - requestSent = false; - } - - /** * Releases the connection being used by this HTTP method. In particular the * connection is used to read the response(if there is one) and will be held * until the response has been read. If the connection can be reused by other @@ -1077,6 +962,7 @@ // FYI - this may indirectly invoke responseBodyConsumed. this.responseStream.close(); } catch (IOException ignore) { + // ignored } } } finally { @@ -1130,14 +1016,9 @@ * * @return cookie spec */ - private CookieSpec getCookieSpec(final HttpState state) { + private CookieSpec getCookieSpec() { if (this.cookiespec == null) { - int i = state.getCookiePolicy(); - if (i == -1) { this.cookiespec = CookiePolicy.getCookieSpec(this.params.getCookiePolicy()); - } else { - this.cookiespec = CookiePolicy.getSpecByPolicy(i); - } this.cookiespec.setValidDateFormats( (Collection)this.params.getParameter(HttpMethodParams.DATE_PATTERNS)); } @@ -1151,16 +1032,10 @@ * @param state the {@link HttpState state} information associated with this method * @param conn the {@link HttpConnection connection} used to execute * this HTTP method - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. */ - protected void addCookieRequestHeader(HttpState state, HttpConnection conn) - throws IOException, HttpException { + protected void addCookieRequestHeader(HttpState state, HttpConnection conn) { - LOG.trace("enter HttpMethodBase.addCookieRequestHeader(HttpState, " + LOG.debug("enter HttpMethodBase.addCookieRequestHeader(HttpState, " + "HttpConnection)"); Header[] cookieheaders = getRequestHeaderGroup().getHeaders("Cookie"); @@ -1171,7 +1046,7 @@ } } - CookieSpec matcher = getCookieSpec(state); + CookieSpec matcher = getCookieSpec(); String host = this.params.getVirtualHost(); if (host == null) { host = conn.getHost(); @@ -1200,15 +1075,9 @@ * @param state the {@link HttpState state} information associated with this method * @param conn the {@link HttpConnection connection} used to execute * this HTTP method - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. */ - protected void addHostRequestHeader(HttpState state, HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter HttpMethodBase.addHostRequestHeader(HttpState, " + protected void addHostRequestHeader(HttpState state, HttpConnection conn) { + LOG.debug("enter HttpMethodBase.addHostRequestHeader(HttpState, " + "HttpConnection)"); // Per 19.6.1.1 of RFC 2616, it is legal for HTTP/1.0 based @@ -1250,16 +1119,10 @@ * @param state the {@link HttpState state} information associated with this method * @param conn the {@link HttpConnection connection} used to execute * this HTTP method - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. */ protected void addProxyConnectionHeader(HttpState state, - HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter HttpMethodBase.addProxyConnectionHeader(" + HttpConnection conn) { + LOG.debug("enter HttpMethodBase.addProxyConnectionHeader(" + "HttpState, HttpConnection)"); if (!conn.isTransparent()) { if (getRequestHeader("Proxy-Connection") == null) { @@ -1287,17 +1150,13 @@ * @param state the {@link HttpState state} information associated with this method * @param conn the {@link HttpConnection connection} used to execute * this HTTP method - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. + * @throws IOException + * @throws HttpException * * @see #writeRequestHeaders */ - protected void addRequestHeaders(HttpState state, HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter HttpMethodBase.addRequestHeaders(HttpState, " + protected void addRequestHeaders(HttpState state, HttpConnection conn) throws HttpException, IOException { + LOG.debug("enter HttpMethodBase.addRequestHeaders(HttpState, " + "HttpConnection)"); addUserAgentRequestHeader(state, conn); @@ -1313,16 +1172,10 @@ * @param state the {@link HttpState state} information associated with this method * @param conn the {@link HttpConnection connection} used to execute * this HTTP method - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. */ protected void addUserAgentRequestHeader(HttpState state, - HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter HttpMethodBase.addUserAgentRequestHeaders(HttpState, " + HttpConnection conn) { + LOG.debug("enter HttpMethodBase.addUserAgentRequestHeaders(HttpState, " + "HttpConnection)"); if (getRequestHeader("User-Agent") == null) { @@ -1336,7 +1189,7 @@ /** * Throws an {@link IllegalStateException} if the HTTP method has been already - * {@link #execute executed}, but not {@link #recycle recycled}. + * {@link #execute executed}. * * @throws IllegalStateException if the method has been used and not * recycled @@ -1349,7 +1202,7 @@ /** * Throws an {@link IllegalStateException} if the HTTP method has not been - * {@link #execute executed} since last {@link #recycle recycle}. + * {@link #execute executed}. * * * @throws IllegalStateException if not used @@ -1376,7 +1229,7 @@ */ protected static String generateRequestLine(HttpConnection connection, String name, String requestPath, String query, String version) { - LOG.trace("enter HttpMethodBase.generateRequestLine(HttpConnection, " + LOG.debug("enter HttpMethodBase.generateRequestLine(HttpConnection, " + "String, String, String, String)"); StringBuffer buf = new StringBuffer(); @@ -1434,9 +1287,10 @@ * this HTTP method * * @see #readResponse - * @see #readResponseBody + * @see #readResponse(HttpState, HttpConnection) */ protected void processResponseBody(HttpState state, HttpConnection conn) { + //does nothing } /** @@ -1459,7 +1313,7 @@ */ protected void processResponseHeaders(HttpState state, HttpConnection conn) { - LOG.trace("enter HttpMethodBase.processResponseHeaders(HttpState, " + LOG.debug("enter HttpMethodBase.processResponseHeaders(HttpState, " + "HttpConnection)"); Header[] headers = getResponseHeaderGroup().getHeaders("set-cookie2"); @@ -1469,7 +1323,7 @@ headers = getResponseHeaderGroup().getHeaders("set-cookie"); } - CookieSpec parser = getCookieSpec(state); + CookieSpec parser = getCookieSpec(); String host = this.params.getVirtualHost(); if (host == null) { host = conn.getHost(); @@ -1530,6 +1384,7 @@ * @see #readStatusLine */ protected void processStatusLine(HttpState state, HttpConnection conn) { + // does nothing } /** @@ -1582,7 +1437,7 @@ */ protected void readResponse(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace( + LOG.debug( "enter HttpMethodBase.readResponse(HttpState, HttpConnection)"); // Status line & line may have already been received // if 'expect - continue' handshake has been used @@ -1633,7 +1488,7 @@ */ protected void readResponseBody(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace( + LOG.debug( "enter HttpMethodBase.readResponseBody(HttpState, HttpConnection)"); // assume we are not done with the connection if we get a stream @@ -1668,7 +1523,7 @@ private InputStream readResponseBody(HttpConnection conn) throws HttpException, IOException { - LOG.trace("enter HttpMethodBase.readResponseBody(HttpConnection)"); + LOG.debug("enter HttpMethodBase.readResponseBody(HttpConnection)"); responseBody = null; InputStream is = conn.getResponseInputStream(); @@ -1700,9 +1555,8 @@ } else { if (getParams().isParameterTrue(HttpMethodParams.STRICT_TRANSFER_ENCODING)) { throw new ProtocolException("Chunk-encoded body declared but not sent"); - } else { - LOG.warn("Chunk-encoded body missing"); } + LOG.warn("Chunk-encoded body missing"); } } else { LOG.info("Response content is not chunk-encoded"); @@ -1782,7 +1636,7 @@ */ protected void readResponseHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace("enter HttpMethodBase.readResponseHeaders(HttpState," + LOG.debug("enter HttpMethodBase.readResponseHeaders(HttpState," + "HttpConnection)"); getResponseHeaderGroup().clear(); @@ -1820,7 +1674,7 @@ */ protected void readStatusLine(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace("enter HttpMethodBase.readStatusLine(HttpState, HttpConnection)"); + LOG.debug("enter HttpMethodBase.readStatusLine(HttpState, HttpConnection)"); final int maxGarbageLines = getParams(). getIntParameter(HttpMethodParams.STATUS_LINE_GARBAGE_LIMIT, Integer.MAX_VALUE); @@ -1913,7 +1767,7 @@ */ protected void writeRequest(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace( + LOG.debug( "enter HttpMethodBase.writeRequest(HttpState, HttpConnection)"); writeRequestLine(state, conn); writeRequestHeaders(state, conn); @@ -1993,14 +1847,9 @@ * this HTTP method * * @return true - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. + * @throws IOException */ - protected boolean writeRequestBody(HttpState state, HttpConnection conn) - throws IOException, HttpException { + protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException { return true; } @@ -2027,11 +1876,11 @@ * cannot be recovered from. * * @see #addRequestHeaders - * @see #getRequestHeaders + * @see #getRequestHeaders() */ protected void writeRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace("enter HttpMethodBase.writeRequestHeaders(HttpState," + LOG.debug("enter HttpMethodBase.writeRequestHeaders(HttpState," + "HttpConnection)"); addRequestHeaders(state, conn); @@ -2068,7 +1917,7 @@ */ protected void writeRequestLine(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace( + LOG.debug( "enter HttpMethodBase.writeRequestLine(HttpState, HttpConnection)"); String requestLine = getRequestLine(conn); if (Wire.HEADER_WIRE.enabled()) { @@ -2091,22 +1940,14 @@ } /** - * Returns {@link HttpMethodParams HTTP protocol parameters} associated with this method. - * - * @return HTTP parameters. - * - * @since 3.0 + * {@inheritDoc} */ public HttpMethodParams getParams() { return this.params; } /** - * Assigns {@link HttpMethodParams HTTP protocol parameters} for this method. - * - * @since 3.0 - * - * @see HttpMethodParams + * {@inheritDoc} */ public void setParams(final HttpMethodParams params) { if (params == null) { @@ -2137,7 +1978,7 @@ * contain a message body */ private static boolean canResponseHaveBody(int status) { - LOG.trace("enter HttpMethodBase.canResponseHaveBody(int)"); + LOG.debug("enter HttpMethodBase.canResponseHaveBody(int)"); boolean result = true; @@ -2150,37 +1991,13 @@ } /** - * Returns proxy authentication realm, if it has been used during authentication process. - * Otherwise returns null. - * - * @return proxy authentication realm - * - * @deprecated use #getProxyAuthState() - */ - public String getProxyAuthenticationRealm() { - return this.proxyAuthState.getRealm(); - } - - /** - * Returns authentication realm, if it has been used during authentication process. - * Otherwise returns null. - * - * @return authentication realm - * - * @deprecated use #getHostAuthState() - */ - public String getAuthenticationRealm() { - return this.hostAuthState.getRealm(); - } - - /** * Returns the character set from the Content-Type header. * * @param contentheader The content header. * @return String The character set. */ protected String getContentCharSet(Header contentheader) { - LOG.trace("enter getContentCharSet( Header contentheader )"); + LOG.debug("enter getContentCharSet( Header contentheader )"); String charset = null; if (contentheader != null) { HeaderElement values[] = contentheader.getElements(); @@ -2225,18 +2042,6 @@ } /** - * @deprecated no longer used - * - * Returns the number of "recoverable" exceptions thrown and handled, to - * allow for monitoring the quality of the connection. - * - * @return The number of recoverable exceptions handled by the method. - */ - public int getRecoverableExceptionCount() { - return recoverableExceptionCount; - } - - /** * A response has been consumed. * *

The default behavior for this class is to check to see if the connection @@ -2289,58 +2094,6 @@ responseConnection.releaseConnection(); responseConnection = null; } - } - - /** - * Returns the {@link HostConfiguration host configuration}. - * - * @return the host configuration - * - * @deprecated no longer applicable - */ - public HostConfiguration getHostConfiguration() { - HostConfiguration hostconfig = new HostConfiguration(); - hostconfig.setHost(this.httphost); - return hostconfig; - } - /** - * Sets the {@link HostConfiguration host configuration}. - * - * @param hostconfig The hostConfiguration to set - * - * @deprecated no longer applicable - */ - public void setHostConfiguration(final HostConfiguration hostconfig) { - if (hostconfig != null) { - this.httphost = new HttpHost( - hostconfig.getHost(), - hostconfig.getPort(), - hostconfig.getProtocol()); - } else { - this.httphost = null; - } - } - - /** - * Returns the {@link MethodRetryHandler retry handler} for this HTTP method - * - * @return the methodRetryHandler - * - * @deprecated use {@link HttpMethodParams} - */ - public MethodRetryHandler getMethodRetryHandler() { - return methodRetryHandler; - } - - /** - * Sets the {@link MethodRetryHandler retry handler} for this HTTP method - * - * @param handler the methodRetryHandler to use when this method executed - * - * @deprecated use {@link HttpMethodParams} - */ - public void setMethodRetryHandler(MethodRetryHandler handler) { - methodRetryHandler = handler; } /** diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpMethodDirector.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpMethodDirector.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpMethodDirector.java Mon Nov 7 22:32:36 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpMethodDirector.java Tue Jan 3 19:36:36 2006 @@ -35,24 +35,23 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; - import org.apache.commons.httpclient.auth.AuthChallengeException; import org.apache.commons.httpclient.auth.AuthChallengeParser; import org.apache.commons.httpclient.auth.AuthChallengeProcessor; import org.apache.commons.httpclient.auth.AuthScheme; +import org.apache.commons.httpclient.auth.AuthScope; import org.apache.commons.httpclient.auth.AuthState; import org.apache.commons.httpclient.auth.AuthenticationException; -import org.apache.commons.httpclient.auth.CredentialsProvider; import org.apache.commons.httpclient.auth.CredentialsNotAvailableException; -import org.apache.commons.httpclient.auth.AuthScope; +import org.apache.commons.httpclient.auth.CredentialsProvider; import org.apache.commons.httpclient.auth.MalformedChallengeException; import org.apache.commons.httpclient.params.HostParams; import org.apache.commons.httpclient.params.HttpClientParams; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.params.HttpMethodParams; import org.apache.commons.httpclient.params.HttpParams; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Handles the process of executing a method including authentication, redirection and retries. @@ -73,8 +72,8 @@ /** The proxy authenticate response header. */ public static final String PROXY_AUTH_RESP = "Proxy-Authorization"; - private static final Log LOG = LogFactory.getLog(HttpMethodDirector.class); - + private static final Logger LOG = LoggerFactory + .getLogger(HttpMethodDirector.class); private ConnectMethod connectMethod; private HttpState state; @@ -93,8 +92,14 @@ /** Authentication processor */ private AuthChallengeProcessor authProcessor = null; - private Set redirectLocations = null; + private Set redirectLocations = null; + /** + * @param connectionManager + * @param hostConfiguration + * @param params + * @param state + */ public HttpMethodDirector( final HttpConnectionManager connectionManager, final HostConfiguration hostConfiguration, @@ -112,6 +117,7 @@ /** * Executes the method associated with this method director. + * @param method * * @throws IOException * @throws HttpException @@ -154,8 +160,7 @@ this.params.getConnectionManagerTimeout() ); this.conn.setLocked(true); - if (this.params.isAuthenticationPreemptive() - || this.state.isAuthenticationPreemptive()) + if (this.params.isAuthenticationPreemptive()) { LOG.debug("Preemptively sending default basic credentials"); method.getHostAuthState().setPreemptive(); @@ -374,8 +379,8 @@ execCount++; try { - if (LOG.isTraceEnabled()) { - LOG.trace("Attempt number " + execCount + " to process request"); + if (LOG.isDebugEnabled()) { + LOG.debug("Attempt number " + execCount + " to process request"); } if (this.conn.getParams().isStaleCheckingEnabled()) { this.conn.closeIfStale(); @@ -404,25 +409,6 @@ this.conn.close(); // test if this method should be retried // ======================================== - // this code is provided for backward compatibility with 2.0 - // will be removed in the next major release - if (method instanceof HttpMethodBase) { - MethodRetryHandler handler = - ((HttpMethodBase)method).getMethodRetryHandler(); - if (handler != null) { - if (!handler.retryMethod( - method, - this.conn, - new HttpRecoverableException(e.getMessage()), - execCount, - method.isRequestSent())) { - LOG.debug("Method retry handler returned false. " - + "Automatic recovery will not be attempted"); - throw e; - } - } - } - // ======================================== HttpMethodRetryHandler handler = (HttpMethodRetryHandler)method.getParams().getParameter( HttpMethodParams.RETRY_HANDLER); @@ -480,8 +466,7 @@ if (!this.conn.isOpen()) { this.conn.open(); } - if (this.params.isAuthenticationPreemptive() - || this.state.isAuthenticationPreemptive()) { + if (this.params.isAuthenticationPreemptive()) { LOG.debug("Preemptively sending default basic credentials"); this.connectMethod.getProxyAuthState().setPreemptive(); this.connectMethod.getProxyAuthState().setAuthAttempted(true); @@ -514,19 +499,16 @@ // Drop the connect method, as it is no longer needed this.connectMethod = null; return true; - } else { - return false; } + return false; } /** * Fake response * @param method - * @return */ - private void fakeResponse(final HttpMethod method) - throws IOException, HttpException { + private void fakeResponse(final HttpMethod method) { // What is to follow is an ugly hack. // I REALLY hate having to resort to such // an appalling trick @@ -599,12 +581,11 @@ if (this.params.isParameterTrue(HttpClientParams.REJECT_RELATIVE_REDIRECT)) { LOG.warn("Relative redirect location '" + location + "' not allowed"); return false; - } else { + } //location is incomplete, use current values for defaults LOG.debug("Redirect URI is not absolute - parsing as relative"); redirectUri = new URI(currentUri, redirectUri); } - } method.setURI(redirectUri); hostConfiguration.setHost(redirectUri); } catch (URIException e) { @@ -614,7 +595,7 @@ if (this.params.isParameterFalse(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS)) { if (this.redirectLocations == null) { - this.redirectLocations = new HashSet(); + this.redirectLocations = new HashSet(); } this.redirectLocations.add(currentUri); try { @@ -651,7 +632,7 @@ * and matching credentials have been found), false otherwise. */ private boolean processAuthenticationResponse(final HttpMethod method) { - LOG.trace("enter HttpMethodBase.processAuthenticationResponse(" + LOG.debug("enter HttpMethodBase.processAuthenticationResponse(" + "HttpState, HttpConnection)"); try { @@ -714,10 +695,9 @@ LOG.info("Failure authenticating with " + authscope); } return false; - } else { + } return true; } - } else { authstate.setAuthAttempted(true); Credentials credentials = this.state.getCredentials(authscope); if (credentials == null) { @@ -729,10 +709,8 @@ LOG.info("No credentials available for " + authscope); } return false; - } else { - return true; - } } + return true; } private boolean processProxyAuthChallenge(final HttpMethod method) @@ -773,10 +751,9 @@ LOG.info("Failure authenticating with " + authscope); } return false; - } else { + } return true; } - } else { authstate.setAuthAttempted(true); Credentials credentials = this.state.getProxyCredentials(authscope); if (credentials == null) { @@ -788,10 +765,8 @@ LOG.info("No credentials available for " + authscope); } return false; - } else { - return true; - } } + return true; } /** @@ -810,11 +785,10 @@ LOG.debug("Redirect required"); if (method.getFollowRedirects()) { return true; - } else { + } LOG.info("Redirect requested but followRedirects is " + "disabled"); return false; - } default: return false; } //end of switch @@ -837,15 +811,13 @@ LOG.debug("Authorization required"); if (method.getDoAuthentication()) { //process authentication response return true; - } else { //let the client handle the authenticaiton + }//let the client handle the authenticaiton LOG.info("Authentication requested but doAuthentication is " + "disabled"); return false; } - } else { return false; } - } private Credentials promptForCredentials( final AuthScheme authScheme, @@ -904,28 +876,28 @@ } /** - * @return + * @return current hostconfiguration */ public HostConfiguration getHostConfiguration() { return hostConfiguration; } /** - * @return + * @return current http state */ public HttpState getState() { return state; } /** - * @return + * @return connection manager in use */ public HttpConnectionManager getConnectionManager() { return connectionManager; } /** - * @return + * @return parameters set */ public HttpParams getParams() { return this.params; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpParser.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpParser.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpParser.java Wed Jun 1 22:04:58 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpParser.java Tue Jan 3 19:42:21 2006 @@ -29,14 +29,13 @@ package org.apache.commons.httpclient; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.ByteArrayOutputStream; import java.util.ArrayList; - import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A utility class for parsing http header values according to @@ -50,12 +49,14 @@ public class HttpParser { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpParser.class); + private static final Logger LOG = LoggerFactory.getLogger(HttpParser.class); /** * Constructor for HttpParser. */ - private HttpParser() { } + private HttpParser() { + // singleton + } /** * Return byte array from an (unchunked) input stream. @@ -70,7 +71,7 @@ * @return a byte array from the stream */ public static byte[] readRawLine(InputStream inputStream) throws IOException { - LOG.trace("enter HttpParser.readRawLine()"); + LOG.debug("enter HttpParser.readRawLine()"); ByteArrayOutputStream buf = new ByteArrayOutputStream(); int ch; @@ -101,7 +102,7 @@ * @since 3.0 */ public static String readLine(InputStream inputStream, String charset) throws IOException { - LOG.trace("enter HttpParser.readLine(InputStream, String)"); + LOG.debug("enter HttpParser.readLine(InputStream, String)"); byte[] rawdata = readRawLine(inputStream); if (rawdata == null) { return null; @@ -123,25 +124,6 @@ } /** - * Read up to "\n" from an (unchunked) input stream. - * If the stream ends before the line terminator is found, - * the last part of the string will still be returned. - * If no input data available, null is returned - * - * @param inputStream the stream to read from - * - * @throws IOException if an I/O problem occurs - * @return a line from the stream - * - * @deprecated use #readLine(InputStream, String) - */ - - public static String readLine(InputStream inputStream) throws IOException { - LOG.trace("enter HttpParser.readLine(InputStream)"); - return readLine(inputStream, "US-ASCII"); - } - - /** * Parses headers from the given stream. Headers with the same name are not * combined. * @@ -156,9 +138,9 @@ * @since 3.0 */ public static Header[] parseHeaders(InputStream is, String charset) throws IOException, HttpException { - LOG.trace("enter HeaderParser.parseHeaders(InputStream, String)"); + LOG.debug("enter HeaderParser.parseHeaders(InputStream, String)"); - ArrayList headers = new ArrayList(); + ArrayList

headers = new ArrayList
(); String name = null; StringBuffer value = null; for (; ;) { @@ -201,24 +183,6 @@ headers.add(new Header(name, value.toString())); } - return (Header[]) headers.toArray(new Header[headers.size()]); - } - - /** - * Parses headers from the given stream. Headers with the same name are not - * combined. - * - * @param is the stream to read headers from - * - * @return an array of headers in the order in which they were parsed - * - * @throws IOException if an IO error occurs while reading from the stream - * @throws HttpException if there is an error parsing a header value - * - * @deprecated use #parseHeaders(InputStream, String) - */ - public static Header[] parseHeaders(InputStream is) throws IOException, HttpException { - LOG.trace("enter HeaderParser.parseHeaders(InputStream, String)"); - return parseHeaders(is, "US-ASCII"); + return headers.toArray(new Header[headers.size()]); } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpRecoverableException.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpRecoverableException.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpRecoverableException.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpRecoverableException.java Thu Jan 1 01:00:00 1970 @@ -1,63 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpRecoverableException.java,v 1.15 2004/07/05 22:46:58 olegk Exp $ - * $Revision: 155418 $ - * $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - * - * ==================================================================== - * - * Copyright 1999-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient; - -/** - *

- * Signals that an HTTP or HttpClient exception has occurred. This - * exception may have been caused by a transient error and the request - * may be retried. It may be possible to retrieve the underlying transient - * error via the inherited {@link HttpException#getCause()} method. - *

- * - * @deprecated no longer used - * - * @author Unascribed - * @version $Revision: 155418 $ $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - */ -public class HttpRecoverableException extends HttpException { - - /** - * Creates a new HttpRecoverableException with a null detail message. - */ - public HttpRecoverableException() { - super(); - } - - /** - * Creates a new HttpRecoverableException with the specified detail message. - * - * @param message exception message - */ - public HttpRecoverableException(String message) { - super(message); - } - -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpState.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpState.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpState.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpState.java Tue Jan 3 19:40:20 2006 @@ -32,14 +32,12 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.Map; -import java.util.List; import java.util.Iterator; -import org.apache.commons.httpclient.cookie.CookieSpec; -import org.apache.commons.httpclient.cookie.CookiePolicy; +import java.util.List; +import java.util.Map; import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

@@ -68,38 +66,24 @@ * Map of {@link Credentials credentials} by realm that this * HTTP state contains. */ - private HashMap credMap = new HashMap(); + private HashMap credMap = + new HashMap(); /** * Map of {@link Credentials proxy credentials} by realm that this * HTTP state contains */ - private HashMap proxyCred = new HashMap(); + private HashMap proxyCred = + new HashMap(); /** * Array of {@link Cookie cookies} that this HTTP state contains. */ - private ArrayList cookies = new ArrayList(); - - private boolean preemptive = false; - - private int cookiePolicy = -1; + private ArrayList cookies = new ArrayList(); // -------------------------------------------------------- Class Variables - /** - * The boolean system property name to turn on preemptive authentication. - * @deprecated This field and feature will be removed following HttpClient 3.0. - */ - public static final String PREEMPTIVE_PROPERTY = "httpclient.authentication.preemptive"; - - /** - * The default value for {@link #PREEMPTIVE_PROPERTY}. - * @deprecated This field and feature will be removed following HttpClient 3.0. - */ - public static final String PREEMPTIVE_DEFAULT = "false"; - /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpState.class); + private static final Logger LOG = LoggerFactory.getLogger(HttpState.class); /** * Default constructor. @@ -121,7 +105,7 @@ * */ public synchronized void addCookie(Cookie cookie) { - LOG.trace("enter HttpState.addCookie(Cookie)"); + LOG.debug("enter HttpState.addCookie(Cookie)"); if (cookie != null) { // first remove any old cookie that is equivalent @@ -150,7 +134,7 @@ * */ public synchronized void addCookies(Cookie[] cookies) { - LOG.trace("enter HttpState.addCookies(Cookie[])"); + LOG.debug("enter HttpState.addCookies(Cookie[])"); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { @@ -165,57 +149,22 @@ * * @return an array of {@link Cookie cookies}. * - * @see #getCookies(String, int, String, boolean) - * */ public synchronized Cookie[] getCookies() { - LOG.trace("enter HttpState.getCookies()"); - return (Cookie[]) (cookies.toArray(new Cookie[cookies.size()])); - } - - /** - * Returns an array of {@link Cookie cookies} in this HTTP - * state that match the given request parameters. - * - * @param domain the request domain - * @param port the request port - * @param path the request path - * @param secure true when using HTTPS - * - * @return an array of {@link Cookie cookies}. - * - * @see #getCookies() - * - * @deprecated use CookieSpec#match(String, int, String, boolean, Cookie) - */ - public synchronized Cookie[] getCookies( - String domain, - int port, - String path, - boolean secure - ) { - LOG.trace("enter HttpState.getCookies(String, int, String, boolean)"); - - CookieSpec matcher = CookiePolicy.getDefaultSpec(); - ArrayList list = new ArrayList(cookies.size()); - for (int i = 0, m = cookies.size(); i < m; i++) { - Cookie cookie = (Cookie) (cookies.get(i)); - if (matcher.match(domain, port, path, secure, cookie)) { - list.add(cookie); - } - } - return (Cookie[]) (list.toArray(new Cookie[list.size()])); + LOG.debug("enter HttpState.getCookies()"); + return cookies.toArray(new Cookie[cookies.size()]); } /** * Removes all of {@link Cookie cookies} in this HTTP state * that have expired according to the current system time. + * @return true on success * * @see #purgeExpiredCookies(java.util.Date) * */ public synchronized boolean purgeExpiredCookies() { - LOG.trace("enter HttpState.purgeExpiredCookies()"); + LOG.debug("enter HttpState.purgeExpiredCookies()"); return purgeExpiredCookies(new Date()); } @@ -232,7 +181,7 @@ * @see #purgeExpiredCookies() */ public synchronized boolean purgeExpiredCookies(Date date) { - LOG.trace("enter HttpState.purgeExpiredCookies(Date)"); + LOG.debug("enter HttpState.purgeExpiredCookies(Date)"); boolean removed = false; Iterator it = cookies.iterator(); while (it.hasNext()) { @@ -244,100 +193,6 @@ return removed; } - - /** - * Returns the current {@link CookiePolicy cookie policy} for this - * HTTP state. - * - * @return The {@link CookiePolicy cookie policy}. - * - * @deprecated Use - * {@link org.apache.commons.httpclient.params.HttpMethodParams#getCookiePolicy()}, - * {@link HttpMethod#getParams()}. - */ - - public int getCookiePolicy() { - return this.cookiePolicy; - } - - - /** - * Defines whether preemptive authentication should be - * attempted. - * - * @param value true if preemptive authentication should be - * attempted, false otherwise. - * - * @deprecated Use - * {@link org.apache.commons.httpclient.params.HttpClientParams#setAuthenticationPreemptive(boolean)}, - * {@link HttpClient#getParams()}. - */ - - public void setAuthenticationPreemptive(boolean value) { - this.preemptive = value; - } - - - /** - * Returns true if preemptive authentication should be - * attempted, false otherwise. - * - * @return boolean flag. - * - * @deprecated Use - * {@link org.apache.commons.httpclient.params.HttpClientParams#isAuthenticationPreemptive()}, - * {@link HttpClient#getParams()}. - */ - - public boolean isAuthenticationPreemptive() { - return this.preemptive; - } - - - /** - * Sets the current {@link CookiePolicy cookie policy} for this HTTP - * state to one of the following supported policies: - * {@link CookiePolicy#COMPATIBILITY}, - * {@link CookiePolicy#NETSCAPE_DRAFT} or - * {@link CookiePolicy#RFC2109}. - * - * @param policy new {@link CookiePolicy cookie policy} - * - * @deprecated - * Use {@link org.apache.commons.httpclient.params.HttpMethodParams#setCookiePolicy(String)}, - * {@link HttpMethod#getParams()}. - */ - - public void setCookiePolicy(int policy) { - this.cookiePolicy = policy; - } - - /** - * Sets the {@link Credentials credentials} for the given authentication - * realm on the given host. The null realm signifies default - * credentials for the given host, which should be used when no - * {@link Credentials credentials} have been explictly supplied for the - * challenging realm. The null host signifies default - * credentials, which should be used when no {@link Credentials credentials} - * have been explictly supplied for the challenging host. Any previous - * credentials for the given realm on the given host will be overwritten. - * - * @param realm the authentication realm - * @param host the host the realm belongs to - * @param credentials the authentication {@link Credentials credentials} - * for the given realm. - * - * @see #getCredentials(String, String) - * @see #setProxyCredentials(String, String, Credentials) - * - * @deprecated use #setCredentials(AuthScope, Credentials) - */ - - public synchronized void setCredentials(String realm, String host, Credentials credentials) { - LOG.trace("enter HttpState.setCredentials(String, String, Credentials)"); - credMap.put(new AuthScope(host, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME), credentials); - } - /** * Sets the {@link Credentials credentials} for the given authentication * scope. Any previous credentials for the given scope will be overwritten. @@ -355,7 +210,7 @@ if (authscope == null) { throw new IllegalArgumentException("Authentication scope may not be null"); } - LOG.trace("enter HttpState.setCredentials(AuthScope, Credentials)"); + LOG.debug("enter HttpState.setCredentials(AuthScope, Credentials)"); credMap.put(authscope, credentials); } @@ -392,33 +247,6 @@ } /** - * Get the {@link Credentials credentials} for the given authentication scope on the - * given host. - * - * If the realm exists on host, return the coresponding credentials. - * If the host exists with a null realm, return the corresponding - * credentials. - * If the realm exists with a null host, return the - * corresponding credentials. If the realm does not exist, return - * the default Credentials. If there are no default credentials, return - * null. - * - * @param realm the authentication realm - * @param host the host the realm is on - * @return the credentials - * - * @see #setCredentials(String, String, Credentials) - * - * @deprecated use #getCredentials(AuthScope) - */ - - public synchronized Credentials getCredentials(String realm, String host) { - LOG.trace("enter HttpState.getCredentials(String, String"); - return matchCredentials(this.credMap, - new AuthScope(host, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME)); - } - - /** * Get the {@link Credentials credentials} for the given authentication scope. * * @param authscope the {@link AuthScope authentication scope} @@ -432,40 +260,11 @@ if (authscope == null) { throw new IllegalArgumentException("Authentication scope may not be null"); } - LOG.trace("enter HttpState.getCredentials(AuthScope)"); + LOG.debug("enter HttpState.getCredentials(AuthScope)"); return matchCredentials(this.credMap, authscope); } /** - * Sets the {@link Credentials credentials} for the given proxy authentication - * realm on the given proxy host. The null proxy realm signifies - * default credentials for the given proxy host, which should be used when no - * {@link Credentials credentials} have been explictly supplied for the - * challenging proxy realm. The null proxy host signifies default - * credentials, which should be used when no {@link Credentials credentials} - * have been explictly supplied for the challenging proxy host. Any previous - * credentials for the given proxy realm on the given proxy host will be - * overwritten. - * - * @param realm the authentication realm - * @param proxyHost the proxy host - * @param credentials the authentication credentials for the given realm - * - * @see #getProxyCredentials(AuthScope) - * @see #setCredentials(AuthScope, Credentials) - * - * @deprecated use #setProxyCredentials(AuthScope, Credentials) - */ - public synchronized void setProxyCredentials( - String realm, - String proxyHost, - Credentials credentials - ) { - LOG.trace("enter HttpState.setProxyCredentials(String, String, Credentials"); - proxyCred.put(new AuthScope(proxyHost, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME), credentials); - } - - /** * Sets the {@link Credentials proxy credentials} for the given authentication * realm. Any previous credentials for the given realm will be overwritten. * @@ -484,36 +283,11 @@ if (authscope == null) { throw new IllegalArgumentException("Authentication scope may not be null"); } - LOG.trace("enter HttpState.setProxyCredentials(AuthScope, Credentials)"); + LOG.debug("enter HttpState.setProxyCredentials(AuthScope, Credentials)"); proxyCred.put(authscope, credentials); } /** - * Get the {@link Credentials credentials} for the proxy host with the given - * authentication scope. - * - * If the realm exists on host, return the coresponding credentials. - * If the host exists with a null realm, return the corresponding - * credentials. - * If the realm exists with a null host, return the - * corresponding credentials. If the realm does not exist, return - * the default Credentials. If there are no default credentials, return - * null. - * - * @param realm the authentication realm - * @param proxyHost the proxy host the realm is on - * @return the credentials - * @see #setProxyCredentials(String, String, Credentials) - * - * @deprecated use #getProxyCredentials(AuthScope) - */ - public synchronized Credentials getProxyCredentials(String realm, String proxyHost) { - LOG.trace("enter HttpState.getCredentials(String, String"); - return matchCredentials(this.proxyCred, - new AuthScope(proxyHost, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME)); - } - - /** * Get the {@link Credentials proxy credentials} for the given authentication scope. * * @param authscope the {@link AuthScope authentication scope} @@ -527,7 +301,7 @@ if (authscope == null) { throw new IllegalArgumentException("Authentication scope may not be null"); } - LOG.trace("enter HttpState.getProxyCredentials(AuthScope)"); + LOG.debug("enter HttpState.getProxyCredentials(AuthScope)"); return matchCredentials(this.proxyCred, authscope); } @@ -538,6 +312,7 @@ * * @see java.lang.Object#toString() */ + @Override public synchronized String toString() { StringBuffer sbResult = new StringBuffer(); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpURL.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpURL.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpURL.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpURL.java Tue Jan 3 19:47:10 2006 @@ -43,6 +43,7 @@ /** Create an instance as an internal use. */ protected HttpURL() { + // do nothing } @@ -54,7 +55,6 @@ * @param charset the charset string to do escape encoding * @throws URIException If {@link #checkValid()} fails * @throws NullPointerException if escaped is null - * @see #getProtocolCharset */ public HttpURL(char[] escaped, String charset) throws URIException, NullPointerException { @@ -70,7 +70,6 @@ * @param escaped the HTTP URL character sequence * @throws URIException If {@link #checkValid()} fails * @throws NullPointerException if escaped is null - * @see #getDefaultProtocolCharset */ public HttpURL(char[] escaped) throws URIException, NullPointerException { parseUriReference(new String(escaped), true); @@ -85,7 +84,6 @@ * @param original the HTTP URL string * @param charset the charset string to do escape encoding * @throws URIException If {@link #checkValid()} fails - * @see #getProtocolCharset */ public HttpURL(String original, String charset) throws URIException { protocolCharset = charset; @@ -99,7 +97,6 @@ * * @param original the HTTP URL string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String original) throws URIException { parseUriReference(original, false); @@ -114,7 +111,6 @@ * @param port the port number * @param path the path string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String host, int port, String path) throws URIException { this(null, null, host, port, path, null, null); @@ -129,7 +125,6 @@ * @param path the path string * @param query the query string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String host, int port, String path, String query) throws URIException { @@ -145,7 +140,6 @@ * @param password his or her password * @param host the host string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String user, String password, String host) throws URIException { @@ -162,7 +156,6 @@ * @param host the host string * @param port the port number * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String user, String password, String host, int port) throws URIException { @@ -180,7 +173,6 @@ * @param port the port number * @param path the path string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String user, String password, String host, int port, String path) throws URIException { @@ -199,7 +191,6 @@ * @param path the path string * @param query The query string. * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String user, String password, String host, int port, String path, String query) throws URIException { @@ -216,7 +207,6 @@ * @param query the query string * @param fragment the fragment string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String host, String path, String query, String fragment) throws URIException { @@ -238,7 +228,6 @@ * @param query the query string * @param fragment the fragment string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String userinfo, String host, String path, String query, String fragment) throws URIException { @@ -259,7 +248,6 @@ * @param port the port number * @param path the path string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String userinfo, String host, int port, String path) throws URIException { @@ -281,7 +269,6 @@ * @param path the path string * @param query the query string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String userinfo, String host, int port, String path, String query) throws URIException { @@ -304,7 +291,6 @@ * @param query the query string * @param fragment the fragment string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String userinfo, String host, int port, String path, String query, String fragment) throws URIException { @@ -313,7 +299,7 @@ StringBuffer buff = new StringBuffer(); if (userinfo != null || host != null || port != -1) { _scheme = DEFAULT_SCHEME; // in order to verify the own protocol - buff.append(_default_scheme); + buff.append(DEFAULT_SCHEME); buff.append("://"); if (userinfo != null) { buff.append(userinfo); @@ -358,14 +344,18 @@ * @param query the query string * @param fragment the fragment string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpURL(String user, String password, String host, int port, String path, String query, String fragment) throws URIException { this(toUserinfo(user, password), host, port, path, query, fragment); } - protected static String toUserinfo(String user, String password) throws URIException { + /** + * @param user + * @param password + * @return user:password string or null + */ + protected static String toUserinfo(String user, String password) { if (user == null) return null; StringBuffer usrinfo = new StringBuffer(20); //sufficient for real world usrinfo.append(URIUtil.encode(user, URI.allowed_within_userinfo)); @@ -408,25 +398,11 @@ public static final char[] DEFAULT_SCHEME = { 'h', 't', 't', 'p' }; /** - * Default scheme for HTTP URL. - * @deprecated Use {@link #DEFAULT_SCHEME} instead. This one doesn't - * conform to the project naming conventions. - */ - public static final char[] _default_scheme = DEFAULT_SCHEME; - - /** * Default port for HTTP URL. */ public static final int DEFAULT_PORT = 80; /** - * Default port for HTTP URL. - * @deprecated Use {@link #DEFAULT_PORT} instead. This one doesn't conform - * to the project naming conventions. - */ - public static final int _default_port = DEFAULT_PORT; - - /** * The serialVersionUID. */ static final long serialVersionUID = -7158031098595039459L; @@ -438,6 +414,7 @@ * * @return the scheme */ + @Override public char[] getRawScheme() { return (_scheme == null) ? null : HttpURL.DEFAULT_SCHEME; } @@ -448,6 +425,7 @@ * * @return the scheme null if empty or undefined */ + @Override public String getScheme() { return (_scheme == null) ? null : new String(HttpURL.DEFAULT_SCHEME); } @@ -458,6 +436,7 @@ * Get the port number. * @return the port number */ + @Override public int getPort() { return (_port == -1) ? HttpURL.DEFAULT_PORT : _port; } @@ -619,7 +598,7 @@ * Get the user. * * @return the user name - * @throws URIException If {@link #decode} fails + * @throws URIException If decoding fails */ public String getUser() throws URIException { char[] user = getRawUser(); @@ -727,6 +706,7 @@ * @return the raw-escaped current hierarchy level * @throws URIException If {@link #getRawCurrentHierPath(char[])} fails. */ + @Override public char[] getRawCurrentHierPath() throws URIException { return (_path == null || _path.length == 0) ? rootPath : super.getRawCurrentHierPath(_path); @@ -739,6 +719,7 @@ * @return the raw above hierarchy level * @throws URIException If {@link #getRawCurrentHierPath(char[])} fails. */ + @Override public char[] getRawAboveHierPath() throws URIException { char[] path = getRawCurrentHierPath(); return (path == null || path.length == 0) ? rootPath : getRawCurrentHierPath(path); @@ -750,6 +731,7 @@ * * @return the path '/' if empty or undefined */ + @Override public char[] getRawPath() { char[] path = super.getRawPath(); return (path == null || path.length == 0) ? rootPath : path; @@ -762,13 +744,10 @@ * * @param queryName the query string. * @param queryValue the query string. - * @throws URIException incomplete trailing escape pattern - * Or unsupported character encoding * @throws NullPointerException null query - * @see #encode */ public void setQuery(String queryName, String queryValue) - throws URIException, NullPointerException { + throws NullPointerException { StringBuffer buff = new StringBuffer(); // set the charset to do escape encoding @@ -789,7 +768,6 @@ * @throws URIException incomplete trailing escape pattern, * unsupported character encoding or wrong array size * @throws NullPointerException null query - * @see #encode */ public void setQuery(String[] queryName, String[] queryValue) throws URIException, NullPointerException { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpVersion.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpVersion.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpVersion.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpVersion.java Tue Jan 3 06:16:45 2006 @@ -124,6 +124,7 @@ /** * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { return this.major * 100000 + this.minor; } @@ -131,6 +132,7 @@ /** * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(Object obj) { if (this == obj) { return true; @@ -169,6 +171,7 @@ /** * Test if the HTTP protocol version is equal to the given number. + * @param version * * @return true if HTTP protocol version is given to the given number, * false otherwise. @@ -179,6 +182,7 @@ /** * Test if the HTTP protocol version is greater or equal to the given number. + * @param version * * @return true if HTTP protocol version is greater or equal given to the * given number, false otherwise. @@ -189,6 +193,7 @@ /** * Test if the HTTP protocol version is less or equal to the given number. + * @param version * * @return true if HTTP protocol version is less or equal to given to the * given number, false otherwise. @@ -200,6 +205,7 @@ /** * @see java.lang.Object#toString() */ + @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("HTTP/"); @@ -211,6 +217,7 @@ /** * Parses the textual representation of the given HTTP protocol version. + * @param s * * @return HTTP protocol version. * diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpsURL.java commons-httpclient/src/java/org/apache/commons/httpclient/HttpsURL.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/HttpsURL.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/HttpsURL.java Tue Jan 3 19:45:39 2006 @@ -45,6 +45,7 @@ * Create an instance as an internal use. */ protected HttpsURL() { + // do nothing } @@ -56,7 +57,6 @@ * @param charset the charset to do escape encoding * @throws URIException If {@link #checkValid()} fails * @throws NullPointerException if escaped is null - * @see #getProtocolCharset */ public HttpsURL(char[] escaped, String charset) throws URIException, NullPointerException { @@ -72,7 +72,6 @@ * @param escaped the HTTPS URL character sequence * @throws URIException If {@link #checkValid()} fails * @throws NullPointerException if escaped is null - * @see #getDefaultProtocolCharset */ public HttpsURL(char[] escaped) throws URIException, NullPointerException { parseUriReference(new String(escaped), true); @@ -87,7 +86,6 @@ * @param original the HTTPS URL string * @param charset the charset to do escape encoding * @throws URIException If {@link #checkValid()} fails - * @see #getProtocolCharset */ public HttpsURL(String original, String charset) throws URIException { protocolCharset = charset; @@ -101,7 +99,6 @@ * * @param original the HTTPS URL string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String original) throws URIException { parseUriReference(original, false); @@ -116,7 +113,6 @@ * @param port the port number * @param path the path string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String host, int port, String path) throws URIException { this(null, host, port, path, null, null); @@ -131,7 +127,6 @@ * @param path the path string * @param query the query string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String host, int port, String path, String query) throws URIException { @@ -147,7 +142,6 @@ * @param password his or her password * @param host the host string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String user, String password, String host) throws URIException { @@ -164,7 +158,6 @@ * @param host the host string * @param port the port number * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String user, String password, String host, int port) throws URIException { @@ -182,7 +175,6 @@ * @param port the port number * @param path the path string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String user, String password, String host, int port, String path) throws URIException { @@ -201,7 +193,6 @@ * @param path the path string * @param query The query string. * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String user, String password, String host, int port, String path, String query) throws URIException { @@ -218,7 +209,6 @@ * @param query the query string * @param fragment the fragment string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String host, String path, String query, String fragment) throws URIException { @@ -240,7 +230,6 @@ * @param query the query string * @param fragment the fragment string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String userinfo, String host, String path, String query, String fragment) throws URIException { @@ -261,7 +250,6 @@ * @param port the port number * @param path the path string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String userinfo, String host, int port, String path) throws URIException { @@ -283,7 +271,6 @@ * @param path the path string * @param query the query string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String userinfo, String host, int port, String path, String query) throws URIException { @@ -306,7 +293,6 @@ * @param query the query string * @param fragment the fragment string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String userinfo, String host, int port, String path, String query, String fragment) throws URIException { @@ -315,7 +301,7 @@ StringBuffer buff = new StringBuffer(); if (userinfo != null || host != null || port != -1) { _scheme = DEFAULT_SCHEME; // in order to verify the own protocol - buff.append(_default_scheme); + buff.append(DEFAULT_SCHEME); buff.append("://"); if (userinfo != null) { buff.append(userinfo); @@ -359,7 +345,6 @@ * @param query the query string * @param fragment the fragment string * @throws URIException If {@link #checkValid()} fails - * @see #getDefaultProtocolCharset */ public HttpsURL(String user, String password, String host, int port, String path, String query, String fragment) throws URIException { @@ -398,27 +383,11 @@ public static final char[] DEFAULT_SCHEME = { 'h', 't', 't', 'p', 's' }; /** - * Default scheme for HTTPS URL. - * @deprecated Use {@link #DEFAULT_SCHEME} instead. This one doesn't - * conform to the project naming conventions. - */ - public static final char[] _default_scheme = DEFAULT_SCHEME; - - - /** * Default port for HTTPS URL. */ public static final int DEFAULT_PORT = 443; /** - * Default port for HTTPS URL. - * @deprecated Use {@link #DEFAULT_PORT} instead. This one doesn't conform - * to the project naming conventions. - */ - public static final int _default_port = DEFAULT_PORT; - - - /** * The serialVersionUID. */ static final long serialVersionUID = 887844277028676648L; @@ -430,6 +399,7 @@ * * @return the scheme */ + @Override public char[] getRawScheme() { return (_scheme == null) ? null : HttpsURL.DEFAULT_SCHEME; } @@ -440,6 +410,7 @@ * * @return the scheme null if empty or undefined */ + @Override public String getScheme() { return (_scheme == null) ? null : new String(HttpsURL.DEFAULT_SCHEME); } @@ -450,6 +421,7 @@ * Get the port number. * @return the port number */ + @Override public int getPort() { return (_port == -1) ? HttpsURL.DEFAULT_PORT : _port; } @@ -461,6 +433,7 @@ * * @throws URIException the wrong scheme use */ + @Override protected void checkValid() throws URIException { // could be explicit protocol or undefined. if (!(equals(_scheme, DEFAULT_SCHEME) || _scheme == null)) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/MethodRetryHandler.java commons-httpclient/src/java/org/apache/commons/httpclient/MethodRetryHandler.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/MethodRetryHandler.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/MethodRetryHandler.java Thu Jan 1 01:00:00 1970 @@ -1,67 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/MethodRetryHandler.java,v 1.5 2004/07/05 22:46:58 olegk Exp $ - * $Revision: 155418 $ - * $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - * - * ==================================================================== - * - * Copyright 1999-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient; - -/** - * A handler for determining if an HttpMethod should be retried after a - * recoverable exception during execution. - * - * @see HttpMethod#execute(HttpState, HttpConnection) - * @see HttpRecoverableException - * - * @deprecated use {@link HttpMethodRetryHandler} - * - * @author Michael Becke - */ -public interface MethodRetryHandler { - - /** - * Determines if a method should be retried after an HttpRecoverableException - * occurs during execution. - * - * @param method the method being executed - * @param connection the connection the method is using - * @param recoverableException the exception that occurred - * @param executionCount the number of times this method has been - * unsuccessfully executed - * @param requestSent this argument is unused and will be removed in the future. - * {@link HttpMethod#isRequestSent()} should be used instead - * - * @return true if the method should be retried, false - * otherwise - */ - boolean retryMethod( - HttpMethod method, - HttpConnection connection, - HttpRecoverableException recoverableException, - int executionCount, - boolean requestSent); - -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java commons-httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java Sun Oct 9 21:53:32 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java Tue Jan 3 19:51:53 2006 @@ -43,13 +43,12 @@ import java.util.LinkedList; import java.util.Map; import java.util.WeakHashMap; - import org.apache.commons.httpclient.params.HttpConnectionManagerParams; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.util.IdleConnectionHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Manages a set of HttpConnections for various HostConfigurations. @@ -66,7 +65,8 @@ // -------------------------------------------------------- Class Variables /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(MultiThreadedHttpConnectionManager.class); + static final Logger LOG = LoggerFactory + .getLogger(MultiThreadedHttpConnectionManager.class); /** The default maximum number of connections allowed per host */ public static final int DEFAULT_MAX_HOST_CONNECTIONS = 2; // Per RFC 2616 sec 8.1.4 @@ -78,13 +78,18 @@ * A mapping from Reference to ConnectionSource. Used to reclaim resources when connections * are lost to the garbage collector. */ - private static final Map REFERENCE_TO_CONNECTION_SOURCE = new HashMap(); + static final Map, + ConnectionSource> + REFERENCE_TO_CONNECTION_SOURCE = + new HashMap, + ConnectionSource>(); /** * The reference queue used to track when HttpConnections are lost to the * garbage collector */ - private static final ReferenceQueue REFERENCE_QUEUE = new ReferenceQueue(); + static final ReferenceQueue + REFERENCE_QUEUE = new ReferenceQueue(); /** * The thread responsible for handling lost connections. @@ -94,8 +99,9 @@ /** * Holds references to all active instances of this class. */ - private static WeakHashMap ALL_CONNECTION_MANAGERS = new WeakHashMap(); - + private static WeakHashMap + ALL_CONNECTION_MANAGERS = + new WeakHashMap(); // ---------------------------------------------------------- Class Methods @@ -147,7 +153,7 @@ * * @see #removeReferenceToConnection(HttpConnection) */ - private static void storeReferenceToConnection( + static void storeReferenceToConnection( HttpConnectionWithReference connection, HostConfiguration hostConfiguration, ConnectionPool connectionPool @@ -176,21 +182,24 @@ * Closes and releases all connections currently checked out of the given connection pool. * @param connectionPool the connection pool to shutdown the connections for */ - private static void shutdownCheckedOutConnections(ConnectionPool connectionPool) { + static void shutdownCheckedOutConnections(ConnectionPool connectionPool) { // keep a list of the connections to be closed - ArrayList connectionsToClose = new ArrayList(); + ArrayList connectionsToClose = + new ArrayList(); synchronized (REFERENCE_TO_CONNECTION_SOURCE) { - Iterator referenceIter = REFERENCE_TO_CONNECTION_SOURCE.keySet().iterator(); + Iterator> referenceIter = + REFERENCE_TO_CONNECTION_SOURCE.keySet().iterator(); while (referenceIter.hasNext()) { - Reference ref = (Reference) referenceIter.next(); + WeakReference ref = + referenceIter.next(); ConnectionSource source = - (ConnectionSource) REFERENCE_TO_CONNECTION_SOURCE.get(ref); + REFERENCE_TO_CONNECTION_SOURCE.get(ref); if (source.connectionPool == connectionPool) { referenceIter.remove(); - HttpConnection connection = (HttpConnection) ref.get(); + HttpConnection connection = ref.get(); if (connection != null) { connectionsToClose.add(connection); } @@ -200,8 +209,8 @@ // close and release the connections outside of the synchronized block to // avoid holding the lock for too long - for (Iterator i = connectionsToClose.iterator(); i.hasNext();) { - HttpConnection connection = (HttpConnection) i.next(); + for (Iterator i = connectionsToClose.iterator(); i.hasNext();) { + HttpConnection connection = i.next(); connection.close(); // remove the reference to the connection manager. this ensures // that the we don't accidentally end up here again @@ -218,7 +227,7 @@ * * @see #storeReferenceToConnection(HttpConnection, HostConfiguration, ConnectionPool) */ - private static void removeReferenceToConnection(HttpConnectionWithReference connection) { + static void removeReferenceToConnection(HttpConnectionWithReference connection) { synchronized (REFERENCE_TO_CONNECTION_SOURCE) { REFERENCE_TO_CONNECTION_SOURCE.remove(connection.reference); @@ -231,12 +240,12 @@ /** * Collection of parameters associated with this connection manager. */ - private HttpConnectionManagerParams params = new HttpConnectionManagerParams(); + HttpConnectionManagerParams params = new HttpConnectionManagerParams(); /** Connection Pool */ private ConnectionPool connectionPool; - private boolean shutdown = false; + boolean shutdown = false; // ----------------------------------------------------------- Constructors @@ -272,87 +281,6 @@ } /** - * Gets the staleCheckingEnabled value to be set on HttpConnections that are created. - * - * @return true if stale checking will be enabled on HttpConnections - * - * @see HttpConnection#isStaleCheckingEnabled() - * - * @deprecated Use {@link HttpConnectionManagerParams#isStaleCheckingEnabled()}, - * {@link HttpConnectionManager#getParams()}. - */ - public boolean isConnectionStaleCheckingEnabled() { - return this.params.isStaleCheckingEnabled(); - } - - /** - * Sets the staleCheckingEnabled value to be set on HttpConnections that are created. - * - * @param connectionStaleCheckingEnabled true if stale checking will be enabled - * on HttpConnections - * - * @see HttpConnection#setStaleCheckingEnabled(boolean) - * - * @deprecated Use {@link HttpConnectionManagerParams#setStaleCheckingEnabled(boolean)}, - * {@link HttpConnectionManager#getParams()}. - */ - public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled) { - this.params.setStaleCheckingEnabled(connectionStaleCheckingEnabled); - } - - /** - * Sets the maximum number of connections allowed for a given - * HostConfiguration. Per RFC 2616 section 8.1.4, this value defaults to 2. - * - * @param maxHostConnections the number of connections allowed for each - * hostConfiguration - * - * @deprecated Use {@link HttpConnectionManagerParams#setDefaultMaxConnectionsPerHost(int)}, - * {@link HttpConnectionManager#getParams()}. - */ - public void setMaxConnectionsPerHost(int maxHostConnections) { - this.params.setDefaultMaxConnectionsPerHost(maxHostConnections); - } - - /** - * Gets the maximum number of connections allowed for a given - * hostConfiguration. - * - * @return The maximum number of connections allowed for a given - * hostConfiguration. - * - * @deprecated Use {@link HttpConnectionManagerParams#getDefaultMaxConnectionsPerHost()}, - * {@link HttpConnectionManager#getParams()}. - */ - public int getMaxConnectionsPerHost() { - return this.params.getDefaultMaxConnectionsPerHost(); - } - - /** - * Sets the maximum number of connections allowed for this connection manager. - * - * @param maxTotalConnections the maximum number of connections allowed - * - * @deprecated Use {@link HttpConnectionManagerParams#setMaxTotalConnections(int)}, - * {@link HttpConnectionManager#getParams()}. - */ - public void setMaxTotalConnections(int maxTotalConnections) { - this.params.getMaxTotalConnections(); - } - - /** - * Gets the maximum number of connections allowed for this connection manager. - * - * @return The maximum number of connections allowed - * - * @deprecated Use {@link HttpConnectionManagerParams#getMaxTotalConnections()}, - * {@link HttpConnectionManager#getParams()}. - */ - public int getMaxTotalConnections() { - return this.params.getMaxTotalConnections(); - } - - /** * @see HttpConnectionManager#getConnection(HostConfiguration) */ public HttpConnection getConnection(HostConfiguration hostConfiguration) { @@ -380,7 +308,7 @@ public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) throws ConnectionPoolTimeoutException { - LOG.trace("enter HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)"); + LOG.debug("enter HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)"); if (hostConfiguration == null) { throw new IllegalArgumentException("hostConfiguration is null"); @@ -399,22 +327,6 @@ } /** - * @see HttpConnectionManager#getConnection(HostConfiguration, long) - * - * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long) - */ - public HttpConnection getConnection(HostConfiguration hostConfiguration, - long timeout) throws HttpException { - - LOG.trace("enter HttpConnectionManager.getConnection(HostConfiguration, long)"); - try { - return getConnectionWithTimeout(hostConfiguration, timeout); - } catch(ConnectionPoolTimeoutException e) { - throw new HttpException(e.getMessage()); - } - } - - /** * Gets a connection or waits if one is not available. A connection is * available if one exists that is not being used or if fewer than * maxHostConnections have been created in the connectionPool, and fewer @@ -530,8 +442,7 @@ * Gets the total number of pooled connections for the given host configuration. This * is the total number of connections that have been created and are still in use * by this connection manager for the host configuration. This value will - * not exceed the {@link #getMaxConnectionsPerHost() maximum number of connections per - * host}. + * not exceed the maximum number of connections per host. * * @param hostConfiguration The host configuration * @return The total number of pooled connections @@ -546,8 +457,7 @@ /** * Gets the total number of pooled connections. This is the total number of * connections that have been created and are still in use by this connection - * manager. This value will not exceed the {@link #getMaxTotalConnections() - * maximum number of connections}. + * manager. This value will not exceed the maximum number of connections. * * @return the total number of pooled connections */ @@ -558,29 +468,6 @@ } /** - * Gets the number of connections in use for this configuration. - * - * @param hostConfiguration the key that connections are tracked on - * @return the number of connections in use - * - * @deprecated Use {@link #getConnectionsInPool(HostConfiguration)} - */ - public int getConnectionsInUse(HostConfiguration hostConfiguration) { - return getConnectionsInPool(hostConfiguration); - } - - /** - * Gets the total number of connections in use. - * - * @return the total number of connections in use - * - * @deprecated Use {@link #getConnectionsInPool()} - */ - public int getConnectionsInUse() { - return getConnectionsInPool(); - } - - /** * Deletes all closed connections. Only connections currently owned by the connection * manager are processed. * @@ -593,6 +480,7 @@ } /** + * @param idleTimeout * @since 3.0 */ public void closeIdleConnections(long idleTimeout) { @@ -607,7 +495,7 @@ * @param conn the HttpConnection to make available. */ public void releaseConnection(HttpConnection conn) { - LOG.trace("enter HttpConnectionManager.releaseConnection(HttpConnection)"); + LOG.debug("enter HttpConnectionManager.releaseConnection(HttpConnection)"); if (conn instanceof HttpConnectionAdapter) { // connections given out are wrapped in an HttpConnectionAdapter @@ -628,7 +516,7 @@ * @param conn the connection to get the configuration of * @return a new HostConfiguration */ - private HostConfiguration configurationForConnection(HttpConnection conn) { + HostConfiguration configurationForConnection(HttpConnection conn) { HostConfiguration connectionConfiguration = new HostConfiguration(); @@ -648,24 +536,14 @@ } /** - * Returns {@link HttpConnectionManagerParams parameters} associated - * with this connection manager. - * - * @since 3.0 - * - * @see HttpConnectionManagerParams + * {@inheritDoc} */ public HttpConnectionManagerParams getParams() { return this.params; } /** - * Assigns {@link HttpConnectionManagerParams parameters} for this - * connection manager. - * - * @since 3.0 - * - * @see HttpConnectionManagerParams + * {@inheritDoc} */ public void setParams(final HttpConnectionManagerParams params) { if (params == null) { @@ -680,21 +558,24 @@ private class ConnectionPool { /** The list of free connections */ - private LinkedList freeConnections = new LinkedList(); + LinkedList freeConnections = + new LinkedList(); /** The list of WaitingThreads waiting for a connection */ - private LinkedList waitingThreads = new LinkedList(); + LinkedList waitingThreads = + new LinkedList(); /** * Map where keys are {@link HostConfiguration}s and values are {@link * HostConnectionPool}s */ - private final Map mapHosts = new HashMap(); + private final Map mapHosts = + new HashMap(); private IdleConnectionHandler idleConnectionHandler = new IdleConnectionHandler(); /** The number of created connections */ - private int numConnections = 0; + int numConnections = 0; /** * Cleans up all connection pool resources. @@ -772,10 +653,10 @@ * @return a pool (list) of connections available for the given config */ public synchronized HostConnectionPool getHostPool(HostConfiguration hostConfiguration) { - LOG.trace("enter HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)"); + LOG.debug("enter HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)"); // Look for a list of connections for the given config - HostConnectionPool listConnections = (HostConnectionPool) + HostConnectionPool listConnections = mapHosts.get(hostConfiguration); if (listConnections == null) { // First time for this config @@ -876,7 +757,7 @@ */ public synchronized void deleteLeastUsedConnection() { - HttpConnection connection = (HttpConnection) freeConnections.removeFirst(); + HttpConnection connection = freeConnections.removeFirst(); if (connection != null) { deleteConnection(connection); @@ -914,13 +795,13 @@ LOG.debug("Notifying thread waiting on host pool, hostConfig=" + hostPool.hostConfiguration); } - waitingThread = (WaitingThread) hostPool.waitingThreads.removeFirst(); + waitingThread = hostPool.waitingThreads.removeFirst(); waitingThreads.remove(waitingThread); } else if (waitingThreads.size() > 0) { if (LOG.isDebugEnabled()) { LOG.debug("No-one waiting on host pool, notifying next waiting thread."); } - waitingThread = (WaitingThread) waitingThreads.removeFirst(); + waitingThread = waitingThreads.removeFirst(); waitingThread.hostConnectionPool.waitingThreads.remove(waitingThread); } else if (LOG.isDebugEnabled()) { LOG.debug("Notifying no-one, there are no waiting threads"); @@ -1004,10 +885,12 @@ public HostConfiguration hostConfiguration; /** The list of free connections */ - public LinkedList freeConnections = new LinkedList(); + public LinkedList freeConnections = + new LinkedList(); /** The list of WaitingThreads for this host */ - public LinkedList waitingThreads = new LinkedList(); + public LinkedList waitingThreads = + new LinkedList(); /** The number of created connections */ public int numConnections = 0; @@ -1041,6 +924,9 @@ setName("MultiThreadedHttpConnectionManager cleanup"); } + /** + * Notify the thread to shutdown. + */ public void shutdown() { this.shutdown = true; } @@ -1055,7 +941,7 @@ ConnectionSource source = null; synchronized (REFERENCE_TO_CONNECTION_SOURCE) { - source = (ConnectionSource) REFERENCE_TO_CONNECTION_SOURCE.remove(ref); + source = REFERENCE_TO_CONNECTION_SOURCE.remove(ref); } // only clean up for this reference if it is still associated with // a ConnectionSource @@ -1073,6 +959,7 @@ /** * Start execution. */ + @Override public void run() { while (!shutdown) { try { @@ -1095,8 +982,9 @@ * A connection that keeps a reference to itself. */ private static class HttpConnectionWithReference extends HttpConnection { - - public WeakReference reference = new WeakReference(this, REFERENCE_QUEUE); + /** this http connection as weak reference */ + public WeakReference reference + = new WeakReference(this, REFERENCE_QUEUE); /** * @param hostConfiguration @@ -1140,33 +1028,28 @@ return wrappedConnection; } + /** + * {@inheritDoc} + */ + @Override public void close() { if (hasConnection()) { wrappedConnection.close(); - } else { - // do nothing } } + /** + * {@inheritDoc} + */ + @Override public InetAddress getLocalAddress() { - if (hasConnection()) { - return wrappedConnection.getLocalAddress(); - } else { - return null; - } + return hasConnection() ? wrappedConnection.getLocalAddress() : null; } /** - * @deprecated + * {@inheritDoc} */ - public boolean isStaleCheckingEnabled() { - if (hasConnection()) { - return wrappedConnection.isStaleCheckingEnabled(); - } else { - return false; - } - } - + @Override public void setLocalAddress(InetAddress localAddress) { if (hasConnection()) { wrappedConnection.setLocalAddress(localAddress); @@ -1176,146 +1059,152 @@ } /** - * @deprecated + * {@inheritDoc} */ - public void setStaleCheckingEnabled(boolean staleCheckEnabled) { - if (hasConnection()) { - wrappedConnection.setStaleCheckingEnabled(staleCheckEnabled); - } else { - throw new IllegalStateException("Connection has been released"); - } - } - + @Override public String getHost() { - if (hasConnection()) { - return wrappedConnection.getHost(); - } else { - return null; - } + return hasConnection() ? wrappedConnection.getHost() : null; } + /** + * {@inheritDoc} + */ + @Override public HttpConnectionManager getHttpConnectionManager() { - if (hasConnection()) { - return wrappedConnection.getHttpConnectionManager(); - } else { - return null; - } + return hasConnection() + ? wrappedConnection.getHttpConnectionManager() + : null; } + /** + * {@inheritDoc} + */ + @Override public InputStream getLastResponseInputStream() { - if (hasConnection()) { - return wrappedConnection.getLastResponseInputStream(); - } else { - return null; - } + return hasConnection() + ? wrappedConnection.getLastResponseInputStream() + : null; } + /** + * {@inheritDoc} + */ + @Override public int getPort() { - if (hasConnection()) { - return wrappedConnection.getPort(); - } else { - return -1; - } + return hasConnection() ? wrappedConnection.getPort() : -1; } + /** + * {@inheritDoc} + */ + @Override public Protocol getProtocol() { - if (hasConnection()) { - return wrappedConnection.getProtocol(); - } else { - return null; - } + return hasConnection() ? wrappedConnection.getProtocol() : null; } + /** + * {@inheritDoc} + */ + @Override public String getProxyHost() { - if (hasConnection()) { - return wrappedConnection.getProxyHost(); - } else { - return null; - } + return hasConnection() ? wrappedConnection.getProxyHost() : null; } + /** + * {@inheritDoc} + */ + @Override public int getProxyPort() { - if (hasConnection()) { - return wrappedConnection.getProxyPort(); - } else { - return -1; - } + return hasConnection() ? wrappedConnection.getProxyPort() : -1; } + /** + * {@inheritDoc} + */ + @Override public OutputStream getRequestOutputStream() - throws IOException, IllegalStateException { - if (hasConnection()) { - return wrappedConnection.getRequestOutputStream(); - } else { - return null; - } + throws IllegalStateException + { + return hasConnection() + ? wrappedConnection.getRequestOutputStream() + : null; } + /** + * {@inheritDoc} + */ + @Override public InputStream getResponseInputStream() - throws IOException, IllegalStateException { - if (hasConnection()) { - return wrappedConnection.getResponseInputStream(); - } else { - return null; - } + throws IllegalStateException { + return hasConnection() + ? wrappedConnection.getResponseInputStream() + : null; } + /** + * {@inheritDoc} + */ + @Override public boolean isOpen() { - if (hasConnection()) { - return wrappedConnection.isOpen(); - } else { - return false; - } + return hasConnection() ? wrappedConnection.isOpen() : false; } + /** + * {@inheritDoc} + */ + @Override public boolean closeIfStale() throws IOException { - if (hasConnection()) { - return wrappedConnection.closeIfStale(); - } else { - return false; - } + return hasConnection() ? wrappedConnection.closeIfStale() : false; } + /** + * {@inheritDoc} + */ + @Override public boolean isProxied() { - if (hasConnection()) { - return wrappedConnection.isProxied(); - } else { - return false; - } + return hasConnection() ? wrappedConnection.isProxied() : false; } + /** + * {@inheritDoc} + */ + @Override public boolean isResponseAvailable() throws IOException { - if (hasConnection()) { - return wrappedConnection.isResponseAvailable(); - } else { - return false; - } + return hasConnection() + ? wrappedConnection.isResponseAvailable() + : false; } + /** + * {@inheritDoc} + */ + @Override public boolean isResponseAvailable(int timeout) throws IOException { - if (hasConnection()) { - return wrappedConnection.isResponseAvailable(timeout); - } else { - return false; - } + return hasConnection() + ? wrappedConnection.isResponseAvailable(timeout) + : false; } + /** + * {@inheritDoc} + */ + @Override public boolean isSecure() { - if (hasConnection()) { - return wrappedConnection.isSecure(); - } else { - return false; - } + return hasConnection() ? wrappedConnection.isSecure() : false; } + /** + * {@inheritDoc} + */ + @Override public boolean isTransparent() { - if (hasConnection()) { - return wrappedConnection.isTransparent(); - } else { - return false; - } + return hasConnection() ? wrappedConnection.isTransparent() : false; } + /** + * {@inheritDoc} + */ + @Override public void open() throws IOException { if (hasConnection()) { wrappedConnection.open(); @@ -1325,17 +1214,9 @@ } /** - * @deprecated + * {@inheritDoc} */ - public void print(String data) - throws IOException, IllegalStateException { - if (hasConnection()) { - wrappedConnection.print(data); - } else { - throw new IllegalStateException("Connection has been released"); - } - } - + @Override public void printLine() throws IOException, IllegalStateException { if (hasConnection()) { @@ -1346,144 +1227,112 @@ } /** - * @deprecated + * {@inheritDoc} */ - public void printLine(String data) - throws IOException, IllegalStateException { - if (hasConnection()) { - wrappedConnection.printLine(data); - } else { - throw new IllegalStateException("Connection has been released"); - } - } - - /** - * @deprecated - */ - public String readLine() throws IOException, IllegalStateException { - if (hasConnection()) { - return wrappedConnection.readLine(); - } else { - throw new IllegalStateException("Connection has been released"); - } - } - + @Override public String readLine(String charset) throws IOException, IllegalStateException { if (hasConnection()) { return wrappedConnection.readLine(charset); - } else { - throw new IllegalStateException("Connection has been released"); } + throw new IllegalStateException("Connection has been released"); } + /** + * {@inheritDoc} + */ + @Override public void releaseConnection() { if (!isLocked() && hasConnection()) { HttpConnection wrappedConnection = this.wrappedConnection; this.wrappedConnection = null; wrappedConnection.releaseConnection(); - } else { - // do nothing } } /** - * @deprecated + * {@inheritDoc} */ - public void setConnectionTimeout(int timeout) { - if (hasConnection()) { - wrappedConnection.setConnectionTimeout(timeout); - } else { - // do nothing - } - } - + @Override public void setHost(String host) throws IllegalStateException { if (hasConnection()) { wrappedConnection.setHost(host); - } else { - // do nothing } } + /** + * {@inheritDoc} + */ + @Override public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager) { if (hasConnection()) { wrappedConnection.setHttpConnectionManager(httpConnectionManager); - } else { - // do nothing } } + /** + * {@inheritDoc} + */ + @Override public void setLastResponseInputStream(InputStream inStream) { if (hasConnection()) { wrappedConnection.setLastResponseInputStream(inStream); - } else { - // do nothing } } + /** + * {@inheritDoc} + */ + @Override public void setPort(int port) throws IllegalStateException { if (hasConnection()) { wrappedConnection.setPort(port); - } else { - // do nothing } } + /** + * {@inheritDoc} + */ + @Override public void setProtocol(Protocol protocol) { if (hasConnection()) { wrappedConnection.setProtocol(protocol); - } else { - // do nothing } } + /** + * {@inheritDoc} + */ + @Override public void setProxyHost(String host) throws IllegalStateException { if (hasConnection()) { wrappedConnection.setProxyHost(host); - } else { - // do nothing - } - } - - public void setProxyPort(int port) throws IllegalStateException { - if (hasConnection()) { - wrappedConnection.setProxyPort(port); - } else { - // do nothing } } /** - * @deprecated + * {@inheritDoc} */ - public void setSoTimeout(int timeout) - throws SocketException, IllegalStateException { + @Override + public void setProxyPort(int port) throws IllegalStateException { if (hasConnection()) { - wrappedConnection.setSoTimeout(timeout); - } else { - // do nothing + wrappedConnection.setProxyPort(port); } } /** - * @deprecated + * {@inheritDoc} */ - public void shutdownOutput() { - if (hasConnection()) { - wrappedConnection.shutdownOutput(); - } else { - // do nothing - } - } - + @Override public void tunnelCreated() throws IllegalStateException, IOException { if (hasConnection()) { wrappedConnection.tunnelCreated(); - } else { - // do nothing } } + /** + * {@inheritDoc} + */ + @Override public void write(byte[] data, int offset, int length) throws IOException, IllegalStateException { if (hasConnection()) { @@ -1493,6 +1342,10 @@ } } + /** + * {@inheritDoc} + */ + @Override public void write(byte[] data) throws IOException, IllegalStateException { if (hasConnection()) { @@ -1502,6 +1355,10 @@ } } + /** + * {@inheritDoc} + */ + @Override public void writeLine() throws IOException, IllegalStateException { if (hasConnection()) { @@ -1511,6 +1368,10 @@ } } + /** + * {@inheritDoc} + */ + @Override public void writeLine(byte[] data) throws IOException, IllegalStateException { if (hasConnection()) { @@ -1520,74 +1381,44 @@ } } - public void flushRequestOutputStream() throws IOException { - if (hasConnection()) { - wrappedConnection.flushRequestOutputStream(); - } else { - throw new IllegalStateException("Connection has been released"); - } - } - /** - * @deprecated + * {@inheritDoc} */ - public int getSoTimeout() throws SocketException { - if (hasConnection()) { - return wrappedConnection.getSoTimeout(); - } else { - throw new IllegalStateException("Connection has been released"); - } - } - - /** - * @deprecated - */ - public String getVirtualHost() { + @Override + public void flushRequestOutputStream() throws IOException { if (hasConnection()) { - return wrappedConnection.getVirtualHost(); + wrappedConnection.flushRequestOutputStream(); } else { throw new IllegalStateException("Connection has been released"); } } /** - * @deprecated + * {@inheritDoc} */ - public void setVirtualHost(String host) throws IllegalStateException { - if (hasConnection()) { - wrappedConnection.setVirtualHost(host); - } else { - throw new IllegalStateException("Connection has been released"); - } - } - + @Override public int getSendBufferSize() throws SocketException { if (hasConnection()) { return wrappedConnection.getSendBufferSize(); - } else { - throw new IllegalStateException("Connection has been released"); } + throw new IllegalStateException("Connection has been released"); } /** - * @deprecated + * {@inheritDoc} */ - public void setSendBufferSize(int sendBufferSize) throws SocketException { - if (hasConnection()) { - wrappedConnection.setSendBufferSize(sendBufferSize); - } else { - throw new IllegalStateException("Connection has been released"); - } - } - + @Override public HttpConnectionParams getParams() { if (hasConnection()) { return wrappedConnection.getParams(); - } else { - throw new IllegalStateException("Connection has been released"); } + throw new IllegalStateException("Connection has been released"); } + /** + * {@inheritDoc} + */ + @Override public void setParams(final HttpConnectionParams params) { if (hasConnection()) { wrappedConnection.setParams(params); @@ -1596,9 +1427,10 @@ } } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.HttpConnection#print(java.lang.String, java.lang.String) + /** + * {@inheritDoc} */ + @Override public void print(String data, String charset) throws IOException, IllegalStateException { if (hasConnection()) { wrappedConnection.print(data, charset); @@ -1607,9 +1439,10 @@ } } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.HttpConnection#printLine(java.lang.String, java.lang.String) + /** + * {@inheritDoc} */ + @Override public void printLine(String data, String charset) throws IOException, IllegalStateException { if (hasConnection()) { @@ -1619,9 +1452,10 @@ } } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.HttpConnection#setSocketTimeout(int) + /** + * {@inheritDoc} */ + @Override public void setSocketTimeout(int timeout) throws SocketException, IllegalStateException { if (hasConnection()) { wrappedConnection.setSocketTimeout(timeout); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/NTCredentials.java commons-httpclient/src/java/org/apache/commons/httpclient/NTCredentials.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/NTCredentials.java Wed Oct 19 22:51:46 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/NTCredentials.java Tue Jan 3 19:52:59 2006 @@ -55,15 +55,6 @@ // ----------------------------------------------------------- Constructors /** - * Default constructor. - * - * @deprecated Do not use. Null user name, domain & host no longer allowed - */ - public NTCredentials() { - super(); - } - - /** * Constructor. * @param userName The user name. This should not include the domain to authenticate with. * For example: "user" is correct whereas "DOMAIN\\user" is not. @@ -86,51 +77,16 @@ } // ------------------------------------------------------- Instance Methods - - /** - * Sets the domain to authenticate with. The domain may not be null. - * - * @param domain the NT domain to authenticate in. - * - * @see #getDomain() - * - * @deprecated Do not use. The NTCredentials objects should be immutable - */ - public void setDomain(String domain) { - if (domain == null) { - throw new IllegalArgumentException("Domain may not be null"); - } - this.domain = domain; - } - /** * Retrieves the name to authenticate with. * * @return String the domain these credentials are intended to authenticate with. - * - * @see #setDomain(String) - * */ public String getDomain() { return domain; } /** - * Sets the host name of the computer originating the request. The host name may - * not be null. - * - * @param host the Host the user is logged into. - * - * @deprecated Do not use. The NTCredentials objects should be immutable - */ - public void setHost(String host) { - if (host == null) { - throw new IllegalArgumentException("Host may not be null"); - } - this.host = host; - } - - /** * Retrieves the host name of the computer originating the request. * * @return String the host the user is logged into. @@ -143,6 +99,7 @@ * Return a string representation of this object. * @return A string represenation of this object. */ + @Override public String toString() { final StringBuffer sbResult = new StringBuffer(super.toString()); @@ -159,6 +116,7 @@ * * @return The hash code for the credentials. */ + @Override public int hashCode() { int hash = super.hashCode(); hash = LangUtils.hashCode(hash, this.host); @@ -174,6 +132,7 @@ * * @return true if all of the credentials match. */ + @Override public boolean equals(Object o) { if (o == null) return false; if (this == o) return true; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/NameValuePair.java commons-httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/NameValuePair.java Mon Mar 14 21:23:16 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java Tue Jan 3 02:47:42 2006 @@ -126,10 +126,15 @@ * Get a String representation of this pair. * @return A string representation. */ + @Override public String toString() { return ("name=" + name + ", " + "value=" + value); } + /** + * {@inheritDoc} + */ + @Override public boolean equals(final Object object) { if (object == null) return false; if (this == object) return true; @@ -137,11 +142,14 @@ NameValuePair that = (NameValuePair) object; return LangUtils.equals(this.name, that.name) && LangUtils.equals(this.value, that.value); - } else { - return false; } + return false; } + /** + * {@inheritDoc} + */ + @Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.name); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/NoHttpResponseException.java commons-httpclient/src/java/org/apache/commons/httpclient/NoHttpResponseException.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/NoHttpResponseException.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/NoHttpResponseException.java Tue Jan 3 18:42:08 2006 @@ -31,8 +31,6 @@ import java.io.IOException; -import org.apache.commons.httpclient.util.ExceptionUtil; - /** *

* Signals that the target server failed to respond with a valid HTTP response. @@ -71,7 +69,6 @@ */ public NoHttpResponseException(String message, Throwable cause) { super(message); - // If we're running on JDK 1.4 or later, tell Throwable what the cause was - ExceptionUtil.initCause(this, cause); + initCause(cause); } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/ProxyClient.java commons-httpclient/src/java/org/apache/commons/httpclient/ProxyClient.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/ProxyClient.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/ProxyClient.java Tue Jan 3 19:53:47 2006 @@ -138,6 +138,7 @@ /** * Returns {@link HttpClientParams HTTP protocol parameters} associated with this ProxyClient. + * @return associated parameters * * @see HttpClientParams */ @@ -147,6 +148,7 @@ /** * Assigns {@link HttpClientParams HTTP protocol parameters} for this ProxyClient. + * @param params params to set * * @see HttpClientParams */ @@ -223,7 +225,9 @@ private Socket socket; - private ConnectResponse() {} + ConnectResponse() { + // nothing to do + } /** * Gets the method that was used to execute the connect. This method is useful for @@ -237,7 +241,7 @@ /** * @param connectMethod The connectMethod to set. */ - private void setConnectMethod(ConnectMethod connectMethod) { + void setConnectMethod(ConnectMethod connectMethod) { this.connectMethod = connectMethod; } /** @@ -253,7 +257,7 @@ /** * @param socket The socket to set. */ - private void setSocket(Socket socket) { + void setSocket(Socket socket) { this.socket = socket; } } @@ -267,17 +271,30 @@ private HttpParams connectionParams; + /** + * {@inheritDoc} + */ public void closeIdleConnections(long idleTimeout) { + // ignore } + /** + * @return used http connection + */ public HttpConnection getConnection() { return httpConnection; } + /** + * @param httpParams + */ public void setConnectionParams(HttpParams httpParams) { this.connectionParams = httpParams; } + /** + * {@inheritDoc} + */ public HttpConnection getConnectionWithTimeout( HostConfiguration hostConfiguration, long timeout) { @@ -288,25 +305,31 @@ } /** - * @deprecated + * {@inheritDoc} */ - public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) - throws HttpException { - return getConnectionWithTimeout(hostConfiguration, timeout); - } - public HttpConnection getConnection(HostConfiguration hostConfiguration) { return getConnectionWithTimeout(hostConfiguration, -1); } + /** + * {@inheritDoc} + */ public void releaseConnection(HttpConnection conn) { + //ignore } + /** + * {@inheritDoc} + */ public HttpConnectionManagerParams getParams() { return null; } + /** + * {@inheritDoc} + */ public void setParams(HttpConnectionManagerParams params) { + //ignore } } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/ProxyHost.java commons-httpclient/src/java/org/apache/commons/httpclient/ProxyHost.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/ProxyHost.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/ProxyHost.java Tue Jan 3 15:01:15 2006 @@ -75,6 +75,7 @@ /** * @see java.lang.Object#clone() */ + @Override public Object clone() { return new ProxyHost(this); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java commons-httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java Mon Oct 31 22:24:47 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/SimpleHttpConnectionManager.java Tue Jan 3 19:55:52 2006 @@ -31,10 +31,9 @@ import java.io.IOException; import java.io.InputStream; - import org.apache.commons.httpclient.params.HttpConnectionManagerParams; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A connection manager that provides access to a single HttpConnection. This @@ -51,7 +50,8 @@ */ public class SimpleHttpConnectionManager implements HttpConnectionManager { - private static final Log LOG = LogFactory.getLog(SimpleHttpConnectionManager.class); + private static final Logger LOG = LoggerFactory + .getLogger(SimpleHttpConnectionManager.class); private static final String MISUSE_MESSAGE = "SimpleHttpConnectionManager being used incorrectly. Be sure that" @@ -98,43 +98,18 @@ */ private volatile boolean inUse = false; + /** + * Do nothing constructor. + */ public SimpleHttpConnectionManager() { + // nothing to do } /** * @see HttpConnectionManager#getConnection(HostConfiguration) */ public HttpConnection getConnection(HostConfiguration hostConfiguration) { - return getConnection(hostConfiguration, 0); - } - - /** - * Gets the staleCheckingEnabled value to be set on HttpConnections that are created. - * - * @return true if stale checking will be enabled on HttpConections - * - * @see HttpConnection#isStaleCheckingEnabled() - * - * @deprecated Use {@link HttpConnectionManagerParams#isStaleCheckingEnabled()}, - * {@link HttpConnectionManager#getParams()}. - */ - public boolean isConnectionStaleCheckingEnabled() { - return this.params.isStaleCheckingEnabled(); - } - - /** - * Sets the staleCheckingEnabled value to be set on HttpConnections that are created. - * - * @param connectionStaleCheckingEnabled true if stale checking will be enabled - * on HttpConections - * - * @see HttpConnection#setStaleCheckingEnabled(boolean) - * - * @deprecated Use {@link HttpConnectionManagerParams#setStaleCheckingEnabled(boolean)}, - * {@link HttpConnectionManager#getParams()}. - */ - public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled) { - this.params.setStaleCheckingEnabled(connectionStaleCheckingEnabled); + return getConnectionWithTimeout(hostConfiguration, 0); } /** @@ -182,16 +157,6 @@ } /** - * @see HttpConnectionManager#getConnection(HostConfiguration, long) - * - * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long) - */ - public HttpConnection getConnection( - HostConfiguration hostConfiguration, long timeout) { - return getConnectionWithTimeout(hostConfiguration, timeout); - } - - /** * @see HttpConnectionManager#releaseConnection(org.apache.commons.httpclient.HttpConnection) */ public void releaseConnection(HttpConnection conn) { @@ -207,25 +172,16 @@ idleStartTime = System.currentTimeMillis(); } + /** - * Returns {@link HttpConnectionManagerParams parameters} associated - * with this connection manager. - * - * @since 2.1 - * - * @see HttpConnectionManagerParams + * {@inheritDoc} */ public HttpConnectionManagerParams getParams() { return this.params; } /** - * Assigns {@link HttpConnectionManagerParams parameters} for this - * connection manager. - * - * @since 2.1 - * - * @see HttpConnectionManagerParams + * {@inheritDoc} */ public void setParams(final HttpConnectionManagerParams params) { if (params == null) { @@ -235,7 +191,7 @@ } /** - * @since 3.0 + * {@inheritDoc} */ public void closeIdleConnections(long idleTimeout) { long maxIdleTime = System.currentTimeMillis() - idleTimeout; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/StatusLine.java commons-httpclient/src/java/org/apache/commons/httpclient/StatusLine.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/StatusLine.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/StatusLine.java Tue Jan 3 15:05:32 2006 @@ -160,6 +160,7 @@ * Return a string representation of this object. * @return a string represenation of this object. */ + @Override public final String toString() { return statusLine; } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/URI.java commons-httpclient/src/java/org/apache/commons/httpclient/URI.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/URI.java Fri Jun 3 15:18:34 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/URI.java Tue Jan 3 19:57:07 2006 @@ -121,6 +121,7 @@ /** Create an instance as an internal use */ protected URI() { + // nothing to do } /** @@ -166,80 +167,6 @@ } /** - * Construct a URI as an escaped form of a character array with the given - * charset. - * - * @param escaped the URI character sequence - * @param charset the charset string to do escape encoding - * @throws URIException If the URI cannot be created. - * @throws NullPointerException if escaped is null - * @see #getProtocolCharset - * - * @deprecated Use #URI(String, boolean, String) - */ - public URI(char[] escaped, String charset) - throws URIException, NullPointerException { - protocolCharset = charset; - parseUriReference(new String(escaped), true); - } - - - /** - * Construct a URI as an escaped form of a character array. - * An URI can be placed within double-quotes or angle brackets like - * "http://test.com/" and <http://test.com/> - * - * @param escaped the URI character sequence - * @throws URIException If the URI cannot be created. - * @throws NullPointerException if escaped is null - * @see #getDefaultProtocolCharset - * - * @deprecated Use #URI(String, boolean) - */ - public URI(char[] escaped) - throws URIException, NullPointerException { - parseUriReference(new String(escaped), true); - } - - - /** - * Construct a URI from the given string with the given charset. - * - * @param original the string to be represented to URI character sequence - * It is one of absoluteURI and relativeURI. - * @param charset the charset string to do escape encoding - * @throws URIException If the URI cannot be created. - * @see #getProtocolCharset - * - * @deprecated Use #URI(String, boolean, String) - */ - public URI(String original, String charset) throws URIException { - protocolCharset = charset; - parseUriReference(original, false); - } - - - /** - * Construct a URI from the given string. - *

-     *   URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
-     * 

- * An URI can be placed within double-quotes or angle brackets like - * "http://test.com/" and <http://test.com/> - * - * @param original the string to be represented to URI character sequence - * It is one of absoluteURI and relativeURI. - * @throws URIException If the URI cannot be created. - * @see #getDefaultProtocolCharset - * - * @deprecated Use #URI(String, boolean) - */ - public URI(String original) throws URIException { - parseUriReference(original, false); - } - - - /** * Construct a general URI from the given components. *

      *   URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
@@ -423,21 +350,6 @@
         this(scheme, host, path, null, fragment);
     }
 
-
-    /**
-     * Construct a general URI with the given relative URI string.
-     *
-     * @param base the base URI
-     * @param relative the relative URI string
-     * @throws URIException If the new URI cannot be created.
-     * 
-     * @deprecated Use #URI(URI, String, boolean)
-     */
-    public URI(URI base, String relative) throws URIException {
-        this(base, new URI(relative));
-    }
-
-
     /**
      * Construct a general URI with the given relative URI string.
      *
@@ -644,6 +556,7 @@
         try {
             defaultDocumentCharsetByPlatform = System.getProperty("file.encoding");
         } catch (SecurityException ignore) {
+        	// ignore
         }
         if (defaultDocumentCharset == null) {
             // set the default document charset
@@ -1671,11 +1584,10 @@
      * @param allowed those characters that are allowed within a component
      * @param charset the protocol charset
      * @return URI character sequence
-     * @throws URIException null component or unsupported character encoding
      */
         
     protected static char[] encode(String original, BitSet allowed,
-            String charset) throws URIException {
+            String charset) {
         if (original == null) {
             throw new IllegalArgumentException("Original string may not be null");
         }
@@ -2181,9 +2093,8 @@
             next = original.indexOf(']', from);
             if (next == -1) {
                 throw new URIException(URIException.PARSING, "IPv6reference");
-            } else {
-                next++;
             }
+            next++;
             // In IPv6reference, '[', ']' should be excluded
             _host = (escaped) ? original.substring(from, next).toCharArray() 
                 : encode(original.substring(from, next), allowed_IPv6reference,
@@ -2707,7 +2618,7 @@
      * Get the authority.
      *
      * @return the authority
-     * @throws URIException If {@link #decode} fails
+     * @throws URIException If {@link #decode(char[], String)} fails
      */
     public String getAuthority() throws URIException {
         return (_authority == null) ? null : decode(_authority,
@@ -2742,7 +2653,7 @@
      * Get the userinfo.
      *
      * @return the userinfo
-     * @throws URIException If {@link #decode} fails
+     * @throws URIException If {@link #decode(String, String)} fails
      * @see #getAuthority
      */
     public String getUserinfo() throws URIException {
@@ -2773,15 +2684,11 @@
      * 

* * @return the host - * @throws URIException If {@link #decode} fails + * @throws URIException If {@link #decode(String, String)} fails * @see #getAuthority */ public String getHost() throws URIException { - if (_host != null) { - return decode(_host, getProtocolCharset()); - } else { - return null; - } + return (_host != null) ? decode(_host, getProtocolCharset()) : null; } // --------------------------------------------------------------- The port @@ -2923,10 +2830,8 @@ * @param basePath a character array of the basePath * @param relPath a character array of the relPath * @return the resolved path - * @throws URIException no more higher path level to be resolved */ - protected char[] resolvePath(char[] basePath, char[] relPath) - throws URIException { + protected char[] resolvePath(char[] basePath, char[] relPath) { // REMINDME: paths are never null String base = (basePath == null) ? "" : new String(basePath); @@ -3007,7 +2912,7 @@ * * @return the current hierarchy level * @throws URIException If {@link #getRawCurrentHierPath(char[])} fails. - * @see #decode + * @see #decode(char[], String) */ public String getCurrentHierPath() throws URIException { char[] path = getRawCurrentHierPath(); @@ -3044,7 +2949,7 @@ * * @return the above hierarchy level * @throws URIException If {@link #getRawCurrentHierPath(char[])} fails. - * @see #decode + * @see #decode(char[], String) */ public String getAboveHierPath() throws URIException { char[] path = getRawAboveHierPath(); @@ -3087,8 +2992,8 @@ * path = [ abs_path | opaque_part ] *

* @return the path string - * @throws URIException If {@link #decode} fails. - * @see #decode + * @throws URIException If {@link #decode(char[], String)} fails. + * @see #decode(char[], String) */ public String getPath() throws URIException { char[] path = getRawPath(); @@ -3137,7 +3042,7 @@ * @return the basename string * @throws URIException incomplete trailing escape pattern or unsupported * character encoding - * @see #decode + * @see #decode(char[], String) */ public String getName() throws URIException { char[] basename = getRawName(); @@ -3186,7 +3091,7 @@ * @return the path and query string. * @throws URIException incomplete trailing escape pattern or unsupported * character encoding - * @see #decode + * @see #decode(char[], String) */ public String getPathQuery() throws URIException { char[] rawPathQuery = getRawPathQuery(); @@ -3288,7 +3193,7 @@ * @return the query string. * @throws URIException incomplete trailing escape pattern or unsupported * character encoding - * @see #decode + * @see #decode(char[], String) */ public String getQuery() throws URIException { return (_query == null) ? null : decode(_query, getProtocolCharset()); @@ -3337,9 +3242,8 @@ * Set the fragment. * * @param fragment the fragment string. - * @throws URIException If an error occurs. */ - public void setFragment(String fragment) throws URIException { + public void setFragment(String fragment) { if (fragment == null || fragment.length() == 0) { _fragment = (fragment == null) ? null : fragment.toCharArray(); hash = 0; @@ -3386,7 +3290,7 @@ * @return the fragment string * @throws URIException incomplete trailing escape pattern or unsupported * character encoding - * @see #decode + * @see #decode(char[], String) */ public String getFragment() throws URIException { return (_fragment == null) ? null : decode(_fragment, @@ -3422,9 +3326,8 @@ * * @param path the path to normalize * @return the normalized path - * @throws URIException no more higher path level to be normalized */ - protected char[] normalize(char[] path) throws URIException { + protected char[] normalize(char[] path) { if (path == null) { return null; @@ -3483,9 +3386,8 @@ int slashIndex = normalized.lastIndexOf('/', index - 1); if (slashIndex >= 0) { break; - } else { - normalized = normalized.substring(index + 3); } + normalized = normalized.substring(index + 3); } if (normalized.endsWith("/..")) { int slashIndex = normalized.lastIndexOf('/', normalized.length() - 4); @@ -3503,11 +3405,9 @@ * URIs with an absolute path. Calling this method on a relative path URI will have no * effect. * - * @throws URIException no more higher path level to be normalized - * * @see #isAbsPath() */ - public void normalize() throws URIException { + public void normalize() { if (isAbsPath()) { _path = normalize(_path); setURI(); @@ -3548,6 +3448,7 @@ * @param obj an object to compare * @return true if two URI objects are equal */ + @Override public boolean equals(Object obj) { // normalize and test each components @@ -3622,6 +3523,7 @@ * * @return a has code value for this URI */ + @Override public int hashCode() { if (hash == 0) { char[] c = _uri; @@ -3671,6 +3573,7 @@ * * @return a clone of this instance */ + @Override public synchronized Object clone() { URI instance = new URI(); @@ -3741,7 +3644,7 @@ * @return the original URI string * @throws URIException incomplete trailing escape pattern or unsupported * character encoding - * @see #decode + * @see #decode(char[], String) */ public String getURI() throws URIException { return (_uri == null) ? null : decode(_uri, getProtocolCharset()); @@ -3781,7 +3684,7 @@ * Get the original URI reference string. * * @return the original URI reference string - * @throws URIException If {@link #decode} fails. + * @throws URIException If {@link #decode(char[], String)} fails. */ public String getURIReference() throws URIException { char[] uriReference = getRawURIReference(); @@ -3807,6 +3710,7 @@ * @return the escaped URI string * @see #clone() */ + @Override public String toString() { return getEscapedURI(); } @@ -3886,9 +3790,9 @@ public static class LocaleToCharsetMap { /** A mapping of language code to charset */ - private static final Hashtable LOCALE_TO_CHARSET_MAP; + private static final Hashtable LOCALE_TO_CHARSET_MAP; static { - LOCALE_TO_CHARSET_MAP = new Hashtable(); + LOCALE_TO_CHARSET_MAP = new Hashtable(); LOCALE_TO_CHARSET_MAP.put("ar", "ISO-8859-6"); LOCALE_TO_CHARSET_MAP.put("be", "ISO-8859-5"); LOCALE_TO_CHARSET_MAP.put("bg", "ISO-8859-5"); @@ -3939,14 +3843,13 @@ */ public static String getCharset(Locale locale) { // try for an full name match (may include country) - String charset = - (String) LOCALE_TO_CHARSET_MAP.get(locale.toString()); + String charset = LOCALE_TO_CHARSET_MAP.get(locale.toString()); if (charset != null) { return charset; } // if a full name didn't match, try just the language - charset = (String) LOCALE_TO_CHARSET_MAP.get(locale.getLanguage()); + charset = LOCALE_TO_CHARSET_MAP.get(locale.getLanguage()); return charset; // may be null } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/URIException.java commons-httpclient/src/java/org/apache/commons/httpclient/URIException.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/URIException.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/URIException.java Tue Jan 3 16:29:18 2006 @@ -44,6 +44,7 @@ * Default constructor. */ public URIException() { + // do nothing } @@ -64,8 +65,7 @@ * @param reason the reason */ public URIException(int reasonCode, String reason) { - super(reason); // for backward compatibility of Throwable - this.reason = reason; + super(reason); this.reasonCode = reasonCode; } @@ -76,8 +76,7 @@ * @param reason the reason */ public URIException(String reason) { - super(reason); // for backward compatibility of Throwable - this.reason = reason; + super(reason); this.reasonCode = UNKNOWN; } @@ -119,12 +118,6 @@ */ protected int reasonCode; - - /** - * The reason message. - */ - protected String reason; - // ---------------------------------------------------------------- methods /** @@ -135,43 +128,5 @@ public int getReasonCode() { return reasonCode; } - - /** - * Set the reason code. - * - * @param reasonCode the reason code - * - * @deprecated Callers should set the reason code as a parameter to the - * constructor. - */ - public void setReasonCode(int reasonCode) { - this.reasonCode = reasonCode; - } - - - /** - * Get the reason message. - * - * @return the reason message - * - * @deprecated You should instead call {@link #getMessage()}. - */ - public String getReason() { - return reason; - } - - - /** - * Set the reason message. - * - * @param reason the reason message - * - * @deprecated Callers should instead set this via a parameter to the constructor. - */ - public void setReason(String reason) { - this.reason = reason; - } - - } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java commons-httpclient/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java Wed Oct 19 22:51:46 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java Tue Jan 3 19:59:30 2006 @@ -45,17 +45,6 @@ public class UsernamePasswordCredentials implements Credentials { // ----------------------------------------------------------- Constructors - - /** - * Default constructor. - * - * @deprecated Do not use. Null user name no longer allowed - */ - public UsernamePasswordCredentials() { - super(); - } - - /** * The constructor with the username and password combined string argument. * @@ -107,53 +96,19 @@ // ------------------------------------------------------------- Properties - - - /** - * User name property setter. User name may not be null. - * - * @param userName - * @see #getUserName() - * - * @deprecated Do not use. The UsernamePasswordCredentials objects should be immutable - */ - public void setUserName(String userName) { - if (userName == null) { - throw new IllegalArgumentException("Username may not be null"); - } - this.userName = userName; - } - - /** * User name property getter. * * @return the userName - * @see #setUserName(String) */ public String getUserName() { return userName; } - - /** - * Password property setter. - * - * @param password - * @see #getPassword() - * - * @deprecated Do not use. The UsernamePasswordCredentials objects should be immutable - */ - public void setPassword(String password) { - this.password = password; - } - - /** * Password property getter. * * @return the password - * @see #setPassword(String) */ public String getPassword() { return password; @@ -165,6 +120,7 @@ * * @return the username:password formed string */ + @Override public String toString() { StringBuffer result = new StringBuffer(); result.append(this.userName); @@ -178,6 +134,7 @@ * * @return The hash code including user name and password. */ + @Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.userName); @@ -193,6 +150,7 @@ * * @return true if the object is equivalent. */ + @Override public boolean equals(Object o) { if (o == null) return false; if (this == o) return true; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/Wire.java commons-httpclient/src/java/org/apache/commons/httpclient/Wire.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/Wire.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/Wire.java Tue Jan 3 15:21:41 2006 @@ -29,11 +29,11 @@ package org.apache.commons.httpclient; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.ByteArrayInputStream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Logs data to the wire LOG. @@ -44,14 +44,15 @@ */ class Wire { - public static Wire HEADER_WIRE = new Wire(LogFactory.getLog("httpclient.wire.header")); - - public static Wire CONTENT_WIRE = new Wire(LogFactory.getLog("httpclient.wire.content")); + /** wire for header logging */ + public static Wire HEADER_WIRE = new Wire(LoggerFactory.getLogger("httpclient.wire.header")); + /** wire for content logging */ + public static Wire CONTENT_WIRE = new Wire(LoggerFactory.getLogger("httpclient.wire.content")); /** Log for any wire messages. */ - private Log log; + private Logger log; - private Wire(Log log) { + private Wire(Logger log) { this.log = log; } @@ -85,10 +86,17 @@ } + /** + * @return true if logging of debug level is enabled. + */ public boolean enabled() { return log.isDebugEnabled(); } + /** + * @param outstream + * @throws IOException + */ public void output(InputStream outstream) throws IOException { if (outstream == null) { @@ -97,6 +105,10 @@ wire(">> ", outstream); } + /** + * @param instream + * @throws IOException + */ public void input(InputStream instream) throws IOException { if (instream == null) { @@ -105,6 +117,12 @@ wire("<< ", instream); } + /** + * @param b + * @param off + * @param len + * @throws IOException + */ public void output(byte[] b, int off, int len) throws IOException { if (b == null) { @@ -113,6 +131,12 @@ wire(">> ", new ByteArrayInputStream(b, off, len)); } + /** + * @param b + * @param off + * @param len + * @throws IOException + */ public void input(byte[] b, int off, int len) throws IOException { if (b == null) { @@ -121,6 +145,10 @@ wire("<< ", new ByteArrayInputStream(b, off, len)); } + /** + * @param b + * @throws IOException + */ public void output(byte[] b) throws IOException { if (b == null) { @@ -129,6 +157,10 @@ wire(">> ", new ByteArrayInputStream(b)); } + /** + * @param b + * @throws IOException + */ public void input(byte[] b) throws IOException { if (b == null) { @@ -137,16 +169,28 @@ wire("<< ", new ByteArrayInputStream(b)); } + /** + * @param b + * @throws IOException + */ public void output(int b) throws IOException { output(new byte[] {(byte) b}); } + /** + * @param b + * @throws IOException + */ public void input(int b) throws IOException { input(new byte[] {(byte) b}); } + /** + * @param s + * @throws IOException + */ public void output(final String s) throws IOException { if (s == null) { @@ -155,6 +199,10 @@ output(s.getBytes()); } + /** + * @param s + * @throws IOException + */ public void input(final String s) throws IOException { if (s == null) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/WireLogInputStream.java commons-httpclient/src/java/org/apache/commons/httpclient/WireLogInputStream.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/WireLogInputStream.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/WireLogInputStream.java Tue Jan 3 15:22:03 2006 @@ -64,6 +64,7 @@ * * @see java.io.InputStream#read(byte[], int, int) */ + @Override public int read(byte[] b, int off, int len) throws IOException { int l = this.in.read(b, off, len); if (l > 0) { @@ -76,6 +77,7 @@ * * @see java.io.InputStream#read() */ + @Override public int read() throws IOException { int l = this.in.read(); if (l > 0) { @@ -88,6 +90,7 @@ * * @see java.io.InputStream#read(byte[]) */ + @Override public int read(byte[] b) throws IOException { int l = this.in.read(b); if (l > 0) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/WireLogOutputStream.java commons-httpclient/src/java/org/apache/commons/httpclient/WireLogOutputStream.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/WireLogOutputStream.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/WireLogOutputStream.java Tue Jan 3 07:22:07 2006 @@ -63,6 +63,7 @@ * * @see java.io.OutputStream#write(byte[], int, int) */ + @Override public void write(byte[] b, int off, int len) throws IOException { this.out.write(b, off, len); wire.output(b, off, len); @@ -70,8 +71,11 @@ /** * - * @see java.io.OutputStream#write() + * @param b + * @throws IOException + * @see java.io.OutputStream#write(int) */ + @Override public void write(int b) throws IOException { this.out.write(b); wire.output(b); @@ -81,6 +85,7 @@ * * @see java.io.OutputStream#write(byte[]) */ + @Override public void write(byte[] b) throws IOException { this.out.write(b); wire.output(b); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthChallengeParser.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthChallengeParser.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthChallengeParser.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthChallengeParser.java Tue Jan 3 02:48:24 2006 @@ -87,7 +87,7 @@ * * @since 2.0beta1 */ - public static Map extractParams(final String challengeStr) + public static Map extractParams(final String challengeStr) throws MalformedChallengeException { if (challengeStr == null) { throw new IllegalArgumentException("Challenge may not be null"); @@ -96,12 +96,12 @@ if (idx == -1) { throw new MalformedChallengeException("Invalid challenge: " + challengeStr); } - Map map = new HashMap(); + Map map = new HashMap(); ParameterParser parser = new ParameterParser(); - List params = parser.parse( + List params = parser.parse( challengeStr.substring(idx + 1, challengeStr.length()), ','); for (int i = 0; i < params.size(); i++) { - NameValuePair param = (NameValuePair) params.get(i); + NameValuePair param = params.get(i); map.put(param.getName().toLowerCase(), param.getValue()); } return map; @@ -118,13 +118,13 @@ * * @since 3.0 */ - public static Map parseChallenges(final Header[] headers) + public static Map parseChallenges(final Header[] headers) throws MalformedChallengeException { if (headers == null) { throw new IllegalArgumentException("Array of challenges may not be null"); } String challenge = null; - Map challengemap = new HashMap(headers.length); + Map challengemap = new HashMap(headers.length); for (int i = 0; i < headers.length; i++) { challenge = headers[i].getValue(); String s = AuthChallengeParser.extractScheme(challenge); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthChallengeProcessor.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthChallengeProcessor.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthChallengeProcessor.java Mon Sep 19 22:37:48 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthChallengeProcessor.java Tue Jan 3 02:49:36 2006 @@ -32,10 +32,9 @@ import java.util.Collection; import java.util.Iterator; import java.util.Map; - import org.apache.commons.httpclient.params.HttpParams; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class provides utility methods for processing HTTP www and proxy authentication @@ -47,8 +46,8 @@ */ public final class AuthChallengeProcessor { - private static final Log LOG = LogFactory.getLog(AuthChallengeProcessor.class); - + private static final Logger LOG = LoggerFactory + .getLogger(AuthChallengeProcessor.class); private HttpParams params = null; /** @@ -105,13 +104,12 @@ throw new AuthChallengeException(e.getMessage()); } break; - } else { + } if (LOG.isDebugEnabled()) { LOG.debug("Challenge for " + id + " authentication scheme not available"); // Try again } } - } if (authscheme == null) { // If none selected, something is wrong throw new AuthChallengeException( @@ -124,11 +122,14 @@ /** * Processes the given collection of challenges and updates the * {@link AuthState state} of the authentication process. + * @param state * * @param challenges the collection of authentication challenges * * @return the {@link AuthScheme authentication scheme} used to * process the challenge + * @throws MalformedChallengeException + * @throws AuthenticationException * * @throws AuthChallengeException if authentication challenges cannot be * successfully processed or the preferred authentication scheme cannot diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthPolicy.java Tue Jan 3 02:51:41 2006 @@ -32,9 +32,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Authentication policy class. The Authentication policy provides corresponding @@ -56,8 +55,8 @@ */ public abstract class AuthPolicy { - private static final HashMap SCHEMES = new HashMap(); - private static final ArrayList SCHEME_LIST = new ArrayList(); + private static final HashMap SCHEMES = new HashMap(); + private static final ArrayList SCHEME_LIST = new ArrayList(); /** * The key used to look up the list of IDs of supported {@link AuthScheme @@ -102,7 +101,7 @@ } /** Log object. */ - protected static final Log LOG = LogFactory.getLog(AuthPolicy.class); + protected static final Logger LOG = LoggerFactory.getLogger(AuthPolicy.class); /** * Registers a class implementing an {@link AuthScheme authentication scheme} with @@ -161,7 +160,7 @@ if (id == null) { throw new IllegalArgumentException("Id may not be null"); } - Class clazz = (Class)SCHEMES.get(id.toLowerCase()); + Class clazz = SCHEMES.get(id.toLowerCase()); if (clazz != null) { try { return (AuthScheme)clazz.newInstance(); @@ -171,9 +170,8 @@ " authentication scheme implemented by " + clazz.getName() + " could not be initialized"); } - } else { - throw new IllegalStateException("Unsupported authentication scheme " + id); } + throw new IllegalStateException("Unsupported authentication scheme " + id); } /** diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthScheme.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthScheme.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthScheme.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthScheme.java Tue Jan 3 17:37:44 2006 @@ -75,6 +75,7 @@ * to maintain the state information when dealing with sequential challenges * * @param challenge the challenge string + * @throws MalformedChallengeException * * @since 3.0 */ @@ -106,26 +107,6 @@ String getRealm(); /** - * Returns a String identifying the authentication challenge. This is - * used, in combination with the host and port to determine if - * authorization has already been attempted or not. Schemes which - * require multiple requests to complete the authentication should - * return a different value for each stage in the request. - * - *

Additionally, the ID should take into account any changes to the - * authentication challenge and return a different value when appropriate. - * For example when the realm changes in basic authentication it should be - * considered a different authentication attempt and a different value should - * be returned.

- * - * @return String a String identifying the authentication challenge. The - * returned value may be null. - * - * @deprecated no longer used - */ - String getID(); - - /** * Tests if the authentication scheme is provides authorization on a per * connection basis instead of usual per request basis * @@ -148,30 +129,6 @@ * @since 3.0 */ boolean isComplete(); - /** - * @deprecated Use {@link #authenticate(Credentials, HttpMethod)} - * - * Produces an authorization string for the given set of {@link Credentials}, - * method name and URI using the given authentication scheme in response to - * the actual authorization challenge. - * - * @param credentials The set of credentials to be used for athentication - * @param method The name of the method that requires authorization. - * This parameter may be ignored, if it is irrelevant - * or not applicable to the given authentication scheme - * @param uri The URI for which authorization is needed. - * This parameter may be ignored, if it is irrelevant or not - * applicable to the given authentication scheme - * @throws AuthenticationException if authorization string cannot - * be generated due to an authentication failure - * - * @return the authorization string - * - * @see org.apache.commons.httpclient.HttpMethod#getName() - * @see org.apache.commons.httpclient.HttpMethod#getPath() - */ - String authenticate(Credentials credentials, String method, String uri) - throws AuthenticationException; /** * Produces an authorization string for the given set of {@link Credentials}. diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthSchemeBase.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthSchemeBase.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthSchemeBase.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthSchemeBase.java Thu Jan 1 01:00:00 1970 @@ -1,92 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/auth/AuthSchemeBase.java,v 1.7 2004/04/18 23:51:36 jsdever Exp $ - * $Revision: 155418 $ - * $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - * - * ==================================================================== - * - * Copyright 2002-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient.auth; - -/** - *

- * Abstract authentication scheme class that implements {@link AuthScheme} - * interface and provides a default contstructor. - *

- * @deprecated No longer used - * - * @author Oleg Kalnichevski - */ -public abstract class AuthSchemeBase implements AuthScheme { - - /** - * Original challenge string as received from the server. - */ - private String challenge = null; - - /** - * Constructor for an abstract authetication schemes. - * - * @param challenge authentication challenge - * - * @throws MalformedChallengeException is thrown if the authentication challenge - * is malformed - * - * @deprecated Use parameterless constructor and {@link AuthScheme#processChallenge(String)} - * method - */ - public AuthSchemeBase(final String challenge) - throws MalformedChallengeException { - super(); - if (challenge == null) { - throw new IllegalArgumentException("Challenge may not be null"); - } - this.challenge = challenge; - } - - /** - * @see java.lang.Object#equals(Object) - */ - public boolean equals(Object obj) { - if (obj instanceof AuthSchemeBase) { - return this.challenge.equals(((AuthSchemeBase) obj).challenge); - } else { - return super.equals(obj); - } - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() { - return this.challenge.hashCode(); - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() { - return this.challenge; - } -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthScope.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthScope.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthScope.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthScope.java Tue Jan 3 02:56:45 2006 @@ -108,7 +108,7 @@ this.host = (host == null) ? ANY_HOST: host.toLowerCase(); this.port = (port < 0) ? ANY_PORT: port; this.realm = (realm == null) ? ANY_REALM: realm; - this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase();; + this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(); } /** Creates a new credentials scope for the given @@ -150,6 +150,7 @@ /** * Creates a copy of the given credentials scope. + * @param authscope * * @since 3.0 */ @@ -207,11 +208,7 @@ * @return boolean true if the parameters are equal, otherwise false. */ private static boolean paramsEqual(final String p1, final String p2) { - if (p1 == null) { - return p1 == p2; - } else { - return p1.equals(p2); - } + return (p1 == null) ? p1 == p2 : p1.equals(p2); } /** Determines if the given parameters are equal. @@ -226,6 +223,7 @@ /** * Tests if the authentication scopes match. + * @param that * * @return the match factor. Negative value signifies no match. * Non-negative signifies a match. The greater the returned value @@ -267,8 +265,9 @@ } /** - * @see java.lang.Object#equals(Object) + * {@inheritDoc} */ + @Override public boolean equals(Object o) { if (o == null) { return false; @@ -288,8 +287,9 @@ } /** - * @see java.lang.Object#toString() + * {@inheritDoc} */ + @Override public String toString() { StringBuffer buffer = new StringBuffer(); if (this.scheme != null) { @@ -315,8 +315,9 @@ } /** - * @see java.lang.Object#hashCode() + * {@inheritDoc} */ + @Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.host); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthState.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthState.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/AuthState.java Mon Sep 19 22:37:48 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/AuthState.java Tue Jan 3 02:58:22 2006 @@ -38,6 +38,7 @@ */ public class AuthState { + /** {@value #PREEMPTIVE_AUTH_SCHEME} */ public static final String PREEMPTIVE_AUTH_SCHEME = "basic"; /** Actual authentication scheme */ @@ -165,13 +166,13 @@ * @return the name of the authentication realm */ public String getRealm() { - if (this.authScheme != null) { - return this.authScheme.getRealm(); - } else { - return null; - } + return (this.authScheme != null) ? this.authScheme.getRealm() : null; } + /** + * {@inheritDoc} + */ + @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("Auth state: auth requested ["); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/BasicScheme.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/BasicScheme.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/BasicScheme.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/BasicScheme.java Tue Jan 3 17:44:02 2006 @@ -34,8 +34,8 @@ import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

@@ -55,8 +55,8 @@ public class BasicScheme extends RFC2617Scheme { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(BasicScheme.class); - + private static final Logger LOG = LoggerFactory + .getLogger(BasicScheme.class); /** Whether the basic authentication process is complete */ private boolean complete; @@ -71,22 +71,6 @@ } /** - * Constructor for the basic authetication scheme. - * - * @param challenge authentication challenge - * - * @throws MalformedChallengeException is thrown if the authentication challenge - * is malformed - * - * @deprecated Use parameterless constructor and {@link AuthScheme#processChallenge(String)} - * method - */ - public BasicScheme(final String challenge) throws MalformedChallengeException { - super(challenge); - this.complete = true; - } - - /** * Returns textual designation of the basic authentication scheme. * * @return basic @@ -105,6 +89,7 @@ * * @since 3.0 */ + @Override public void processChallenge(String challenge) throws MalformedChallengeException { @@ -125,38 +110,6 @@ } /** - * Produces basic authorization string for the given set of - * {@link Credentials}. - * - * @param credentials The set of credentials to be used for athentication - * @param method Method name is ignored by the basic authentication scheme - * @param uri URI is ignored by the basic authentication scheme - * @throws InvalidCredentialsException if authentication credentials - * are not valid or not applicable for this authentication scheme - * @throws AuthenticationException if authorization string cannot - * be generated due to an authentication failure - * - * @return a basic authorization string - * - * @deprecated Use {@link #authenticate(Credentials, HttpMethod)} - */ - public String authenticate(Credentials credentials, String method, String uri) - throws AuthenticationException { - - LOG.trace("enter BasicScheme.authenticate(Credentials, String, String)"); - - UsernamePasswordCredentials usernamepassword = null; - try { - usernamepassword = (UsernamePasswordCredentials) credentials; - } catch (ClassCastException e) { - throw new InvalidCredentialsException( - "Credentials cannot be used for basic authentication: " - + credentials.getClass().getName()); - } - return BasicScheme.authenticate(usernamepassword); - } - - /** * Returns false. Basic authentication scheme is request based. * * @return false. @@ -183,7 +136,7 @@ */ public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { - LOG.trace("enter BasicScheme.authenticate(Credentials, HttpMethod)"); + LOG.debug("enter BasicScheme.authenticate(Credentials, HttpMethod)"); if (method == null) { throw new IllegalArgumentException("Method may not be null"); @@ -202,20 +155,6 @@ } /** - * @deprecated Use {@link #authenticate(UsernamePasswordCredentials, String)} - * - * Returns a basic Authorization header value for the given - * {@link UsernamePasswordCredentials}. - * - * @param credentials The credentials to encode. - * - * @return a basic authorization string - */ - public static String authenticate(UsernamePasswordCredentials credentials) { - return authenticate(credentials, "ISO-8859-1"); - } - - /** * Returns a basic Authorization header value for the given * {@link UsernamePasswordCredentials} and charset. * @@ -228,7 +167,7 @@ */ public static String authenticate(UsernamePasswordCredentials credentials, String charset) { - LOG.trace("enter BasicScheme.authenticate(UsernamePasswordCredentials, String)"); + LOG.debug("enter BasicScheme.authenticate(UsernamePasswordCredentials, String)"); if (credentials == null) { throw new IllegalArgumentException("Credentials may not be null"); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/CredentialsProvider.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/CredentialsProvider.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/CredentialsProvider.java Mon Dec 19 10:19:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/CredentialsProvider.java Tue Jan 3 03:03:11 2006 @@ -77,6 +77,8 @@ * @param port the port of the authentication host * @param proxy true if authenticating with a proxy, * false otherwise + * @return additional credentials + * @throws CredentialsNotAvailableException */ public Credentials getCredentials( final AuthScheme scheme, diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/DigestScheme.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/DigestScheme.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/DigestScheme.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/DigestScheme.java Tue Jan 3 17:39:22 2006 @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; - import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.HttpClientError; import org.apache.commons.httpclient.HttpMethod; @@ -42,8 +41,8 @@ import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.util.EncodingUtil; import org.apache.commons.httpclient.util.ParameterFormatter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

@@ -76,7 +75,8 @@ public class DigestScheme extends RFC2617Scheme { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(DigestScheme.class); + private static final Logger LOG = LoggerFactory + .getLogger(DigestScheme.class); /** * Hexa values used when creating 32 character long digest in HTTP DigestScheme @@ -114,41 +114,6 @@ } /** - * Gets an ID based upon the realm and the nonce value. This ensures that requests - * to the same realm with different nonce values will succeed. This differentiation - * allows servers to request re-authentication using a fresh nonce value. - * - * @deprecated no longer used - */ - public String getID() { - - String id = getRealm(); - String nonce = getParameter("nonce"); - if (nonce != null) { - id += "-" + nonce; - } - - return id; - } - - /** - * Constructor for the digest authetication scheme. - * - * @param challenge authentication challenge - * - * @throws MalformedChallengeException is thrown if the authentication challenge - * is malformed - * - * @deprecated Use parameterless constructor and {@link AuthScheme#processChallenge(String)} - * method - */ - public DigestScheme(final String challenge) - throws MalformedChallengeException { - this(); - processChallenge(challenge); - } - - /** * Processes the Digest challenge. * * @param challenge the challenge string @@ -158,6 +123,7 @@ * * @since 3.0 */ + @Override public void processChallenge(final String challenge) throws MalformedChallengeException { super.processChallenge(challenge); @@ -206,11 +172,7 @@ */ public boolean isComplete() { String s = getParameter("stale"); - if ("true".equalsIgnoreCase(s)) { - return false; - } else { - return this.complete; - } + return "true".equalsIgnoreCase(s) ? false : this.complete; } /** @@ -238,47 +200,6 @@ * {@link Credentials}, method name and URI. * * @param credentials A set of credentials to be used for athentication - * @param method the name of the method that requires authorization. - * @param uri The URI for which authorization is needed. - * - * @throws InvalidCredentialsException if authentication credentials - * are not valid or not applicable for this authentication scheme - * @throws AuthenticationException if authorization string cannot - * be generated due to an authentication failure - * - * @return a digest authorization string - * - * @see org.apache.commons.httpclient.HttpMethod#getName() - * @see org.apache.commons.httpclient.HttpMethod#getPath() - * - * @deprecated Use {@link #authenticate(Credentials, HttpMethod)} - */ - public String authenticate(Credentials credentials, String method, String uri) - throws AuthenticationException { - - LOG.trace("enter DigestScheme.authenticate(Credentials, String, String)"); - - UsernamePasswordCredentials usernamepassword = null; - try { - usernamepassword = (UsernamePasswordCredentials) credentials; - } catch (ClassCastException e) { - throw new InvalidCredentialsException( - "Credentials cannot be used for digest authentication: " - + credentials.getClass().getName()); - } - getParameters().put("methodname", method); - getParameters().put("uri", uri); - String digest = createDigest( - usernamepassword.getUserName(), - usernamepassword.getPassword()); - return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest); - } - - /** - * Produces a digest authorization string for the given set of - * {@link Credentials}, method name and URI. - * - * @param credentials A set of credentials to be used for athentication * @param method The method being authenticated * * @throws InvalidCredentialsException if authentication credentials @@ -293,7 +214,7 @@ public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { - LOG.trace("enter DigestScheme.authenticate(Credentials, HttpMethod)"); + LOG.debug("enter DigestScheme.authenticate(Credentials, HttpMethod)"); UsernamePasswordCredentials usernamepassword = null; try { @@ -329,7 +250,7 @@ */ private String createDigest(final String uname, final String pwd) throws AuthenticationException { - LOG.trace("enter DigestScheme.createDigest(String, String, Map)"); + LOG.debug("enter DigestScheme.createDigest(String, String, Map)"); final String digAlg = "MD5"; @@ -450,10 +371,9 @@ * * @return The digest-response as String. */ - private String createDigestHeader(final String uname, final String digest) - throws AuthenticationException { + private String createDigestHeader(final String uname, final String digest) { - LOG.trace("enter DigestScheme.createDigestHeader(String, Map, " + LOG.debug("enter DigestScheme.createDigestHeader(String, Map, " + "String)"); String uri = getParameter("uri"); @@ -463,7 +383,7 @@ String response = digest; String algorithm = getParameter("algorithm"); - List params = new ArrayList(20); + List params = new ArrayList(20); params.add(new NameValuePair("username", uname)); params.add(new NameValuePair("realm", realm)); params.add(new NameValuePair("nonce", nonce)); @@ -484,7 +404,7 @@ StringBuffer buffer = new StringBuffer(); for (int i = 0; i < params.size(); i++) { - NameValuePair param = (NameValuePair) params.get(i); + NameValuePair param = params.get(i); if (i > 0) { buffer.append(", "); } @@ -514,7 +434,7 @@ * @return encoded MD5, or null if encoding failed */ private static String encode(byte[] binaryData) { - LOG.trace("enter DigestScheme.encode(byte[])"); + LOG.debug("enter DigestScheme.encode(byte[])"); if (binaryData.length != 16) { return null; @@ -522,8 +442,8 @@ char[] buffer = new char[32]; for (int i = 0; i < 16; i++) { - int low = (int) (binaryData[i] & 0x0f); - int high = (int) ((binaryData[i] & 0xf0) >> 4); + int low = (binaryData[i] & 0x0f); + int high = ((binaryData[i] & 0xf0) >> 4); buffer[i * 2] = HEXADECIMAL[high]; buffer[(i * 2) + 1] = HEXADECIMAL[low]; } @@ -539,7 +459,7 @@ * @throws HttpClientError if MD5 algorithm is not supported. */ public static String createCnonce() { - LOG.trace("enter DigestScheme.createCnonce()"); + LOG.debug("enter DigestScheme.createCnonce()"); String cnonce; final String digAlg = "MD5"; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java Thu Jan 1 01:00:00 1970 @@ -1,56 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthRealm.java,v 1.9 2004/06/12 22:47:23 olegk Exp $ - * $Revision: 155418 $ - * $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - * - * ==================================================================== - * - * Copyright 1999-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient.auth; - -/** The key used to look up authentication credentials. - * - * @author Oleg Kalnichevski - * @author Adrian Sutton - * - * @deprecated no longer used - */ -public class HttpAuthRealm extends AuthScope { - - /** Creates a new HttpAuthRealm for the given domain and - * realm. - * - * @param domain the domain the credentials apply to. May be set - * to null if credenticals are applicable to - * any domain. - * @param realm the realm the credentials apply to. May be set - * to null if credenticals are applicable to - * any realm. - * - */ - public HttpAuthRealm(final String domain, final String realm) { - super(domain, ANY_PORT, realm, ANY_SCHEME); - } - -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/HttpAuthenticator.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthenticator.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/HttpAuthenticator.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthenticator.java Thu Jan 1 01:00:00 1970 @@ -1,392 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/auth/HttpAuthenticator.java,v 1.19 2004/10/06 17:32:04 olegk Exp $ - * $Revision: 155418 $ - * $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - * - * ==================================================================== - * - * Copyright 1999-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient.auth; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.httpclient.Credentials; -import org.apache.commons.httpclient.Header; -import org.apache.commons.httpclient.HttpConnection; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.HttpState; -import org.apache.commons.httpclient.UsernamePasswordCredentials; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Utility methods for HTTP authorization and authentication. This class - * provides utility methods for generating responses to HTTP www and proxy - * authentication challenges. - * - *

- * A client SHOULD assume that all paths at or deeper than the depth of the - * last symbolic element in the path field of the Request-URI also are within - * the protection space specified by the basic realm value of the current - * challenge. A client MAY preemptively send the corresponding Authorization - * header with requests for resources in that space without receipt of another - * challenge from the server. Similarly, when a client sends a request to a - * proxy, it may reuse a userid and password in the Proxy-Authorization header - * field without receiving another challenge from the proxy server. - *
- *

- * - * @author Remy Maucherat - * @author Rodney Waldhoff - * @author Jeff Dever - * @author Ortwin Gl�ck - * @author Sean C. Sullivan - * @author Adrian Sutton - * @author Mike Bowler - * @author Oleg Kalnichevski - * - * @deprecated no longer used - */ -public final class HttpAuthenticator { - - /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpAuthenticator.class); - - /** - * The www authenticate challange header. - */ - public static final String WWW_AUTH = "WWW-Authenticate"; - - /** - * The www authenticate response header. - */ - public static final String WWW_AUTH_RESP = "Authorization"; - - /** - * The proxy authenticate challange header. - */ - public static final String PROXY_AUTH = "Proxy-Authenticate"; - - /** - * The proxy authenticate response header. - */ - public static final String PROXY_AUTH_RESP = "Proxy-Authorization"; - - /** Chooses the strongest authentication scheme supported from the - * array of authentication challenges. Currently only NTLM, - * Digest, Basic schemes are recognized. - * The NTLM scheme is considered the strongest and is - * preferred to all others. The Digest scheme is preferred to - * the Basic one which provides no encryption for credentials. - * The Basic scheme is used only if it is the only one - * supported. - * - * @param challenges The array of authentication challenges - * - * @return The strongest authentication scheme supported - * - * @throws MalformedChallengeException is thrown if an authentication - * challenge is malformed - * @throws UnsupportedOperationException when none of challenge types - * available is supported. - * - * @deprecated Use {@link AuthChallengeParser#parseChallenges(Header[])} and - * {@link AuthPolicy#getAuthScheme(String)} - */ - public static AuthScheme selectAuthScheme(final Header[] challenges) - throws MalformedChallengeException { - LOG.trace("enter HttpAuthenticator.selectAuthScheme(Header[])"); - if (challenges == null) { - throw new IllegalArgumentException("Array of challenges may not be null"); - } - if (challenges.length == 0) { - throw new IllegalArgumentException("Array of challenges may not be empty"); - } - String challenge = null; - Map challengemap = new HashMap(challenges.length); - for (int i = 0; i < challenges.length; i++) { - challenge = challenges[i].getValue(); - String s = AuthChallengeParser.extractScheme(challenge); - challengemap.put(s, challenge); - } - challenge = (String) challengemap.get("ntlm"); - if (challenge != null) { - return new NTLMScheme(challenge); - } - challenge = (String) challengemap.get("digest"); - if (challenge != null) { - return new DigestScheme(challenge); - } - challenge = (String) challengemap.get("basic"); - if (challenge != null) { - return new BasicScheme(challenge); - } - throw new UnsupportedOperationException( - "Authentication scheme(s) not supported: " + challengemap.toString()); - } - - private static boolean doAuthenticateDefault( - HttpMethod method, - HttpConnection conn, - HttpState state, - boolean proxy) - throws AuthenticationException { - if (method == null) { - throw new IllegalArgumentException("HTTP method may not be null"); - } - if (state == null) { - throw new IllegalArgumentException("HTTP state may not be null"); - } - String host = null; - if (conn != null) { - host = proxy ? conn.getProxyHost() : conn.getHost(); - } - Credentials credentials = proxy - ? state.getProxyCredentials(null, host) : state.getCredentials(null, host); - if (credentials == null) { - return false; - } - if (!(credentials instanceof UsernamePasswordCredentials)) { - throw new InvalidCredentialsException( - "Credentials cannot be used for basic authentication: " - + credentials.toString()); - } - String auth = BasicScheme.authenticate( - (UsernamePasswordCredentials) credentials, - method.getParams().getCredentialCharset()); - if (auth != null) { - String s = proxy ? PROXY_AUTH_RESP : WWW_AUTH_RESP; - Header header = new Header(s, auth, true); - method.addRequestHeader(header); - return true; - } else { - return false; - } - } - - - /** - * Attempt to provide default authentication credentials - * to the given method in the given context using basic - * authentication scheme. - * - * @param method the HttpMethod which requires authentication - * @param conn the connection to a specific host. This parameter - * may be null if default credentials (not specific - * to any particular host) are to be used - * @param state the HttpState object providing Credentials - * - * @return true if the Authenticate response header - * was added - * - * @throws InvalidCredentialsException if authentication credentials - * are not valid or not applicable for basic scheme - * @throws AuthenticationException when a parsing or other error occurs - * - * @see HttpState#setCredentials(String,String,Credentials) - * - * @deprecated use AuthScheme - */ - public static boolean authenticateDefault( - HttpMethod method, - HttpConnection conn, - HttpState state) - throws AuthenticationException { - LOG.trace( - "enter HttpAuthenticator.authenticateDefault(HttpMethod, HttpConnection, HttpState)"); - return doAuthenticateDefault(method, conn, state, false); - } - - - /** - * Attempt to provide default proxy authentication credentials - * to the given method in the given context using basic - * authentication scheme. - * - * @param method the HttpMethod which requires authentication - * @param conn the connection to a specific host. This parameter - * may be null if default credentials (not specific - * to any particular host) are to be used - * @param state the HttpState object providing Credentials - * - * @return true if the Proxy-Authenticate response header - * was added - * - * @throws InvalidCredentialsException if authentication credentials - * are not valid or not applicable for basic scheme - * @throws AuthenticationException when a parsing or other error occurs - - * @see HttpState#setCredentials(String,String,Credentials) - * - * @deprecated use AuthScheme - */ - public static boolean authenticateProxyDefault( - HttpMethod method, - HttpConnection conn, - HttpState state) - throws AuthenticationException { - LOG.trace("enter HttpAuthenticator.authenticateProxyDefault(HttpMethod, HttpState)"); - return doAuthenticateDefault(method, conn, state, true); - } - - - private static boolean doAuthenticate( - AuthScheme authscheme, - HttpMethod method, - HttpConnection conn, - HttpState state, - boolean proxy) - throws AuthenticationException { - if (authscheme == null) { - throw new IllegalArgumentException("Authentication scheme may not be null"); - } - if (method == null) { - throw new IllegalArgumentException("HTTP method may not be null"); - } - if (state == null) { - throw new IllegalArgumentException("HTTP state may not be null"); - } - String host = null; - if (conn != null) { - if (proxy) { - host = conn.getProxyHost(); - } else { - host = method.getParams().getVirtualHost(); - if (host == null) { - host = conn.getHost(); - } - } - } - String realm = authscheme.getRealm(); - if (LOG.isDebugEnabled()) { - StringBuffer buffer = new StringBuffer(); - buffer.append("Using credentials for "); - if (realm == null) { - buffer.append("default"); - } else { - buffer.append('\''); - buffer.append(realm); - buffer.append('\''); - } - buffer.append(" authentication realm at "); - buffer.append(host); - LOG.debug(buffer.toString()); - } - Credentials credentials = proxy - ? state.getProxyCredentials(realm, host) - : state.getCredentials(realm, host); - if (credentials == null) { - StringBuffer buffer = new StringBuffer(); - buffer.append("No credentials available for the "); - if (realm == null) { - buffer.append("default"); - } else { - buffer.append('\''); - buffer.append(realm); - buffer.append('\''); - } - buffer.append(" authentication realm at "); - buffer.append(host); - throw new CredentialsNotAvailableException(buffer.toString()); - } - String auth = authscheme.authenticate(credentials, method); - if (auth != null) { - String s = proxy ? PROXY_AUTH_RESP : WWW_AUTH_RESP; - Header header = new Header(s, auth, true); - method.addRequestHeader(header); - return true; - } else { - return false; - } - } - - /** - * Attempt to provide requisite authentication credentials to the - * given method in the given context using the given - * authentication scheme. - * - * @param authscheme The authentication scheme to be used - * @param method The HttpMethod which requires authentication - * @param conn the connection to a specific host. This parameter - * may be null if default credentials (not specific - * to any particular host) are to be used - * @param state The HttpState object providing Credentials - * - * @return true if the Authenticate response header was added - * - * @throws CredentialsNotAvailableException if authentication credentials - * required to respond to the authentication challenge are not available - * @throws AuthenticationException when a parsing or other error occurs - - * @see HttpState#setCredentials(String,String,Credentials) - * - * @deprecated use AuthScheme - */ - public static boolean authenticate( - AuthScheme authscheme, - HttpMethod method, - HttpConnection conn, - HttpState state) - throws AuthenticationException { - LOG.trace( - "enter HttpAuthenticator.authenticate(AuthScheme, HttpMethod, HttpConnection, " - + "HttpState)"); - return doAuthenticate(authscheme, method, conn, state, false); - } - - - /** - * Attempt to provide requisite proxy authentication credentials - * to the given method in the given context using - * the given authentication scheme. - * - * @param authscheme The authentication scheme to be used - * @param method the HttpMethod which requires authentication - * @param conn the connection to a specific host. This parameter - * may be null if default credentials (not specific - * to any particular host) are to be used - * @param state the HttpState object providing Credentials - * - * @return true if the Proxy-Authenticate response header - * was added - * - * @throws CredentialsNotAvailableException if authentication credentials - * required to respond to the authentication challenge are not available - * @throws AuthenticationException when a parsing or other error occurs - - * @see HttpState#setCredentials(String,String,Credentials) - * - * @deprecated use AuthScheme - */ - public static boolean authenticateProxy( - AuthScheme authscheme, - HttpMethod method, - HttpConnection conn, - HttpState state - ) throws AuthenticationException { - LOG.trace("enter HttpAuthenticator.authenticateProxy(AuthScheme, HttpMethod, HttpState)"); - return doAuthenticate(authscheme, method, conn, state, true); - } -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/NTLM.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/NTLM.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/NTLM.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/NTLM.java Tue Jan 3 03:17:18 2006 @@ -86,7 +86,7 @@ * @param host The host. * @param domain the NT domain to authenticate in. * @return The response. - * @throws HttpException If the messages cannot be retrieved. + * @throws AuthenticationException */ public final String getResponseFor(String message, String username, String password, String host, String domain) @@ -157,7 +157,7 @@ * @param key The key. * @param bytes The data * @return byte[] The encrypted data - * @throws HttpException If {@link Cipher.doFinal(byte[])} fails + * @throws HttpException If {@link Cipher#doFinal(byte[])} fails */ private byte[] encrypt(byte[] key, byte[] bytes) throws AuthenticationException { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/NTLMScheme.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/NTLMScheme.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/NTLMScheme.java Wed Mar 9 22:40:30 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/NTLMScheme.java Tue Jan 3 17:41:13 2006 @@ -32,8 +32,8 @@ import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.NTCredentials; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** An implementation of the Microsoft proprietary NTLM authentication scheme. For a detailed * explanation of the NTLM scheme please see @@ -51,7 +51,7 @@ public class NTLMScheme implements AuthScheme { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(NTLMScheme.class); + private static final Logger LOG = LoggerFactory.getLogger(NTLMScheme.class); /** NTLM challenge string. */ private String ntlmchallenge = null; @@ -151,28 +151,6 @@ } /** - * Returns a String identifying the authentication challenge. This is - * used, in combination with the host and port to determine if - * authorization has already been attempted or not. Schemes which - * require multiple requests to complete the authentication should - * return a different value for each stage in the request. - * - *

Additionally, the ID should take into account any changes to the - * authentication challenge and return a different value when appropriate. - * For example when the realm changes in basic authentication it should be - * considered a different authentication attempt and a different value should - * be returned.

- * - * @return String a String identifying the authentication challenge. The - * returned value may be null. - * - * @deprecated no longer used - */ - public String getID() { - return ntlmchallenge; - } - - /** * Returns the authentication parameter with the given name, if available. * *

There are no valid parameters for NTLM authentication so this method always returns @@ -201,104 +179,6 @@ } /** - * Create a NTLM authorization string for the given - * challenge and NT credentials. - * - * @param challenge The challenge. - * @param credentials {@link NTCredentials} - * - * @return a ntlm authorization string - * @throws AuthenticationException is thrown if authentication fails - * - * @deprecated Use non-static {@link #authenticate(Credentials, HttpMethod)} - */ - public static String authenticate( - final NTCredentials credentials, final String challenge) - throws AuthenticationException { - - LOG.trace("enter NTLMScheme.authenticate(NTCredentials, String)"); - - if (credentials == null) { - throw new IllegalArgumentException("Credentials may not be null"); - } - - NTLM ntlm = new NTLM(); - String s = ntlm.getResponseFor(challenge, - credentials.getUserName(), credentials.getPassword(), - credentials.getHost(), credentials.getDomain()); - return "NTLM " + s; - } - - /** - * Create a NTLM authorization string for the given - * challenge and NT credentials. - * - * @param challenge The challenge. - * @param credentials {@link NTCredentials} - * @param charset The charset to use for encoding the credentials - * - * @return a ntlm authorization string - * @throws AuthenticationException is thrown if authentication fails - * - * @deprecated Use non-static {@link #authenticate(Credentials, HttpMethod)} - * - * @since 3.0 - */ - public static String authenticate( - final NTCredentials credentials, - final String challenge, - String charset - ) throws AuthenticationException { - - LOG.trace("enter NTLMScheme.authenticate(NTCredentials, String)"); - - if (credentials == null) { - throw new IllegalArgumentException("Credentials may not be null"); - } - - NTLM ntlm = new NTLM(); - ntlm.setCredentialCharset(charset); - String s = ntlm.getResponseFor( - challenge, - credentials.getUserName(), - credentials.getPassword(), - credentials.getHost(), - credentials.getDomain()); - return "NTLM " + s; - } - - /** - * Produces NTLM authorization string for the given set of - * {@link Credentials}. - * - * @param credentials The set of credentials to be used for athentication - * @param method Method name is ignored by the NTLM authentication scheme - * @param uri URI is ignored by the NTLM authentication scheme - * @throws InvalidCredentialsException if authentication credentials - * are not valid or not applicable for this authentication scheme - * @throws AuthenticationException if authorization string cannot - * be generated due to an authentication failure - * - * @return an NTLM authorization string - * - * @deprecated Use {@link #authenticate(Credentials, HttpMethod)} - */ - public String authenticate(Credentials credentials, String method, String uri) - throws AuthenticationException { - LOG.trace("enter NTLMScheme.authenticate(Credentials, String, String)"); - - NTCredentials ntcredentials = null; - try { - ntcredentials = (NTCredentials) credentials; - } catch (ClassCastException e) { - throw new InvalidCredentialsException( - "Credentials cannot be used for NTLM authentication: " - + credentials.getClass().getName()); - } - return NTLMScheme.authenticate(ntcredentials, this.ntlmchallenge); - } - - /** * Produces NTLM authorization string for the given set of * {@link Credentials}. * @@ -318,7 +198,7 @@ Credentials credentials, HttpMethod method ) throws AuthenticationException { - LOG.trace("enter NTLMScheme.authenticate(Credentials, HttpMethod)"); + LOG.debug("enter NTLMScheme.authenticate(Credentials, HttpMethod)"); if (this.state == UNINITIATED) { throw new IllegalStateException("NTLM authentication process has not been initiated"); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/RFC2617Scheme.java commons-httpclient/src/java/org/apache/commons/httpclient/auth/RFC2617Scheme.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/auth/RFC2617Scheme.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/auth/RFC2617Scheme.java Tue Jan 3 17:38:20 2006 @@ -45,7 +45,7 @@ /** * Authentication parameter map. */ - private Map params = null; + private Map params = null; /** * Default constructor for RFC2617 compliant authetication schemes. @@ -57,22 +57,6 @@ } /** - * Default constructor for RFC2617 compliant authetication schemes. - * - * @param challenge authentication challenge - * - * @throws MalformedChallengeException is thrown if the authentication challenge - * is malformed - * - * @deprecated Use parameterless constructor and {@link AuthScheme#processChallenge(String)} - * method - */ - public RFC2617Scheme(final String challenge) throws MalformedChallengeException { - super(); - processChallenge(challenge); - } - - /** * Processes the given challenge token. Some authentication schemes * may involve multiple challenge-response exchanges. Such schemes must be able * to maintain the state information when dealing with sequential challenges @@ -98,7 +82,7 @@ * * @return the map of authentication parameters */ - protected Map getParameters() { + protected Map getParameters() { return this.params; } @@ -116,7 +100,7 @@ if (this.params == null) { return null; } - return (String) this.params.get(name.toLowerCase()); + return this.params.get(name.toLowerCase()); } /** @@ -127,28 +111,4 @@ public String getRealm() { return getParameter("realm"); } - - /** - * Returns a String identifying the authentication challenge. This is - * used, in combination with the host and port to determine if - * authorization has already been attempted or not. Schemes which - * require multiple requests to complete the authentication should - * return a different value for each stage in the request. - * - *

Additionally, the ID should take into account any changes to the - * authentication challenge and return a different value when appropriate. - * For example when the realm changes in basic authentication it should be - * considered a different authentication attempt and a different value should - * be returned.

- * - *

This method simply returns the realm for the challenge.

- * - * @return String a String identifying the authentication challenge. The - * returned value may be null. - * - * @deprecated no longer used - */ - public String getID() { - return getRealm(); - } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java commons-httpclient/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java Wed Dec 14 19:08:35 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java Tue Jan 3 17:48:51 2006 @@ -32,9 +32,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Cookie management policy class. The cookie policy provides corresponding @@ -57,7 +56,7 @@ */ public abstract class CookiePolicy { - private static Map SPECS = Collections.synchronizedMap(new HashMap()); + private static Map SPECS = Collections.synchronizedMap(new HashMap()); /** * The policy that provides high degree of compatibilty @@ -103,37 +102,9 @@ CookiePolicy.registerCookieSpec(IGNORE_COOKIES, IgnoreCookiesSpec.class); } - /** - * The COMPATIBILITY policy provides high compatibilty - * with common cookie management of popular HTTP agents. - * - * @deprecated Use {@link #BROWSER_COMPATIBILITY} - */ - public static final int COMPATIBILITY = 0; - - /** - * The NETSCAPE_DRAFT Netscape draft compliant policy. - * - * @deprecated Use {@link #NETSCAPE} - */ - public static final int NETSCAPE_DRAFT = 1; - - /** - * The RFC2109 RFC 2109 compliant policy. - * - * @deprecated Use {@link #RFC_2109} - */ - public static final int RFC2109 = 2; - - /** - * The default cookie policy. - * - * @deprecated Use {@link #DEFAULT} - */ - private static int defaultPolicy = RFC2109; - /** Log object. */ - protected static final Log LOG = LogFactory.getLog(CookiePolicy.class); + protected static final Logger LOG = LoggerFactory + .getLogger(CookiePolicy.class); /** * Registers a new {@link CookieSpec cookie specification} with the given identifier. @@ -189,7 +160,7 @@ if (id == null) { throw new IllegalArgumentException("Id may not be null"); } - Class clazz = (Class)SPECS.get(id.toLowerCase()); + Class clazz = SPECS.get(id.toLowerCase()); if (clazz != null) { try { @@ -200,53 +171,10 @@ " cookie spec implemented by " + clazz.getName() + " could not be initialized"); } - } else { - throw new IllegalStateException("Unsupported cookie spec " + id); - } - } - - /** - * @return default cookie policy - * - * @deprecated Use {@link #getDefaultSpec()} - * - * @see #getDefaultSpec() - */ - public static int getDefaultPolicy() { - return defaultPolicy; - } - - - /** - * @param policy new default cookie policy - * - * @deprecated Use {@link CookiePolicy#registerCookieSpec(String, Class)} - * @see #DEFAULT - */ - public static void setDefaultPolicy(int policy) { - defaultPolicy = policy; - } - - /** - * @param policy cookie policy to get the CookieSpec for - * @return cookie specification interface for the given policy - * - * @deprecated Use {@link CookiePolicy#getCookieSpec(String)} - */ - public static CookieSpec getSpecByPolicy(int policy) { - switch(policy) { - case COMPATIBILITY: - return new CookieSpecBase(); - case NETSCAPE_DRAFT: - return new NetscapeDraftSpec(); - case RFC2109: - return new RFC2109Spec(); - default: - return getDefaultSpec(); } + throw new IllegalStateException("Unsupported cookie spec " + id); } - /** * Returns {@link CookieSpec cookie specification} registered as {@link #DEFAULT}. * If no default {@link CookieSpec cookie specification} has been registered, @@ -264,42 +192,4 @@ return new RFC2109Spec(); } } - - - /** - * Gets the CookieSpec for a particular cookie version. - * - *

Supported versions: - *

    - *
  • version 0 corresponds to the Netscape draft - *
  • version 1 corresponds to the RFC 2109 - *
  • Any other cookie value coresponds to the default spec - *
      - * - * @param ver the cookie version to get the spec for - * @return cookie specification interface intended for processing - * cookies with the given version - * - * @deprecated Use {@link CookiePolicy#getCookieSpec(String)} - */ - public static CookieSpec getSpecByVersion(int ver) { - switch(ver) { - case 0: - return new NetscapeDraftSpec(); - case 1: - return new RFC2109Spec(); - default: - return getDefaultSpec(); - } - } - - /** - * @return cookie specification interface that provides high compatibilty - * with common cookie management of popular HTTP agents - * - * @deprecated Use {@link CookiePolicy#getCookieSpec(String)} - */ - public static CookieSpec getCompatibilitySpec() { - return getSpecByPolicy(COMPATIBILITY); - } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java commons-httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java Mon Jun 13 21:04:56 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java Tue Jan 3 17:30:39 2006 @@ -33,15 +33,14 @@ import java.util.Date; import java.util.LinkedList; import java.util.List; - import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HeaderElement; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.util.DateParseException; import org.apache.commons.httpclient.util.DateUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -63,7 +62,8 @@ public class CookieSpecBase implements CookieSpec { /** Log object */ - protected static final Log LOG = LogFactory.getLog(CookieSpec.class); + protected static final Logger LOG = LoggerFactory + .getLogger(CookieSpecBase.class); /** Valid date patterns */ private Collection datepatterns = null; @@ -109,7 +109,7 @@ boolean secure, final String header) throws MalformedCookieException { - LOG.trace("enter CookieSpecBase.parse(" + LOG.debug("enter CookieSpecBase.parse(" + "String, port, path, boolean, Header)"); if (host == null) { @@ -239,7 +239,7 @@ String host, int port, String path, boolean secure, final Header header) throws MalformedCookieException { - LOG.trace("enter CookieSpecBase.parse(" + LOG.debug("enter CookieSpecBase.parse(" + "String, port, path, boolean, String)"); if (header == null) { throw new IllegalArgumentException("Header may not be null."); @@ -339,11 +339,16 @@ } } - + /** + * {@inheritDoc} + */ public Collection getValidDateFormats() { return this.datepatterns; } + /** + * {@inheritDoc} + */ public void setValidDateFormats(final Collection datepatterns) { this.datepatterns = datepatterns; } @@ -365,7 +370,7 @@ boolean secure, final Cookie cookie) throws MalformedCookieException { - LOG.trace("enter CookieSpecBase.validate(" + LOG.debug("enter CookieSpecBase.validate(" + "String, port, path, boolean, Cookie)"); if (host == null) { throw new IllegalArgumentException( @@ -449,7 +454,7 @@ public boolean match(String host, int port, String path, boolean secure, final Cookie cookie) { - LOG.trace("enter CookieSpecBase.match(" + LOG.debug("enter CookieSpecBase.match(" + "String, int, String, boolean, Cookie"); if (host == null) { @@ -545,19 +550,19 @@ public Cookie[] match(String host, int port, String path, boolean secure, final Cookie cookies[]) { - LOG.trace("enter CookieSpecBase.match(" + LOG.debug("enter CookieSpecBase.match(" + "String, int, String, boolean, Cookie[])"); if (cookies == null) { return null; } - List matching = new LinkedList(); + List matching = new LinkedList(); for (int i = 0; i < cookies.length; i++) { if (match(host, port, path, secure, cookies[i])) { addInPathOrder(matching, cookies[i]); } } - return (Cookie[]) matching.toArray(new Cookie[matching.size()]); + return matching.toArray(new Cookie[matching.size()]); } @@ -570,11 +575,11 @@ * @param list - the list to add the cookie to * @param addCookie - the Cookie to add to list */ - private static void addInPathOrder(List list, Cookie addCookie) { + private static void addInPathOrder(List list, Cookie addCookie) { int i = 0; for (i = 0; i < list.size(); i++) { - Cookie c = (Cookie) list.get(i); + Cookie c = list.get(i); if (addCookie.compare(addCookie, c) > 0) { break; } @@ -588,7 +593,7 @@ * @return a string suitable for sending in a "Cookie" header. */ public String formatCookie(Cookie cookie) { - LOG.trace("enter CookieSpecBase.formatCookie(Cookie)"); + LOG.debug("enter CookieSpecBase.formatCookie(Cookie)"); if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } @@ -612,7 +617,7 @@ public String formatCookies(Cookie[] cookies) throws IllegalArgumentException { - LOG.trace("enter CookieSpecBase.formatCookies(Cookie[])"); + LOG.debug("enter CookieSpecBase.formatCookies(Cookie[])"); if (cookies == null) { throw new IllegalArgumentException("Cookie array may not be null"); } @@ -639,7 +644,7 @@ * @return a "Cookie" {@link Header}. */ public Header formatCookieHeader(Cookie[] cookies) { - LOG.trace("enter CookieSpecBase.formatCookieHeader(Cookie[])"); + LOG.debug("enter CookieSpecBase.formatCookieHeader(Cookie[])"); return new Header("Cookie", formatCookies(cookies)); } @@ -651,7 +656,7 @@ * @return a Cookie header. */ public Header formatCookieHeader(Cookie cookie) { - LOG.trace("enter CookieSpecBase.formatCookieHeader(Cookie)"); + LOG.debug("enter CookieSpecBase.formatCookieHeader(Cookie)"); return new Header("Cookie", formatCookie(cookie)); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java commons-httpclient/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java Mon May 30 14:22:06 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java Tue Jan 3 17:29:38 2006 @@ -52,9 +52,14 @@ /** * Returns an empty {@link Cookie cookie} array. All parameters are ignored. + * @param host + * @param port + * @param path + * @param secure + * @param header + * @return an empty {@link Cookie cookie} array */ - public Cookie[] parse(String host, int port, String path, boolean secure, String header) - throws MalformedCookieException { + public Cookie[] parse(String host, int port, String path, boolean secure, String header) { return new Cookie[0]; } @@ -67,11 +72,14 @@ /** * Does nothing. + * @param datepatterns ignored */ public void setValidDateFormats(Collection datepatterns) { + // do nothing } /** + * @param cookie ignored * @return null */ public String formatCookie(Cookie cookie) { @@ -79,27 +87,38 @@ } /** + * @param cookie ignored * @return null + * @throws IllegalArgumentException */ public Header formatCookieHeader(Cookie cookie) throws IllegalArgumentException { return null; } /** + * @param cookies ignored * @return null + * @throws IllegalArgumentException */ public Header formatCookieHeader(Cookie[] cookies) throws IllegalArgumentException { return null; } /** + * @param cookies ignored * @return null + * @throws IllegalArgumentException */ public String formatCookies(Cookie[] cookies) throws IllegalArgumentException { return null; } /** + * @param host ignored + * @param port ignored + * @param path ignored + * @param secure ignored + * @param cookie ignored * @return false */ public boolean match(String host, int port, String path, boolean secure, Cookie cookie) { @@ -108,6 +127,12 @@ /** * Returns an empty {@link Cookie cookie} array. All parameters are ignored. + * @param host ignored + * @param port ignored + * @param path ignored + * @param secure ignored + * @param cookies ignored + * @return an empty array */ public Cookie[] match(String host, int port, String path, boolean secure, Cookie[] cookies) { return new Cookie[0]; @@ -115,27 +140,47 @@ /** * Returns an empty {@link Cookie cookie} array. All parameters are ignored. + * @param host ignored + * @param port ignored + * @param path ignored + * @param secure ignored + * @param header ignored + * @return an empty array + * @throws IllegalArgumentException */ public Cookie[] parse(String host, int port, String path, boolean secure, Header header) - throws MalformedCookieException, IllegalArgumentException { + throws IllegalArgumentException { return new Cookie[0]; } /** * Does nothing. + * @param attribute ignored + * @param cookie ignored + * @throws IllegalArgumentException */ public void parseAttribute(NameValuePair attribute, Cookie cookie) - throws MalformedCookieException, IllegalArgumentException { + throws IllegalArgumentException { + // do nothing } /** * Does nothing. + * @param host ignored + * @param port ignored + * @param path ignored + * @param secure ignored + * @param cookie ignored + * @throws IllegalArgumentException */ public void validate(String host, int port, String path, boolean secure, Cookie cookie) - throws MalformedCookieException, IllegalArgumentException { + throws IllegalArgumentException { + // do nothing } /** + * @param host ignored + * @param domain ignored * @return false */ public boolean domainMatch(final String host, final String domain) { @@ -143,6 +188,8 @@ } /** + * @param path ignored + * @param topmostPath ignored * @return false */ public boolean pathMatch(final String path, final String topmostPath) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/NetscapeDraftSpec.java commons-httpclient/src/java/org/apache/commons/httpclient/cookie/NetscapeDraftSpec.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/NetscapeDraftSpec.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/cookie/NetscapeDraftSpec.java Tue Jan 3 03:33:23 2006 @@ -83,7 +83,7 @@ * character may be present in unquoted cookie value or unquoted * parameter value.

      * - * @link http://wp.netscape.com/newsref/std/cookie_spec.html + *
      http://wp.netscape.com/newsref/std/cookie_spec.html * * @param host the host from which the Set-Cookie value was * received @@ -99,11 +99,12 @@ * * @since 3.0 */ + @Override public Cookie[] parse(String host, int port, String path, boolean secure, final String header) throws MalformedCookieException { - LOG.trace("enter NetscapeDraftSpec.parse(String, port, path, boolean, Header)"); + LOG.debug("enter NetscapeDraftSpec.parse(String, port, path, boolean, Header)"); if (host == null) { throw new IllegalArgumentException("Host of origin may not be null"); @@ -163,6 +164,7 @@ * @param cookie {@link Cookie} to be updated * @throws MalformedCookieException if an exception occurs during parsing */ + @Override public void parseAttribute( final NameValuePair attribute, final Cookie cookie) throws MalformedCookieException { @@ -202,6 +204,7 @@ * @param domain The cookie domain attribute. * @return true if the specified host matches the given domain. */ + @Override public boolean domainMatch(final String host, final String domain) { return host.endsWith(domain); } @@ -218,11 +221,12 @@ * @throws MalformedCookieException if an exception occurs during * validation */ + @Override public void validate(String host, int port, String path, boolean secure, final Cookie cookie) throws MalformedCookieException { - LOG.trace("enterNetscapeDraftCookieProcessor " + LOG.debug("enterNetscapeDraftCookieProcessor " + "RCF2109CookieProcessor.validate(Cookie)"); // Perform generic validation super.validate(host, port, path, secure, cookie); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java commons-httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java Wed Sep 21 11:30:56 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java Tue Jan 3 03:34:16 2006 @@ -70,6 +70,7 @@ * @param cookie {@link Cookie} to be updated * @throws MalformedCookieException if an exception occurs during parsing */ + @Override public void parseAttribute( final NameValuePair attribute, final Cookie cookie) throws MalformedCookieException { @@ -124,10 +125,11 @@ * @throws MalformedCookieException if an exception occurs during * validation */ + @Override public void validate(String host, int port, String path, boolean secure, final Cookie cookie) throws MalformedCookieException { - LOG.trace("enter RFC2109Spec.validate(String, int, String, " + LOG.debug("enter RFC2109Spec.validate(String, int, String, " + "boolean, Cookie)"); // Perform generic validation @@ -182,6 +184,7 @@ * * @since 3.0 */ + @Override public boolean domainMatch(String host, String domain) { boolean match = host.equals(domain) || (domain.startsWith(".") && host.endsWith(domain)); @@ -239,8 +242,9 @@ * @param cookie a {@link Cookie} to be formatted as string * @return a string suitable for sending in a "Cookie" header. */ + @Override public String formatCookie(Cookie cookie) { - LOG.trace("enter RFC2109Spec.formatCookie(Cookie)"); + LOG.debug("enter RFC2109Spec.formatCookie(Cookie)"); if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } @@ -261,8 +265,9 @@ * @param cookies an array of {@link Cookie}s to be formatted * @return a string suitable for sending in a Cookie header. */ + @Override public String formatCookies(Cookie[] cookies) { - LOG.trace("enter RFC2109Spec.formatCookieHeader(Cookie[])"); + LOG.debug("enter RFC2109Spec.formatCookieHeader(Cookie[])"); int version = Integer.MAX_VALUE; // Pick the lowerest common denominator for (int i = 0; i < cookies.length; i++) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/ByteArrayRequestEntity.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/ByteArrayRequestEntity.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/ByteArrayRequestEntity.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/ByteArrayRequestEntity.java Tue Jan 3 03:44:36 2006 @@ -75,15 +75,15 @@ return true; } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.methods.RequestEntity#getContentType() + /** + * {@inheritDoc} */ public String getContentType() { return contentType; } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.RequestEntity#writeRequest(java.io.OutputStream) + /** + * {@inheritDoc} */ public void writeRequest(OutputStream out) throws IOException { out.write(content); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/DeleteMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/DeleteMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/DeleteMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/DeleteMethod.java Tue Jan 3 18:14:31 2006 @@ -64,6 +64,7 @@ * @since 1.0 */ public DeleteMethod() { + // do nothing } @@ -87,6 +88,7 @@ * * @since 2.0 */ + @Override public String getName() { return "DELETE"; } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java Tue Apr 19 22:25:06 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java Tue Jan 3 20:50:06 2006 @@ -33,7 +33,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; - import org.apache.commons.httpclient.ChunkedOutputStream; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpConnection; @@ -41,8 +40,8 @@ import org.apache.commons.httpclient.HttpState; import org.apache.commons.httpclient.HttpVersion; import org.apache.commons.httpclient.ProtocolException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This abstract class serves as a foundation for all HTTP methods @@ -58,22 +57,9 @@ // ----------------------------------------- Static variables/initializers - /** - * The content length will be calculated automatically. This implies - * buffering of the content. - * @deprecated Use {@link InputStreamRequestEntity#CONTENT_LENGTH_AUTO}. - */ - public static final long CONTENT_LENGTH_AUTO = InputStreamRequestEntity.CONTENT_LENGTH_AUTO; - - /** - * The request will use chunked transfer encoding. Content length is not - * calculated and the content is not buffered.
      - * @deprecated Use {@link #setContentChunked(boolean)}. - */ - public static final long CONTENT_LENGTH_CHUNKED = -1; - /** LOG object for this class. */ - private static final Log LOG = LogFactory.getLog(EntityEnclosingMethod.class); + private static final Logger LOG = LoggerFactory + .getLogger(EntityEnclosingMethod.class); /** The unbuffered request body, if any. */ private InputStream requestStream = null; @@ -86,13 +72,6 @@ /** Counts how often the request was sent to the server. */ private int repeatCount = 0; - /** The content length of the requestBodyStream or one of - * CONTENT_LENGTH_AUTO and CONTENT_LENGTH_CHUNKED. - * - * @deprecated - */ - private long requestContentLength = InputStreamRequestEntity.CONTENT_LENGTH_AUTO; - private boolean chunked = false; // ----------------------------------------------------------- Constructors @@ -130,8 +109,9 @@ * * @since 2.0beta1 */ + @Override protected boolean hasRequestContent() { - LOG.trace("enter EntityEnclosingMethod.hasRequestContent()"); + LOG.debug("enter EntityEnclosingMethod.hasRequestContent()"); return (this.requestEntity != null) || (this.requestStream != null) || (this.requestString != null); @@ -146,7 +126,7 @@ * @since 2.0beta1 */ protected void clearRequestBody() { - LOG.trace("enter EntityEnclosingMethod.clearRequestBody()"); + LOG.debug("enter EntityEnclosingMethod.clearRequestBody()"); this.requestStream = null; this.requestString = null; this.requestEntity = null; @@ -164,10 +144,13 @@ * @since 2.0beta1 */ protected byte[] generateRequestBody() { - LOG.trace("enter EntityEnclosingMethod.renerateRequestBody()"); + LOG.debug("enter EntityEnclosingMethod.renerateRequestBody()"); return null; } + /** + * @return a new request entity + */ protected RequestEntity generateRequestEntity() { byte[] requestBody = generateRequestBody(); @@ -176,9 +159,7 @@ // this is just for backwards compatability this.requestEntity = new ByteArrayRequestEntity(requestBody); } else if (this.requestStream != null) { - this.requestEntity = new InputStreamRequestEntity( - requestStream, - requestContentLength); + this.requestEntity = new InputStreamRequestEntity(requestStream); this.requestStream = null; } else if (this.requestString != null) { String charset = getRequestCharSet(); @@ -205,6 +186,7 @@ * * @since 2.0 */ + @Override public boolean getFollowRedirects() { return false; } @@ -216,6 +198,7 @@ * * @param followRedirects must always be false */ + @Override public void setFollowRedirects(boolean followRedirects) { if (followRedirects == true) { throw new IllegalArgumentException("Entity enclosing requests cannot be redirected without user intervention"); @@ -224,40 +207,15 @@ } /** - * Sets length information about the request body. - * - *

      - * Note: If you specify a content length the request is unbuffered. This - * prevents redirection and automatic retry if a request fails the first - * time. This means that the HttpClient can not perform authorization - * automatically but will throw an Exception. You will have to set the - * necessary 'Authorization' or 'Proxy-Authorization' headers manually. - *

      - * - * @param length size in bytes or any of CONTENT_LENGTH_AUTO, - * CONTENT_LENGTH_CHUNKED. If number of bytes or CONTENT_LENGTH_CHUNKED - * is specified the content will not be buffered internally and the - * Content-Length header of the request will be used. In this case - * the user is responsible to supply the correct content length. - * If CONTENT_LENGTH_AUTO is specified the request will be buffered - * before it is sent over the network. - * - * @deprecated Use {@link #setContentChunked(boolean)} or - * {@link #setRequestEntity(RequestEntity)} - */ - public void setRequestContentLength(int length) { - LOG.trace("enter EntityEnclosingMethod.setRequestContentLength(int)"); - this.requestContentLength = length; - } - - /** * Returns the request's charset. The charset is parsed from the request entity's * content type, unless the content type header has been set manually. + * @return the request's charset * * @see RequestEntity#getContentType() * * @since 3.0 */ + @Override public String getRequestCharSet() { if (getRequestHeader("Content-Type") == null) { // check the content type from request entity @@ -266,39 +224,10 @@ if (this.requestEntity != null) { return getContentCharSet( new Header("Content-Type", requestEntity.getContentType())); - } else { - return super.getRequestCharSet(); } - } else { return super.getRequestCharSet(); } - } - - /** - * Sets length information about the request body. - * - *

      - * Note: If you specify a content length the request is unbuffered. This - * prevents redirection and automatic retry if a request fails the first - * time. This means that the HttpClient can not perform authorization - * automatically but will throw an Exception. You will have to set the - * necessary 'Authorization' or 'Proxy-Authorization' headers manually. - *

      - * - * @param length size in bytes or any of CONTENT_LENGTH_AUTO, - * CONTENT_LENGTH_CHUNKED. If number of bytes or CONTENT_LENGTH_CHUNKED - * is specified the content will not be buffered internally and the - * Content-Length header of the request will be used. In this case - * the user is responsible to supply the correct content length. - * If CONTENT_LENGTH_AUTO is specified the request will be buffered - * before it is sent over the network. - * - * @deprecated Use {@link #setContentChunked(boolean)} or - * {@link #setRequestEntity(RequestEntity)} - */ - public void setRequestContentLength(long length) { - LOG.trace("enter EntityEnclosingMethod.setRequestContentLength(int)"); - this.requestContentLength = length; + return super.getRequestCharSet(); } /** @@ -318,7 +247,7 @@ * @return number of bytes in the request body */ protected long getRequestContentLength() { - LOG.trace("enter EntityEnclosingMethod.getRequestContentLength()"); + LOG.debug("enter EntityEnclosingMethod.getRequestContentLength()"); if (!hasRequestContent()) { return 0; @@ -351,19 +280,14 @@ * @param state the {@link HttpState state} information associated with this method * @param conn the {@link HttpConnection connection} used to execute * this HTTP method - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. - * - * @see #writeRequestHeaders + * @throws IOException + * @throws HttpException * * @since 3.0 */ - protected void addRequestHeaders(HttpState state, HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter EntityEnclosingMethod.addRequestHeaders(HttpState, " + @Override + protected void addRequestHeaders(HttpState state, HttpConnection conn) throws HttpException, IOException { + LOG.debug("enter EntityEnclosingMethod.addRequestHeaders(HttpState, " + "HttpConnection)"); super.addRequestHeaders(state, conn); @@ -394,9 +318,10 @@ protected void addContentLengthRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException { - LOG.trace("enter EntityEnclosingMethod.addContentLengthRequestHeader(" + if (LOG.isDebugEnabled()) { + LOG.debug("enter EntityEnclosingMethod.addContentLengthRequestHeader(" + "HttpState, HttpConnection)"); - + } if ((getRequestHeader("content-length") == null) && (getRequestHeader("Transfer-Encoding") == null)) { long len = getRequestContentLength(); @@ -414,39 +339,6 @@ } /** - * Sets the request body to be the specified inputstream. - * - * @param body Request body content as {@link java.io.InputStream} - * - * @deprecated use {@link #setRequestEntity(RequestEntity)} - */ - public void setRequestBody(InputStream body) { - LOG.trace("enter EntityEnclosingMethod.setRequestBody(InputStream)"); - clearRequestBody(); - this.requestStream = body; - } - - /** - * Sets the request body to be the specified string. - * The string will be submitted, using the encoding - * specified in the Content-Type request header.
      - * Example: setRequestHeader("Content-type", "text/xml; charset=UTF-8");
      - * Would use the UTF-8 encoding. - * If no charset is specified, the - * {@link org.apache.commons.httpclient.HttpConstants#DEFAULT_CONTENT_CHARSET default} - * content encoding is used (ISO-8859-1). - * - * @param body Request body content as a string - * - * @deprecated use {@link #setRequestEntity(RequestEntity)} - */ - public void setRequestBody(String body) { - LOG.trace("enter EntityEnclosingMethod.setRequestBody(String)"); - clearRequestBody(); - this.requestString = body; - } - - /** * Writes the request body to the given {@link HttpConnection connection}. * * @param state the {@link HttpState state} information associated with this method @@ -454,15 +346,11 @@ * this HTTP method * * @return true - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. + * @throws IOException */ - protected boolean writeRequestBody(HttpState state, HttpConnection conn) - throws IOException, HttpException { - LOG.trace( + @Override + protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException { + LOG.debug( "enter EntityEnclosingMethod.writeRequestBody(HttpState, HttpConnection)"); if (!hasRequestContent()) { @@ -503,26 +391,6 @@ LOG.debug("Request body sent"); return true; - } - - /** - * Recycles the HTTP method so that it can be used again. - * Note that all of the instance variables will be reset - * once this method has been called. This method will also - * release the connection being used by this HTTP method. - * - * @see #releaseConnection() - * - * @deprecated no longer supported and will be removed in the future - * version of HttpClient - */ - public void recycle() { - LOG.trace("enter EntityEnclosingMethod.recycle()"); - clearRequestBody(); - this.requestContentLength = InputStreamRequestEntity.CONTENT_LENGTH_AUTO; - this.repeatCount = 0; - this.chunked = false; - super.recycle(); } /** diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/ExpectContinueMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/ExpectContinueMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/ExpectContinueMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/ExpectContinueMethod.java Tue Jan 3 20:22:58 2006 @@ -36,8 +36,8 @@ import org.apache.commons.httpclient.HttpState; import org.apache.commons.httpclient.HttpVersion; import org.apache.commons.httpclient.params.HttpMethodParams; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** *

      @@ -70,7 +70,8 @@ public abstract class ExpectContinueMethod extends HttpMethodBase { /** LOG object for this class. */ - private static final Log LOG = LogFactory.getLog(ExpectContinueMethod.class); + private static final Logger LOG = LoggerFactory + .getLogger(ExpectContinueMethod.class); /** * No-arg constructor. @@ -93,67 +94,6 @@ } /** - *

      - * Returns true if the 'Expect: 100-Continue' handshake - * is activated. The purpose of the 'Expect: 100-Continue' - * handshake to allow a client that is sending a request message - * with a request body to determine if the origin server is - * willing to accept the request (based on the request headers) - * before the client sends the request body. - *

      - * - * @return true if 'Expect: 100-Continue' handshake is to - * be used, false otherwise. - * - * @since 2.0beta1 - * - * @deprecated Use {@link HttpMethodParams} - * - * @see #getParams() - * @see HttpMethodParams - * @see HttpMethodParams#USE_EXPECT_CONTINUE - */ - public boolean getUseExpectHeader() { - return getParams().getBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, false); - } - - /** - *

      - * Activates 'Expect: 100-Continue' handshake. The purpose of - * the 'Expect: 100-Continue' handshake to allow a client that is - * sending a request message with a request body to determine if - * the origin server is willing to accept the request (based on - * the request headers) before the client sends the request body. - *

      - * - *

      - * The use of the 'Expect: 100-continue' handshake can result in - * noticable peformance improvement for entity enclosing requests - * (such as POST and PUT) that require the target server's - * authentication. - *

      - * - *

      - * 'Expect: 100-continue' handshake should be used with - * caution, as it may cause problems with HTTP servers and - * proxies that do not support HTTP/1.1 protocol. - *

      - * - * @param value boolean value - * - * @since 2.0beta1 - * - * @deprecated Use {@link HttpMethodParams} - * - * @see #getParams() - * @see HttpMethodParams - * @see HttpMethodParams#USE_EXPECT_CONTINUE - */ - public void setUseExpectHeader(boolean value) { - getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, value); - } - - /** * Returns true if there is a request body to be sent. * 'Expect: 100-continue' handshake may not be used if request * body is not present @@ -171,15 +111,12 @@ * @param state the {@link HttpState state} information associated with this method * @param conn the {@link HttpConnection connection} used to execute * this HTTP method - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. + * @throws IOException + * @throws HttpException */ - protected void addRequestHeaders(HttpState state, HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter ExpectContinueMethod.addRequestHeaders(HttpState, HttpConnection)"); + @Override + protected void addRequestHeaders(HttpState state, HttpConnection conn) throws HttpException, IOException { + LOG.debug("enter ExpectContinueMethod.addRequestHeaders(HttpState, HttpConnection)"); super.addRequestHeaders(state, conn); // If the request is being retried, the header may already be present diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/GetMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/GetMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/GetMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/GetMethod.java Tue Jan 3 18:23:36 2006 @@ -30,8 +30,8 @@ package org.apache.commons.httpclient.methods; import org.apache.commons.httpclient.HttpMethodBase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Implements the HTTP GET method. @@ -64,7 +64,7 @@ // -------------------------------------------------------------- Constants /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(GetMethod.class); + private static final Logger LOG = LoggerFactory.getLogger(GetMethod.class); // ----------------------------------------------------------- Constructors @@ -86,7 +86,7 @@ */ public GetMethod(String uri) { super(uri); - LOG.trace("enter GetMethod(String)"); + LOG.debug("enter GetMethod(String)"); setFollowRedirects(true); } @@ -99,30 +99,8 @@ * * @since 2.0 */ + @Override public String getName() { return "GET"; } - - // ------------------------------------------------------------- Properties - - /** - * Recycles the HTTP method so that it can be used again. - * Note that all of the instance variables will be reset - * once this method has been called. This method will also - * release the connection being used by this HTTP method. - * - * @see #releaseConnection() - * - * @since 1.0 - * - * @deprecated no longer supported and will be removed in the future - * version of HttpClient - */ - public void recycle() { - LOG.trace("enter GetMethod.recycle()"); - - super.recycle(); - setFollowRedirects(true); - } - } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/HeadMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/HeadMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/HeadMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/HeadMethod.java Tue Jan 3 18:24:35 2006 @@ -30,15 +30,14 @@ package org.apache.commons.httpclient.methods; import java.io.IOException; - import org.apache.commons.httpclient.HttpConnection; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.HttpState; import org.apache.commons.httpclient.ProtocolException; import org.apache.commons.httpclient.params.HttpMethodParams; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Implements the HTTP HEAD method. @@ -69,7 +68,7 @@ //~ Static variables/initializers /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HeadMethod.class); + private static final Logger LOG = LoggerFactory.getLogger(HeadMethod.class); //~ Constructors @@ -103,29 +102,12 @@ * * @since 2.0 */ + @Override public String getName() { return "HEAD"; } /** - * Recycles the HTTP method so that it can be used again. - * Note that all of the instance variables will be reset - * once this method has been called. This method will also - * release the connection being used by this HTTP method. - * - * @see #releaseConnection() - * - * @since 1.0 - * - * @deprecated no longer supported and will be removed in the future - * version of HttpClient - */ - public void recycle() { - super.recycle(); - setFollowRedirects(true); - } - - /** * Overrides {@link HttpMethodBase} method to not read a response * body, despite the presence of a Content-Length or * Transfer-Encoding header. @@ -139,14 +121,14 @@ * @throws HttpException if a protocol exception occurs. Usually protocol exceptions * cannot be recovered from. * - * @see #readResponse - * @see #processResponseBody + * @see #readResponseBody(HttpState, HttpConnection) * * @since 2.0 */ + @Override protected void readResponseBody(HttpState state, HttpConnection conn) throws HttpException, IOException { - LOG.trace( + LOG.debug( "enter HeadMethod.readResponseBody(HttpState, HttpConnection)"); int bodyCheckTimeout = @@ -172,47 +154,12 @@ if (getParams().isParameterTrue(HttpMethodParams.REJECT_HEAD_BODY)) { throw new ProtocolException( "Body content may not be sent in response to HTTP HEAD request"); - } else { - LOG.warn("Body content returned in response to HTTP HEAD"); } + LOG.warn("Body content returned in response to HTTP HEAD"); super.readResponseBody(state, conn); } } } - /** - * Returns non-compliant response body check timeout. - * - * @return The period of time in milliseconds to wait for a response - * body from a non-compliant server. -1 returned when - * non-compliant response body check is disabled - * - * @deprecated Use {@link HttpMethodParams} - * - * @see #getParams() - * @see HttpMethodParams - * @see HttpMethodParams#HEAD_BODY_CHECK_TIMEOUT - */ - public int getBodyCheckTimeout() { - return getParams().getIntParameter(HttpMethodParams.HEAD_BODY_CHECK_TIMEOUT, -1); - } - - /** - * Sets non-compliant response body check timeout. - * - * @param timeout The period of time in milliseconds to wait for a response - * body from a non-compliant server. -1 can be used to - * disable non-compliant response body check - * - * @deprecated Use {@link HttpMethodParams} - * - * @see #getParams() - * @see HttpMethodParams - * @see HttpMethodParams#HEAD_BODY_CHECK_TIMEOUT - */ - public void setBodyCheckTimeout(int timeout) { - getParams().setIntParameter(HttpMethodParams.HEAD_BODY_CHECK_TIMEOUT, timeout); - } - } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/InputStreamRequestEntity.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/InputStreamRequestEntity.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/InputStreamRequestEntity.java Sat Jul 23 12:33:39 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/InputStreamRequestEntity.java Tue Jan 3 03:57:19 2006 @@ -34,9 +34,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A RequestEntity that contains an InputStream. @@ -51,8 +50,8 @@ */ public static final int CONTENT_LENGTH_AUTO = -2; - private static final Log LOG = LogFactory.getLog(InputStreamRequestEntity.class); - + private static final Logger LOG = LoggerFactory + .getLogger(InputStreamRequestEntity.class); private long contentLength; private InputStream content; @@ -111,8 +110,8 @@ this.contentType = contentType; } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.methods.RequestEntity#getContentType() + /** + * {@inheritDoc} */ public String getContentType() { return contentType; @@ -148,8 +147,8 @@ } /** - * Tests if this method is repeatable. Only true if the content has been - * buffered. + * Tests if this method is repeatable. + * @return true if the content has been buffered. * * @see #getContentLength() */ @@ -157,8 +156,8 @@ return buffer != null; } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.RequestEntity#writeRequest(java.io.OutputStream) + /** + * {@inheritDoc} */ public void writeRequest(OutputStream out) throws IOException { @@ -180,6 +179,7 @@ /** * Gets the content length. If the content length has not been set, the content will be * buffered to determine the actual content length. + * @return content length */ public long getContentLength() { if (contentLength == CONTENT_LENGTH_AUTO && buffer == null) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java Thu Jan 1 01:00:00 1970 @@ -1,332 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/methods/MultipartPostMethod.java,v 1.27 2004/10/06 03:39:59 mbecke Exp $ - * $Revision: 155418 $ - * $Date: 2005-02-26 14:01:52 +0100 (Sa, 26 Feb 2005) $ - * - * ==================================================================== - * - * Copyright 2002-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient.methods; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.httpclient.HttpConnection; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpState; -import org.apache.commons.httpclient.methods.multipart.FilePart; -import org.apache.commons.httpclient.methods.multipart.Part; -import org.apache.commons.httpclient.methods.multipart.StringPart; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Implements the HTTP multipart POST method. - *

      - * The HTTP multipart POST method is defined in section 3.3 of - * RFC1867: - *

      - * The media-type multipart/form-data follows the rules of all multipart - * MIME data streams as outlined in RFC 1521. The multipart/form-data contains - * a series of parts. Each part is expected to contain a content-disposition - * header where the value is "form-data" and a name attribute specifies - * the field name within the form, e.g., 'content-disposition: form-data; - * name="xxxxx"', where xxxxx is the field name corresponding to that field. - * Field names originally in non-ASCII character sets may be encoded using - * the method outlined in RFC 1522. - *
      - *

      - *

      - * - * @author Matthew Albright - * @author Jeff Dever - * @author Adrian Sutton - * @author Mark Diggory - * @author Mike Bowler - * @author Oleg Kalnichevski - * - * @since 2.0 - * - * @deprecated Use {@link org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity} - * in conjunction with {@link org.apache.commons.httpclient.methods.PostMethod} instead. - */ -public class MultipartPostMethod extends ExpectContinueMethod { - - /** The Content-Type for multipart/form-data. */ - public static final String MULTIPART_FORM_CONTENT_TYPE = - "multipart/form-data"; - - /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(MultipartPostMethod.class); - - /** The parameters for this method */ - private final List parameters = new ArrayList(); - - /** - * No-arg constructor. - */ - public MultipartPostMethod() { - super(); - } - - /** - * Constructor specifying a URI. - * - * @param uri either an absolute or relative URI - */ - public MultipartPostMethod(String uri) { - super(uri); - } - - /** - * Returns true - * - * @return true - * - * @since 2.0beta1 - */ - protected boolean hasRequestContent() { - return true; - } - - /** - * Returns "POST". - * @return "POST" - */ - public String getName() { - return "POST"; - } - - /** - * Adds a text field part - * - * @param parameterName The name of the parameter. - * @param parameterValue The value of the parameter. - */ - public void addParameter(String parameterName, String parameterValue) { - LOG.trace("enter addParameter(String parameterName, String parameterValue)"); - Part param = new StringPart(parameterName, parameterValue); - parameters.add(param); - } - - /** - * Adds a binary file part - * - * @param parameterName The name of the parameter - * @param parameterFile The name of the file. - * @throws FileNotFoundException If the file cannot be found. - */ - public void addParameter(String parameterName, File parameterFile) - throws FileNotFoundException { - LOG.trace("enter MultipartPostMethod.addParameter(String parameterName, " - + "File parameterFile)"); - Part param = new FilePart(parameterName, parameterFile); - parameters.add(param); - } - - /** - * Adds a binary file part with the given file name - * - * @param parameterName The name of the parameter - * @param fileName The file name - * @param parameterFile The file - * @throws FileNotFoundException If the file cannot be found. - */ - public void addParameter(String parameterName, String fileName, File parameterFile) - throws FileNotFoundException { - LOG.trace("enter MultipartPostMethod.addParameter(String parameterName, " - + "String fileName, File parameterFile)"); - Part param = new FilePart(parameterName, fileName, parameterFile); - parameters.add(param); - } - - /** - * Adds a part. - * - * @param part The part to add. - */ - public void addPart (final Part part) { - LOG.trace("enter addPart(Part part)"); - parameters.add(part); - } - - /** - * Returns all parts. - * - * @return an array of containing all parts - */ - public Part[] getParts() { - return (Part[]) parameters.toArray(new Part[parameters.size()]); - } - - /** - * Adds a Content-Length request header, as long as no - * Content-Length request header already exists. - * - * @param state current state of http requests - * @param conn the connection to use for I/O - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. - * - * @since 3.0 - */ - protected void addContentLengthRequestHeader(HttpState state, - HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter EntityEnclosingMethod.addContentLengthRequestHeader(" - + "HttpState, HttpConnection)"); - - if (getRequestHeader("Content-Length") == null) { - long len = getRequestContentLength(); - addRequestHeader("Content-Length", String.valueOf(len)); - } - removeRequestHeader("Transfer-Encoding"); - } - - /** - * Adds a Content-Type request header. - * - * @param state current state of http requests - * @param conn the connection to use for I/O - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. - * - * @since 3.0 - */ - protected void addContentTypeRequestHeader(HttpState state, - HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter EntityEnclosingMethod.addContentTypeRequestHeader(" - + "HttpState, HttpConnection)"); - - if (!parameters.isEmpty()) { - StringBuffer buffer = new StringBuffer(MULTIPART_FORM_CONTENT_TYPE); - if (Part.getBoundary() != null) { - buffer.append("; boundary="); - buffer.append(Part.getBoundary()); - } - setRequestHeader("Content-Type", buffer.toString()); - } - } - - /** - * Populates the request headers map to with additional - * {@link org.apache.commons.httpclient.Header headers} to be submitted to - * the given {@link HttpConnection}. - * - *

      - * This implementation adds tt>Content-Length and Content-Type - * headers, when appropriate. - *

      - * - *

      - * Subclasses may want to override this method to to add additional - * headers, and may choose to invoke this implementation (via - * super) to add the "standard" headers. - *

      - * - * @param state the {@link HttpState state} information associated with this method - * @param conn the {@link HttpConnection connection} used to execute - * this HTTP method - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. - * - * @see #writeRequestHeaders - */ - protected void addRequestHeaders(HttpState state, HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter MultipartPostMethod.addRequestHeaders(HttpState state, " - + "HttpConnection conn)"); - super.addRequestHeaders(state, conn); - addContentLengthRequestHeader(state, conn); - addContentTypeRequestHeader(state, conn); - } - - /** - * Writes the request body to the given {@link HttpConnection connection}. - * - * @param state the {@link HttpState state} information associated with this method - * @param conn the {@link HttpConnection connection} used to execute - * this HTTP method - * - * @return true - * - * @throws IOException if an I/O (transport) error occurs. Some transport exceptions - * can be recovered from. - * @throws HttpException if a protocol exception occurs. Usually protocol exceptions - * cannot be recovered from. - */ - protected boolean writeRequestBody(HttpState state, HttpConnection conn) - throws IOException, HttpException { - LOG.trace("enter MultipartPostMethod.writeRequestBody(HttpState state, " - + "HttpConnection conn)"); - OutputStream out = conn.getRequestOutputStream(); - Part.sendParts(out, getParts()); - return true; - } - - /** - *

      Return the length of the request body.

      - * - *

      Once this method has been invoked, the request parameters cannot be - * altered until the method is {@link #recycle recycled}.

      - * - * @return The request content length. - */ - protected long getRequestContentLength() throws IOException { - LOG.trace("enter MultipartPostMethod.getRequestContentLength()"); - return Part.getLengthOfParts(getParts()); - } - - - /** - * Recycles the HTTP method so that it can be used again. - * Note that all of the instance variables will be reset - * once this method has been called. This method will also - * release the connection being used by this HTTP method. - * - * @see #releaseConnection() - * - * @deprecated no longer supported and will be removed in the future - * version of HttpClient - */ - public void recycle() { - LOG.trace("enter MultipartPostMethod.recycle()"); - super.recycle(); - parameters.clear(); - } -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/OptionsMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/OptionsMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/OptionsMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/OptionsMethod.java Tue Jan 3 18:25:20 2006 @@ -29,16 +29,15 @@ package org.apache.commons.httpclient.methods; +import java.util.Enumeration; +import java.util.StringTokenizer; +import java.util.Vector; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpConnection; import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.HttpState; - -import org.apache.commons.logging.LogFactory; -import org.apache.commons.logging.Log; -import java.util.Enumeration; -import java.util.StringTokenizer; -import java.util.Vector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -70,8 +69,8 @@ // --------------------------------------------------------- Class Variables /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(OptionsMethod.class); - + private static final Logger LOG = LoggerFactory + .getLogger(OptionsMethod.class); // ----------------------------------------------------------- Constructors @@ -81,6 +80,7 @@ * @since 1.0 */ public OptionsMethod() { + // do nothing } @@ -102,7 +102,7 @@ /** * Methods allowed. */ - private Vector methodsAllowed = new Vector(); + private Vector methodsAllowed = new Vector(); // --------------------------------------------------------- Public Methods @@ -112,6 +112,7 @@ * @return "OPTIONS" * @since 2.0 */ + @Override public String getName() { return "OPTIONS"; } @@ -154,12 +155,11 @@ * @param conn the {@link HttpConnection connection} used to execute * this HTTP method * - * @see #readResponse - * @see #readResponseHeaders * @since 2.0 */ + @Override protected void processResponseHeaders(HttpState state, HttpConnection conn) { - LOG.trace("enter OptionsMethod.processResponseHeaders(HttpState, HttpConnection)"); + LOG.debug("enter OptionsMethod.processResponseHeaders(HttpState, HttpConnection)"); Header allowHeader = getResponseHeader("allow"); if (allowHeader != null) { @@ -173,19 +173,4 @@ } } } - - /** - * Return true if the method needs a content-length header in the request. - * - * @return true if a content-length header will be expected by the server - * - * @since 1.0 - * - * @deprecated only entity enclosing methods set content length header - */ - public boolean needContentLength() { - return false; - } - - } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/PostMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/PostMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java Tue Jan 3 04:08:39 2006 @@ -31,11 +31,10 @@ import java.util.Iterator; import java.util.Vector; - import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Implements the HTTP POST method. @@ -72,7 +71,7 @@ // -------------------------------------------------------------- Constants /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(PostMethod.class); + private static final Logger LOG = LoggerFactory.getLogger(PostMethod.class); /** The Content-Type for www-form-urlencoded. */ public static final String FORM_URL_ENCODED_CONTENT_TYPE = @@ -81,7 +80,7 @@ /** * The buffered request body consisting of NameValuePairs. */ - private Vector params = new Vector(); + private Vector params = new Vector(); // ----------------------------------------------------------- Constructors @@ -114,6 +113,7 @@ * * @since 2.0 */ + @Override public String getName() { return "POST"; } @@ -130,13 +130,10 @@ * * @since 2.0beta1 */ + @Override protected boolean hasRequestContent() { - LOG.trace("enter PostMethod.hasRequestContent()"); - if (!this.params.isEmpty()) { - return true; - } else { - return super.hasRequestContent(); - } + LOG.debug("enter PostMethod.hasRequestContent()"); + return (!this.params.isEmpty()) ? true : super.hasRequestContent(); } /** @@ -147,8 +144,9 @@ * * @since 2.0beta1 */ + @Override protected void clearRequestBody() { - LOG.trace("enter PostMethod.clearRequestBody()"); + LOG.debug("enter PostMethod.clearRequestBody()"); this.params.clear(); super.clearRequestBody(); } @@ -156,9 +154,11 @@ /** * Generates a request entity from the post parameters, if present. Calls * {@link EntityEnclosingMethod#generateRequestBody()} if parameters have not been set. + * @return a request entity * * @since 3.0 */ + @Override protected RequestEntity generateRequestEntity() { if (!this.params.isEmpty()) { // Use a ByteArrayRequestEntity instead of a StringRequestEntity. @@ -172,9 +172,8 @@ FORM_URL_ENCODED_CONTENT_TYPE ); return entity; - } else { - return super.generateRequestEntity(); } + return super.generateRequestEntity(); } /** @@ -187,7 +186,7 @@ * @since 2.0 */ public void setParameter(String parameterName, String parameterValue) { - LOG.trace("enter PostMethod.setParameter(String, String)"); + LOG.debug("enter PostMethod.setParameter(String, String)"); removeParameter(parameterName); addParameter(parameterName, parameterValue); @@ -206,7 +205,7 @@ * */ public NameValuePair getParameter(String paramName) { - LOG.trace("enter PostMethod.getParameter(String)"); + LOG.debug("enter PostMethod.getParameter(String)"); if (paramName == null) { return null; @@ -236,7 +235,7 @@ * */ public NameValuePair[] getParameters() { - LOG.trace("enter PostMethod.getParameters()"); + LOG.debug("enter PostMethod.getParameters()"); int numPairs = this.params.size(); Object[] objectArr = this.params.toArray(); @@ -261,7 +260,7 @@ */ public void addParameter(String paramName, String paramValue) throws IllegalArgumentException { - LOG.trace("enter PostMethod.addParameter(String, String)"); + LOG.debug("enter PostMethod.addParameter(String, String)"); if ((paramName == null) || (paramValue == null)) { throw new IllegalArgumentException( @@ -283,7 +282,7 @@ */ public void addParameter(NameValuePair param) throws IllegalArgumentException { - LOG.trace("enter PostMethod.addParameter(NameValuePair)"); + LOG.debug("enter PostMethod.addParameter(NameValuePair)"); if (param == null) { throw new IllegalArgumentException("NameValuePair may not be null"); @@ -300,7 +299,7 @@ * @since 2.0 */ public void addParameters(NameValuePair[] parameters) { - LOG.trace("enter PostMethod.addParameters(NameValuePair[])"); + LOG.debug("enter PostMethod.addParameters(NameValuePair[])"); if (parameters == null) { LOG.warn("Attempt to addParameters(null) ignored"); @@ -328,7 +327,7 @@ */ public boolean removeParameter(String paramName) throws IllegalArgumentException { - LOG.trace("enter PostMethod.removeParameter(String)"); + LOG.debug("enter PostMethod.removeParameter(String)"); if (paramName == null) { throw new IllegalArgumentException( @@ -364,7 +363,7 @@ */ public boolean removeParameter(String paramName, String paramValue) throws IllegalArgumentException { - LOG.trace("enter PostMethod.removeParameter(String, String)"); + LOG.debug("enter PostMethod.removeParameter(String, String)"); if (paramName == null) { throw new IllegalArgumentException("Parameter name may not be null"); @@ -399,7 +398,7 @@ */ public void setRequestBody(NameValuePair[] parametersBody) throws IllegalArgumentException { - LOG.trace("enter PostMethod.setRequestBody(NameValuePair[])"); + LOG.debug("enter PostMethod.setRequestBody(NameValuePair[])"); if (parametersBody == null) { throw new IllegalArgumentException("Array of parameters may not be null"); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/PutMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/PutMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java Tue Jan 3 04:09:06 2006 @@ -83,6 +83,7 @@ * * @since 2.0 */ + @Override public String getName() { return "PUT"; } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java Wed Dec 14 19:08:35 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/StringRequestEntity.java Tue Jan 3 04:09:56 2006 @@ -89,6 +89,7 @@ * @param charset The charset of the content, or null. Used to convert the * content to bytes. If the content type does not contain a charset and charset is not null, * then the charset will be appended to the content type. + * @throws UnsupportedEncodingException */ public StringRequestEntity(String content, String contentType, String charset) throws UnsupportedEncodingException { @@ -125,8 +126,8 @@ } } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.methods.RequestEntity#getContentType() + /** + * {@inheritDoc} */ public String getContentType() { return contentType; @@ -139,8 +140,8 @@ return true; } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.RequestEntity#writeRequest(java.io.OutputStream) + /** + * {@inheritDoc} */ public void writeRequest(OutputStream out) throws IOException { if (out == null) { @@ -167,9 +168,8 @@ } catch (UnsupportedEncodingException e) { return new String(this.content); } - } else { - return new String(this.content); } + return new String(this.content); } /** diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/TraceMethod.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/TraceMethod.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/TraceMethod.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/TraceMethod.java Tue Jan 3 18:26:32 2006 @@ -82,26 +82,8 @@ * @since 2.0 * */ + @Override public String getName() { return "TRACE"; } - - /** - * Recycles the HTTP method so that it can be used again. - * Note that all of the instance variables will be reset - * once this method has been called. This method will also - * release the connection being used by this HTTP method. - * - * @see #releaseConnection() - * - * @since 2.0 - * - * @deprecated no longer supported and will be removed in the future - * version of HttpClient - */ - public void recycle() { - super.recycle(); - setFollowRedirects(false); - } - } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/ByteArrayPartSource.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/ByteArrayPartSource.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/ByteArrayPartSource.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/ByteArrayPartSource.java Tue Jan 3 03:34:53 2006 @@ -30,7 +30,6 @@ package org.apache.commons.httpclient.methods.multipart; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.InputStream; /** @@ -79,7 +78,7 @@ /** * @see PartSource#createInputStream() */ - public InputStream createInputStream() throws IOException { + public InputStream createInputStream() { return new ByteArrayInputStream(bytes); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/FilePart.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePart.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/FilePart.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePart.java Tue Jan 3 03:36:32 2006 @@ -35,8 +35,8 @@ import java.io.InputStream; import java.io.OutputStream; import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class implements a part of a Multipart post object that @@ -65,8 +65,7 @@ public static final String DEFAULT_TRANSFER_ENCODING = "binary"; /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(FilePart.class); - + private static final Logger LOG = LoggerFactory.getLogger(FilePart.class); /** Attachment's file name */ protected static final String FILE_NAME = "; filename="; @@ -184,9 +183,10 @@ * @throws IOException If an IO problem occurs * @see Part#sendDispositionHeader(OutputStream) */ + @Override protected void sendDispositionHeader(OutputStream out) throws IOException { - LOG.trace("enter sendDispositionHeader(OutputStream out)"); + LOG.debug("enter sendDispositionHeader(OutputStream out)"); super.sendDispositionHeader(out); String filename = this.source.getFileName(); if (filename != null) { @@ -203,8 +203,9 @@ * @throws IOException if an IO problem occurs. * @see org.apache.commons.httpclient.methods.multipart.Part#sendData(OutputStream) */ + @Override protected void sendData(OutputStream out) throws IOException { - LOG.trace("enter sendData(OutputStream out)"); + LOG.debug("enter sendData(OutputStream out)"); if (lengthOfData() == 0) { // this file contains no data, so there is nothing to send. @@ -233,18 +234,18 @@ * @return The source. */ protected PartSource getSource() { - LOG.trace("enter getSource()"); + LOG.debug("enter getSource()"); return this.source; } /** * Return the length of the data. * @return The length. - * @throws IOException if an IO problem occurs * @see org.apache.commons.httpclient.methods.multipart.Part#lengthOfData() */ - protected long lengthOfData() throws IOException { - LOG.trace("enter lengthOfData()"); + @Override + protected long lengthOfData() { + LOG.debug("enter lengthOfData()"); return source.getLength(); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/FilePartSource.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePartSource.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/FilePartSource.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/FilePartSource.java Tue Jan 3 03:37:33 2006 @@ -97,11 +97,7 @@ * @see PartSource#getLength() */ public long getLength() { - if (this.file != null) { - return this.file.length(); - } else { - return 0; - } + return (this.file != null) ? this.file.length() : 0; } /** @@ -120,11 +116,9 @@ * @see PartSource#createInputStream() */ public InputStream createInputStream() throws IOException { - if (this.file != null) { - return new FileInputStream(this.file); - } else { - return new ByteArrayInputStream(new byte[] {}); - } + return (this.file != null) + ? new FileInputStream(this.file) + : new ByteArrayInputStream(new byte[] {}); } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/MultipartRequestEntity.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/MultipartRequestEntity.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/MultipartRequestEntity.java Sun Oct 23 15:27:39 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/MultipartRequestEntity.java Tue Jan 3 03:39:55 2006 @@ -31,12 +31,11 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Random; - import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.commons.httpclient.params.HttpMethodParams; import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Implements a request entity suitable for an HTTP multipart POST method. @@ -75,8 +74,8 @@ */ public class MultipartRequestEntity implements RequestEntity { - private static final Log log = LogFactory.getLog(MultipartRequestEntity.class); - + private static final Logger log = LoggerFactory + .getLogger(MultipartRequestEntity.class); /** The Content-Type for multipart/form-data. */ private static final String MULTIPART_FORM_CONTENT_TYPE = "multipart/form-data"; @@ -88,7 +87,7 @@ /** * Generates a random multipart boundary string. - * @return + * @returna random array with a size from 30 to 40 */ private static byte[] generateMultipartBoundary() { Random rand = new Random(); @@ -156,15 +155,15 @@ return true; } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.methods.RequestEntity#writeRequest(java.io.OutputStream) + /** + * {@inheritDoc} */ public void writeRequest(OutputStream out) throws IOException { Part.sendParts(out, parts, getMultipartBoundary()); } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.methods.RequestEntity#getContentLength() + /** + * {@inheritDoc} */ public long getContentLength() { try { @@ -175,8 +174,8 @@ } } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.methods.RequestEntity#getContentType() + /** + * {@inheritDoc} */ public String getContentType() { StringBuffer buffer = new StringBuffer(MULTIPART_FORM_CONTENT_TYPE); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/Part.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/Part.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/Part.java Wed Nov 9 20:41:40 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/Part.java Tue Jan 3 18:13:34 2006 @@ -32,10 +32,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; - import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Abstract class for one Part of a multipart post object. @@ -51,22 +50,20 @@ public abstract class Part { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(Part.class); + private static final Logger LOG = LoggerFactory.getLogger(Part.class); /** * The boundary - * @deprecated use {@link org.apache.commons.httpclient.params.HttpMethodParams#MULTIPART_BOUNDARY} */ - protected static final String BOUNDARY = "----------------314159265358979323846"; + private static final String BOUNDARY = "----------------314159265358979323846"; /** * The boundary as a byte array. - * @deprecated */ - protected static final byte[] BOUNDARY_BYTES = EncodingUtil.getAsciiBytes(BOUNDARY); + private static final byte[] BOUNDARY_BYTES = EncodingUtil.getAsciiBytes(BOUNDARY); /** - * The default boundary to be used if {@link #setBoundaryBytes(byte[])) has not + * The default boundary to be used if {@link #setBoundaryBytes(byte[])} has not * been called. */ private static final byte[] DEFAULT_BOUNDARY_BYTES = BOUNDARY_BYTES; @@ -120,15 +117,6 @@ EncodingUtil.getAsciiBytes(CONTENT_TRANSFER_ENCODING); /** - * Return the boundary string. - * @return the boundary string - * @deprecated uses a constant string. Rather use {@link #getPartBoundary} - */ - public static String getBoundary() { - return BOUNDARY; - } - - /** * The ASCII bytes to use as the multipart boundary. */ private byte[] boundaryBytes; @@ -165,12 +153,7 @@ * @since 3.0 */ protected byte[] getPartBoundary() { - if (boundaryBytes == null) { - // custom boundary bytes have not been set, use the default. - return DEFAULT_BOUNDARY_BYTES; - } else { - return boundaryBytes; - } + return (boundaryBytes == null) ? DEFAULT_BOUNDARY_BYTES : boundaryBytes; } /** @@ -200,7 +183,7 @@ * @throws IOException If an IO problem occurs. */ protected void sendStart(OutputStream out) throws IOException { - LOG.trace("enter sendStart(OutputStream out)"); + LOG.debug("enter sendStart(OutputStream out)"); out.write(EXTRA_BYTES); out.write(getPartBoundary()); out.write(CRLF_BYTES); @@ -213,7 +196,7 @@ * @throws IOException If an IO problem occurs. */ protected void sendDispositionHeader(OutputStream out) throws IOException { - LOG.trace("enter sendDispositionHeader(OutputStream out)"); + LOG.debug("enter sendDispositionHeader(OutputStream out)"); out.write(CONTENT_DISPOSITION_BYTES); out.write(QUOTE_BYTES); out.write(EncodingUtil.getAsciiBytes(getName())); @@ -226,7 +209,7 @@ * @throws IOException If an IO problem occurs. */ protected void sendContentTypeHeader(OutputStream out) throws IOException { - LOG.trace("enter sendContentTypeHeader(OutputStream out)"); + LOG.debug("enter sendContentTypeHeader(OutputStream out)"); String contentType = getContentType(); if (contentType != null) { out.write(CRLF_BYTES); @@ -248,7 +231,7 @@ * @throws IOException If an IO problem occurs. */ protected void sendTransferEncodingHeader(OutputStream out) throws IOException { - LOG.trace("enter sendTransferEncodingHeader(OutputStream out)"); + LOG.debug("enter sendTransferEncodingHeader(OutputStream out)"); String transferEncoding = getTransferEncoding(); if (transferEncoding != null) { out.write(CRLF_BYTES); @@ -263,7 +246,7 @@ * @throws IOException If an IO problem occurs. */ protected void sendEndOfHeader(OutputStream out) throws IOException { - LOG.trace("enter sendEndOfHeader(OutputStream out)"); + LOG.debug("enter sendEndOfHeader(OutputStream out)"); out.write(CRLF_BYTES); out.write(CRLF_BYTES); } @@ -289,7 +272,7 @@ * @throws IOException If an IO problem occurs. */ protected void sendEnd(OutputStream out) throws IOException { - LOG.trace("enter sendEnd(OutputStream out)"); + LOG.debug("enter sendEnd(OutputStream out)"); out.write(CRLF_BYTES); } @@ -302,7 +285,7 @@ * @throws IOException If an IO problem occurs. */ public void send(OutputStream out) throws IOException { - LOG.trace("enter send(OutputStream out)"); + LOG.debug("enter send(OutputStream out)"); sendStart(out); sendDispositionHeader(out); sendContentTypeHeader(out); @@ -322,7 +305,7 @@ * @throws IOException If an IO problem occurs */ public long length() throws IOException { - LOG.trace("enter length()"); + LOG.debug("enter length()"); if (lengthOfData() < 0) { return -1; } @@ -341,6 +324,7 @@ * @return A string representation of this object. * @see java.lang.Object#toString() */ + @Override public String toString() { return this.getName(); } @@ -414,7 +398,7 @@ * @since 3.0 */ public static long getLengthOfParts(Part[] parts, byte[] partBoundary) throws IOException { - LOG.trace("getLengthOfParts(Parts[])"); + LOG.debug("getLengthOfParts(Parts[])"); if (parts == null) { throw new IllegalArgumentException("Parts may not be null"); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/PartBase.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/PartBase.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/PartBase.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/PartBase.java Tue Jan 3 03:42:46 2006 @@ -73,6 +73,7 @@ * @return The name. * @see org.apache.commons.httpclient.methods.multipart.Part#getName() */ + @Override public String getName() { return this.name; } @@ -81,6 +82,7 @@ * Returns the content type of this part. * @return String The name. */ + @Override public String getContentType() { return this.contentType; } @@ -89,6 +91,7 @@ * Return the character encoding of this part. * @return String The name. */ + @Override public String getCharSet() { return this.charSet; } @@ -97,6 +100,7 @@ * Returns the transfer encoding of this part. * @return String The name. */ + @Override public String getTransferEncoding() { return transferEncoding; } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/StringPart.java commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/StringPart.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/StringPart.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/StringPart.java Tue Jan 3 03:43:59 2006 @@ -29,12 +29,11 @@ package org.apache.commons.httpclient.methods.multipart; -import java.io.OutputStream; import java.io.IOException; - +import java.io.OutputStream; import org.apache.commons.httpclient.util.EncodingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Simple string parameter for a multipart post @@ -49,7 +48,7 @@ public class StringPart extends PartBase { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(StringPart.class); + private static final Logger LOG = LoggerFactory.getLogger(StringPart.class); /** Default content encoding of string parameters. */ public static final String DEFAULT_CONTENT_TYPE = "text/plain"; @@ -120,25 +119,27 @@ * @param out the OutputStream to write to * @throws IOException if there is a write error */ + @Override protected void sendData(OutputStream out) throws IOException { - LOG.trace("enter sendData(OutputStream)"); + LOG.debug("enter sendData(OutputStream)"); out.write(getContent()); } /** * Return the length of the data. * @return The length of the data. - * @throws IOException If an IO problem occurs * @see org.apache.commons.httpclient.methods.multipart.Part#lengthOfData() */ - protected long lengthOfData() throws IOException { - LOG.trace("enter lengthOfData()"); + @Override + protected long lengthOfData() { + LOG.debug("enter lengthOfData()"); return getContent().length; } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.methods.multipart.BasePart#setCharSet(java.lang.String) + /** + * {@inheritDoc} */ + @Override public void setCharSet(String charSet) { super.setCharSet(charSet); this.content = null; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/package.html commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/package.html --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/methods/multipart/package.html Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/methods/multipart/package.html Tue Jan 3 21:36:59 2006 @@ -4,7 +4,7 @@ Package Documentation for org.apache.commons.httpclient.methods.multipart - Provides Multipart support classes for the {@link org.apache.commons.httpclient.methods.MultipartPostMethod}. + Provides Multipart support classes for the {@link org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity}. @since 2.0 diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/DefaultHttpParams.java commons-httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParams.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/DefaultHttpParams.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParams.java Tue Jan 3 04:15:34 2006 @@ -31,9 +31,8 @@ import java.io.Serializable; import java.util.HashMap; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class represents a collection of HTTP protocol parameters. Protocol parameters @@ -50,7 +49,8 @@ public class DefaultHttpParams implements HttpParams, Serializable, Cloneable { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(DefaultHttpParams.class); + private static final Logger LOG = LoggerFactory + .getLogger(DefaultHttpParams.class); /** HttpParams class factory. */ private static HttpParamsFactory httpParamsFactory = new DefaultHttpParamsFactory(); @@ -84,7 +84,7 @@ private HttpParams defaults = null; /** Hash map of HTTP parameters that this collection contains */ - private HashMap parameters = null; + private HashMap parameters = null; /** * Creates a new collection of parameters with the given parent. @@ -112,14 +112,23 @@ this(getDefaultParams()); } + /** + * {@inheritDoc} + */ public synchronized HttpParams getDefaults() { return this.defaults; } + /** + * {@inheritDoc} + */ public synchronized void setDefaults(final HttpParams params) { this.defaults = params; } + /** + * {@inheritDoc} + */ public synchronized Object getParameter(final String name) { // See if the parameter has been explicitly defined Object param = null; @@ -129,21 +138,16 @@ if (param != null) { // If so, return return param; - } else { - // If not, see if defaults are available - if (this.defaults != null) { - // Return default parameter value - return this.defaults.getParameter(name); - } else { - // Otherwise, return null - return null; - } } + return (this.defaults != null) ? this.defaults.getParameter(name) : null; } + /** + * {@inheritDoc} + */ public synchronized void setParameter(final String name, final Object value) { if (this.parameters == null) { - this.parameters = new HashMap(); + this.parameters = new HashMap(); } this.parameters.put(name, value); if (LOG.isDebugEnabled()) { @@ -163,6 +167,9 @@ } } + /** + * {@inheritDoc} + */ public long getLongParameter(final String name, long defaultValue) { Object param = getParameter(name); if (param == null) { @@ -171,10 +178,16 @@ return ((Long)param).longValue(); } + /** + * {@inheritDoc} + */ public void setLongParameter(final String name, long value) { setParameter(name, new Long(value)); } + /** + * {@inheritDoc} + */ public int getIntParameter(final String name, int defaultValue) { Object param = getParameter(name); if (param == null) { @@ -183,10 +196,16 @@ return ((Integer)param).intValue(); } + /** + * {@inheritDoc} + */ public void setIntParameter(final String name, int value) { setParameter(name, new Integer(value)); } + /** + * {@inheritDoc} + */ public double getDoubleParameter(final String name, double defaultValue) { Object param = getParameter(name); if (param == null) { @@ -195,10 +214,16 @@ return ((Double)param).doubleValue(); } + /** + * {@inheritDoc} + */ public void setDoubleParameter(final String name, double value) { setParameter(name, new Double(value)); } + /** + * {@inheritDoc} + */ public boolean getBooleanParameter(final String name, boolean defaultValue) { Object param = getParameter(name); if (param == null) { @@ -207,22 +232,37 @@ return ((Boolean)param).booleanValue(); } + /** + * {@inheritDoc} + */ public void setBooleanParameter(final String name, boolean value) { setParameter(name, new Boolean(value)); } + /** + * {@inheritDoc} + */ public boolean isParameterSet(final String name) { return getParameter(name) != null; } + /** + * {@inheritDoc} + */ public boolean isParameterSetLocally(final String name) { return this.parameters != null && this.parameters.get(name) != null; } + /** + * {@inheritDoc} + */ public boolean isParameterTrue(final String name) { return getBooleanParameter(name, false); } + /** + * {@inheritDoc} + */ public boolean isParameterFalse(final String name) { return !getBooleanParameter(name, false); } @@ -241,11 +281,13 @@ * @see java.io.Serializable * @see java.lang.Object#clone() */ + @SuppressWarnings("unchecked") + @Override public Object clone() throws CloneNotSupportedException { DefaultHttpParams clone = (DefaultHttpParams)super.clone(); if (this.parameters != null) { - clone.parameters = (HashMap)this.parameters.clone(); + clone.parameters = (HashMap)this.parameters.clone(); } clone.setDefaults(this.defaults); return clone; diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/DefaultHttpParamsFactory.java commons-httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParamsFactory.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/DefaultHttpParamsFactory.java Mon Dec 19 05:29:32 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParamsFactory.java Tue Jan 3 17:24:33 2006 @@ -52,8 +52,8 @@ super(); } - /* (non-Javadoc) - * @see org.apache.commons.httpclient.params.HttpParamsFactory#getDefaultParams() + /** + * {@inheritDoc} */ public synchronized HttpParams getDefaultParams() { if (httpParams == null) { @@ -63,6 +63,10 @@ return httpParams; } + /** + * Initialize default parameter settings. + * @return default parameters + */ protected HttpParams createParams() { HttpClientParams params = new HttpClientParams(null); @@ -74,7 +78,7 @@ params.setContentCharset("ISO-8859-1"); params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler()); - ArrayList datePatterns = new ArrayList(); + ArrayList datePatterns = new ArrayList(); datePatterns.addAll( Arrays.asList( new String[] { @@ -102,6 +106,7 @@ try { agent = System.getProperty("httpclient.useragent"); } catch (SecurityException ignore) { + // ignored } if (agent != null) { params.setParameter(HttpMethodParams.USER_AGENT, agent); @@ -112,6 +117,7 @@ try { preemptiveDefault = System.getProperty("httpclient.authentication.preemptive"); } catch (SecurityException ignore) { + // ignored } if (preemptiveDefault != null) { preemptiveDefault = preemptiveDefault.trim().toLowerCase(); @@ -127,6 +133,7 @@ try { defaultCookiePolicy = System.getProperty("apache.commons.httpclient.cookiespec"); } catch (SecurityException ignore) { + //ignored } if (defaultCookiePolicy != null) { if ("COMPATIBILITY".equalsIgnoreCase(defaultCookiePolicy)) { diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/HttpClientParams.java commons-httpclient/src/java/org/apache/commons/httpclient/params/HttpClientParams.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/HttpClientParams.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/params/HttpClientParams.java Tue Jan 3 04:17:39 2006 @@ -197,12 +197,20 @@ }; + /** + * {@inheritDoc} + */ + @Override public void makeStrict() { super.makeStrict(); setParameters(PROTOCOL_STRICTNESS_PARAMETERS, Boolean.TRUE); } + /** + * {@inheritDoc} + */ + @Override public void makeLenient() { super.makeLenient(); setParameters(PROTOCOL_STRICTNESS_PARAMETERS, Boolean.FALSE); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java commons-httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java Tue Jan 3 04:24:34 2006 @@ -95,6 +95,7 @@ * * @see #MAX_HOST_CONNECTIONS */ + @SuppressWarnings("unchecked") public void setMaxConnectionsPerHost( HostConfiguration hostConfiguration, int maxHostConnections) { @@ -103,14 +104,15 @@ throw new IllegalArgumentException("maxHostConnections must be greater than 0"); } - Map currentValues = (Map) getParameter(MAX_HOST_CONNECTIONS); + Map currentValues = + (Map) getParameter(MAX_HOST_CONNECTIONS); // param values are meant to be immutable so we'll make a copy // to modify - Map newValues = null; + Map newValues = null; if (currentValues == null) { - newValues = new HashMap(); + newValues = new HashMap(); } else { - newValues = new HashMap(currentValues); + newValues = new HashMap(currentValues); } newValues.put(hostConfiguration, new Integer(maxHostConnections)); setParameter(MAX_HOST_CONNECTIONS, newValues); @@ -144,20 +146,18 @@ if (m == null) { // MAX_HOST_CONNECTIONS have not been configured, using the default value return MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS; - } else { + } Integer max = (Integer) m.get(hostConfiguration); if (max == null && hostConfiguration != HostConfiguration.ANY_HOST_CONFIGURATION) { // the value has not been configured specifically for this host config, // use the default value return getMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION); - } else { + } return ( max == null ? MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS : max.intValue() ); - } - } } /** diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java commons-httpclient/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java Mon Dec 5 21:18:10 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java Tue Jan 3 04:25:26 2006 @@ -31,8 +31,8 @@ import org.apache.commons.httpclient.HttpVersion; import org.apache.commons.httpclient.cookie.CookiePolicy; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class represents a collection of HTTP protocol parameters applicable to @@ -51,7 +51,8 @@ public class HttpMethodParams extends DefaultHttpParams { /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpMethodParams.class); + private static final Logger LOG = LoggerFactory + .getLogger(HttpMethodParams.class); /** * Defines the content of the User-Agent header used by diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java commons-httpclient/src/java/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java Tue Jan 3 04:27:25 2006 @@ -59,6 +59,7 @@ * This method spawns a controller thread overseeing the process of socket * initialisation. If the socket constructor cannot be created within the specified time * limit, the controller terminates and throws an {@link ConnectTimeoutException} + * @param socketfactory * * @param host the host name/IP * @param port the port on the host @@ -86,6 +87,7 @@ throws IOException, UnknownHostException, ConnectTimeoutException { SocketTask task = new SocketTask() { + @Override public void doit() throws IOException { setSocket(socketfactory.createSocket(host, port, localAddress, localPort)); } @@ -104,6 +106,14 @@ return socket; } + /** + * @param task + * @param timeout + * @return a socket + * @throws IOException + * @throws UnknownHostException + * @throws ConnectTimeoutException + */ public static Socket createSocket(final SocketTask task, int timeout) throws IOException, UnknownHostException, ConnectTimeoutException { @@ -128,7 +138,7 @@ /** The socket */ private Socket socket; /** The exception */ - private IOException exception; + IOException exception; /** * Set the socket. diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java commons-httpclient/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java Tue Jan 3 04:28:50 2006 @@ -119,7 +119,7 @@ int timeout = params.getConnectionTimeout(); if (timeout == 0) { return createSocket(host, port, localAddress, localPort); - } else { + } // To be eventually deprecated when migrated to Java 1.4 or above Socket socket = ReflectionSocketFactory.createSocket( "javax.net.SocketFactory", host, port, localAddress, localPort, timeout); @@ -129,7 +129,6 @@ } return socket; } - } /** * @see ProtocolSocketFactory#createSocket(java.lang.String,int) @@ -141,14 +140,19 @@ /** * All instances of DefaultProtocolSocketFactory are the same. + * @param obj {@inheritDoc} + * @return {@inheritDoc} */ + @Override public boolean equals(Object obj) { return ((obj != null) && obj.getClass().equals(DefaultProtocolSocketFactory.class)); } /** * All instances of DefaultProtocolSocketFactory have the same hash code. + * @return {@inheritDoc} */ + @Override public int hashCode() { return DefaultProtocolSocketFactory.class.hashCode(); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/protocol/Protocol.java commons-httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/protocol/Protocol.java Mon Mar 14 21:23:16 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/protocol/Protocol.java Tue Jan 3 18:35:54 2006 @@ -56,7 +56,8 @@ public class Protocol { /** The available protocols */ - private static final Map PROTOCOLS = Collections.synchronizedMap(new HashMap()); + private static final Map PROTOCOLS = + Collections.synchronizedMap(new HashMap()); /** * Registers a new protocol with the given identifier. If a protocol with @@ -110,7 +111,7 @@ throw new IllegalArgumentException("id is null"); } - Protocol protocol = (Protocol) PROTOCOLS.get(id); + Protocol protocol = PROTOCOLS.get(id); if (protocol == null) { protocol = lazyRegisterProtocol(id); @@ -189,22 +190,6 @@ } /** - * Constructs a new Protocol. Whether the created protocol is secure depends on - * the class of factory. - * - * @param scheme the scheme (e.g. http, https) - * @param factory the factory for creating sockets for communication using - * this protocol - * @param defaultPort the port this protocol defaults to - * @deprecated Use the constructor that uses ProtocolSocketFactory, this version of - * the constructor is only kept for backwards API compatibility. - */ - public Protocol(String scheme, - SecureProtocolSocketFactory factory, int defaultPort) { - this(scheme, (ProtocolSocketFactory) factory, defaultPort); - } - - /** * Returns the defaultPort. * @return int */ @@ -253,6 +238,7 @@ * Return a string representation of this object. * @return a string representation of this object. */ + @Override public String toString() { return scheme + ":" + defaultPort; } @@ -262,6 +248,7 @@ * @param obj The object to compare against. * @return true if the objects are equal. */ + @Override public boolean equals(Object obj) { if (obj instanceof Protocol) { @@ -274,16 +261,15 @@ && secure == p.isSecure() && socketFactory.equals(p.getSocketFactory())); - } else { - return false; } - + return false; } /** * Return a hash code for this object * @return The hash code. */ + @Override public int hashCode() { int hash = LangUtils.HASH_SEED; hash = LangUtils.hashCode(hash, this.defaultPort); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java commons-httpclient/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java Tue Jan 3 04:32:13 2006 @@ -108,6 +108,7 @@ * @throws IOException if an I/O error occurs while creating the socket * @throws UnknownHostException if the IP address of the host cannot be * determined + * @throws ConnectTimeoutException * * @since 3.0 */ @@ -124,7 +125,7 @@ int timeout = params.getConnectionTimeout(); if (timeout == 0) { return createSocket(host, port, localAddress, localPort); - } else { + } // To be eventually deprecated when migrated to Java 1.4 or above Socket socket = ReflectionSocketFactory.createSocket( "javax.net.ssl.SSLSocketFactory", host, port, localAddress, localPort, timeout); @@ -134,7 +135,6 @@ } return socket; } - } /** * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) @@ -166,14 +166,19 @@ /** * All instances of SSLProtocolSocketFactory are the same. + * @param obj {@inheritDoc} + * @return {@inheritDoc} */ + @Override public boolean equals(Object obj) { return ((obj != null) && obj.getClass().equals(SSLProtocolSocketFactory.class)); } /** * All instances of SSLProtocolSocketFactory have the same hash code. + * @return {@inheritDoc} */ + @Override public int hashCode() { return SSLProtocolSocketFactory.class.hashCode(); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/DateParser.java commons-httpclient/src/java/org/apache/commons/httpclient/util/DateParser.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/DateParser.java Sat Jul 23 12:23:59 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/util/DateParser.java Thu Jan 1 01:00:00 1970 @@ -1,141 +0,0 @@ -/* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/util/DateParser.java,v 1.11 2004/11/06 19:15:42 mbecke Exp $ - * $Revision: 224451 $ - * $Date: 2005-07-23 12:23:59 +0200 (Sa, 23 Jul 2005) $ - * - * ==================================================================== - * - * Copyright 1999-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * 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 - * . - * - */ - -package org.apache.commons.httpclient.util; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.Locale; -import java.util.TimeZone; - -/** - * A utility class for parsing HTTP dates as used in cookies and other headers. - * This class handles dates as defined by RFC 2616 section 3.3.1 as well as - * some other common non-standard formats. - * - * @author Christopher Brown - * @author Michael Becke - * - * @deprecated Use {@link org.apache.commons.httpclient.util.DateUtil} - */ -public class DateParser { - - /** - * Date format pattern used to parse HTTP date headers in RFC 1123 format. - */ - public static final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz"; - - /** - * Date format pattern used to parse HTTP date headers in RFC 1036 format. - */ - public static final String PATTERN_RFC1036 = "EEEE, dd-MMM-yy HH:mm:ss zzz"; - - /** - * Date format pattern used to parse HTTP date headers in ANSI C - * asctime() format. - */ - public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy"; - - private static final Collection DEFAULT_PATTERNS = Arrays.asList( - new String[] { PATTERN_ASCTIME, PATTERN_RFC1036, PATTERN_RFC1123 } ); - /** - * Parses a date value. The formats used for parsing the date value are retrieved from - * the default http params. - * - * @param dateValue the date value to parse - * - * @return the parsed date - * - * @throws DateParseException if the value could not be parsed using any of the - * supported date formats - */ - public static Date parseDate(String dateValue) throws DateParseException { - return parseDate(dateValue, null); - } - - /** - * Parses the date value using the given date formats. - * - * @param dateValue the date value to parse - * @param dateFormats the date formats to use - * - * @return the parsed date - * - * @throws DateParseException if none of the dataFormats could parse the dateValue - */ - public static Date parseDate( - String dateValue, - Collection dateFormats - ) throws DateParseException { - - if (dateValue == null) { - throw new IllegalArgumentException("dateValue is null"); - } - if (dateFormats == null) { - dateFormats = DEFAULT_PATTERNS; - } - // trim single quotes around date if present - // see issue #5279 - if (dateValue.length() > 1 - && dateValue.startsWith("'") - && dateValue.endsWith("'") - ) { - dateValue = dateValue.substring (1, dateValue.length() - 1); - } - - SimpleDateFormat dateParser = null; - Iterator formatIter = dateFormats.iterator(); - - while (formatIter.hasNext()) { - String format = (String) formatIter.next(); - if (dateParser == null) { - dateParser = new SimpleDateFormat(format, Locale.US); - dateParser.setTimeZone(TimeZone.getTimeZone("GMT")); - } else { - dateParser.applyPattern(format); - } - try { - return dateParser.parse(dateValue); - } catch (ParseException pe) { - // ignore this exception, we will try the next format - } - } - - // we were unable to parse the date - throw new DateParseException("Unable to parse the date " + dateValue); - } - - /** This class should not be instantiated. */ - private DateParser() { } - -} diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/DateUtil.java commons-httpclient/src/java/org/apache/commons/httpclient/util/DateUtil.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/DateUtil.java Sat Jul 23 12:23:59 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/util/DateUtil.java Tue Jan 3 18:38:04 2006 @@ -204,6 +204,8 @@ } /** This class should not be instantiated. */ - private DateUtil() { } + private DateUtil() { + // singleton + } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/EncodingUtil.java commons-httpclient/src/java/org/apache/commons/httpclient/util/EncodingUtil.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/EncodingUtil.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/util/EncodingUtil.java Tue Jan 3 18:13:01 2006 @@ -29,12 +29,11 @@ package org.apache.commons.httpclient.util; import java.io.UnsupportedEncodingException; - import org.apache.commons.codec.net.URLCodec; import org.apache.commons.httpclient.HttpClientError; import org.apache.commons.httpclient.NameValuePair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The home for utility methods that handle various encoding tasks. @@ -50,7 +49,8 @@ private static final String DEFAULT_CHARSET = "ISO-8859-1"; /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(EncodingUtil.class); + private static final Logger LOG = LoggerFactory + .getLogger(EncodingUtil.class); /** * Form-urlencoding routine. @@ -282,6 +282,7 @@ * This class should not be instantiated. */ private EncodingUtil() { + // do nothing } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/ExceptionUtil.java commons-httpclient/src/java/org/apache/commons/httpclient/util/ExceptionUtil.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/ExceptionUtil.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/util/ExceptionUtil.java Tue Jan 3 18:43:23 2006 @@ -29,10 +29,6 @@ package org.apache.commons.httpclient.util; import java.io.InterruptedIOException; -import java.lang.reflect.Method; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * The home for utility methods that handle various exception-related tasks. @@ -44,34 +40,10 @@ */ public class ExceptionUtil { - /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(ExceptionUtil.class); - - /** A reference to Throwable's initCause method, or null if it's not there in this JVM */ - static private final Method INIT_CAUSE_METHOD = getInitCauseMethod(); - /** A reference to SocketTimeoutExceptionClass class, or null if it's not there in this JVM */ static private final Class SOCKET_TIMEOUT_CLASS = SocketTimeoutExceptionClass(); /** - * Returns a Method allowing access to - * {@link Throwable.initCause(Throwable) initCause} method of {@link Throwable}, - * or null if the method - * does not exist. - * - * @return A Method for Throwable.initCause, or - * null if unavailable. - */ - static private Method getInitCauseMethod() { - try { - Class[] paramsClasses = new Class[] { Throwable.class }; - return Throwable.class.getMethod("initCause", paramsClasses); - } catch (NoSuchMethodException e) { - return null; - } - } - - /** * Returns SocketTimeoutExceptionClass or null if the class * does not exist. * @@ -86,22 +58,6 @@ } /** - * If we're running on JDK 1.4 or later, initialize the cause for the given throwable. - * - * @param throwable The throwable. - * @param cause The cause of the throwable. - */ - public static void initCause(Throwable throwable, Throwable cause) { - if (INIT_CAUSE_METHOD != null) { - try { - INIT_CAUSE_METHOD.invoke(throwable, new Object[] { cause }); - } catch (Exception e) { - LOG.warn("Exception invoking Throwable.initCause", e); - } - } - } - - /** * If SocketTimeoutExceptionClass is defined, returns true only if the * exception is an instance of SocketTimeoutExceptionClass. If * SocketTimeoutExceptionClass is undefined, always returns true. @@ -112,10 +68,8 @@ * otherwise. */ public static boolean isSocketTimeoutException(final InterruptedIOException e) { - if (SOCKET_TIMEOUT_CLASS != null) { - return SOCKET_TIMEOUT_CLASS.isInstance(e); - } else { - return true; - } + return (SOCKET_TIMEOUT_CLASS != null) + ? SOCKET_TIMEOUT_CLASS.isInstance(e) + : true; } } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/HttpURLConnection.java commons-httpclient/src/java/org/apache/commons/httpclient/util/HttpURLConnection.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/HttpURLConnection.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/util/HttpURLConnection.java Tue Jan 3 04:44:58 2006 @@ -29,17 +29,15 @@ package org.apache.commons.httpclient.util; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.Header; - -import org.apache.commons.logging.LogFactory; -import org.apache.commons.logging.Log; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; -import java.net.ProtocolException; import java.security.Permission; +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpMethod; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Provides a HttpURLConnection wrapper around HttpClient's @@ -68,7 +66,8 @@ // -------------------------------------------------------- Class Variables /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(HttpURLConnection.class); + private static final Logger LOG = LoggerFactory + .getLogger(HttpURLConnection.class); // ----------------------------------------------------- Instance Variables @@ -122,8 +121,9 @@ * @see java.net.HttpURLConnection#getInputStream() * @see org.apache.commons.httpclient.HttpMethod#getResponseBodyAsStream() */ + @Override public InputStream getInputStream() throws IOException { - LOG.trace("enter HttpURLConnection.getInputStream()"); + LOG.debug("enter HttpURLConnection.getInputStream()"); return this.method.getResponseBodyAsStream(); } @@ -132,8 +132,9 @@ * Return the error stream. * @see java.net.HttpURLConnection#getErrorStream() */ + @Override public InputStream getErrorStream() { - LOG.trace("enter HttpURLConnection.getErrorStream()"); + LOG.debug("enter HttpURLConnection.getErrorStream()"); throw new RuntimeException("Not implemented yet"); } @@ -141,18 +142,19 @@ * Not yet implemented. * @see java.net.HttpURLConnection#disconnect() */ + @Override public void disconnect() { - LOG.trace("enter HttpURLConnection.disconnect()"); + LOG.debug("enter HttpURLConnection.disconnect()"); throw new RuntimeException("Not implemented yet"); } /** * Not available: the data must have already been retrieved. - * @throws IOException If an IO problem occurs. * @see java.net.HttpURLConnection#connect() */ - public void connect() throws IOException { - LOG.trace("enter HttpURLConnection.connect()"); + @Override + public void connect() { + LOG.debug("enter HttpURLConnection.connect()"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -162,8 +164,9 @@ * @return true if we are using a proxy. * @see java.net.HttpURLConnection#usingProxy() */ + @Override public boolean usingProxy() { - LOG.trace("enter HttpURLConnection.usingProxy()"); + LOG.debug("enter HttpURLConnection.usingProxy()"); throw new RuntimeException("Not implemented yet"); } @@ -173,32 +176,33 @@ * @see java.net.HttpURLConnection#getRequestMethod() * @see org.apache.commons.httpclient.HttpMethod#getName() */ + @Override public String getRequestMethod() { - LOG.trace("enter HttpURLConnection.getRequestMethod()"); + LOG.debug("enter HttpURLConnection.getRequestMethod()"); return this.method.getName(); } /** * Return the response code. * @return The response code. - * @throws IOException If an IO problem occurs. * @see java.net.HttpURLConnection#getResponseCode() * @see org.apache.commons.httpclient.HttpMethod#getStatusCode() */ - public int getResponseCode() throws IOException { - LOG.trace("enter HttpURLConnection.getResponseCode()"); + @Override + public int getResponseCode() { + LOG.debug("enter HttpURLConnection.getResponseCode()"); return this.method.getStatusCode(); } /** * Return the response message * @return The response message - * @throws IOException If an IO problem occurs. * @see java.net.HttpURLConnection#getResponseMessage() * @see org.apache.commons.httpclient.HttpMethod#getStatusText() */ - public String getResponseMessage() throws IOException { - LOG.trace("enter HttpURLConnection.getResponseMessage()"); + @Override + public String getResponseMessage() { + LOG.debug("enter HttpURLConnection.getResponseMessage()"); return this.method.getStatusText(); } @@ -209,8 +213,9 @@ * @see java.net.HttpURLConnection#getHeaderField(String) * @see org.apache.commons.httpclient.HttpMethod#getResponseHeaders() */ + @Override public String getHeaderField(String name) { - LOG.trace("enter HttpURLConnection.getHeaderField(String)"); + LOG.debug("enter HttpURLConnection.getHeaderField(String)"); // Note: Return the last matching header in the Header[] array, as in // the JDK implementation. Header[] headers = this.method.getResponseHeaders(); @@ -230,8 +235,9 @@ * @see java.net.HttpURLConnection#getHeaderFieldKey(int) * @see org.apache.commons.httpclient.HttpMethod#getResponseHeaders() */ + @Override public String getHeaderFieldKey(int keyPosition) { - LOG.trace("enter HttpURLConnection.getHeaderFieldKey(int)"); + LOG.debug("enter HttpURLConnection.getHeaderFieldKey(int)"); // Note: HttpClient does not consider the returned Status Line as // a response header. However, getHeaderFieldKey(0) is supposed to @@ -259,8 +265,9 @@ * @see java.net.HttpURLConnection#getHeaderField(int) * @see org.apache.commons.httpclient.HttpMethod#getResponseHeaders() */ + @Override public String getHeaderField(int position) { - LOG.trace("enter HttpURLConnection.getHeaderField(int)"); + LOG.debug("enter HttpURLConnection.getHeaderField(int)"); // Note: HttpClient does not consider the returned Status Line as // a response header. However, getHeaderField(0) is supposed to @@ -286,8 +293,9 @@ * @return The URL. * @see java.net.HttpURLConnection#getURL() */ + @Override public URL getURL() { - LOG.trace("enter HttpURLConnection.getURL()"); + LOG.debug("enter HttpURLConnection.getURL()"); return this.url; } @@ -306,18 +314,22 @@ /** * Not available: the data must have already been retrieved. + * @param isFollowingRedirects */ + @Override public void setInstanceFollowRedirects(boolean isFollowingRedirects) { - LOG.trace("enter HttpURLConnection.setInstanceFollowRedirects(boolean)"); + LOG.debug("enter HttpURLConnection.setInstanceFollowRedirects(boolean)"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } /** * Not yet implemented. + * @return an error */ + @Override public boolean getInstanceFollowRedirects() { - LOG.trace("enter HttpURLConnection.getInstanceFollowRedirects()"); + LOG.debug("enter HttpURLConnection.getInstanceFollowRedirects()"); throw new RuntimeException("Not implemented yet"); } @@ -325,8 +337,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#setRequestMethod(String) */ - public void setRequestMethod(String method) throws ProtocolException { - LOG.trace("enter HttpURLConnection.setRequestMethod(String)"); + @Override + public void setRequestMethod(String method) { + LOG.debug("enter HttpURLConnection.setRequestMethod(String)"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -335,8 +348,9 @@ * Not yet implemented. * @see java.net.HttpURLConnection#getPermission() */ - public Permission getPermission() throws IOException { - LOG.trace("enter HttpURLConnection.getPermission()"); + @Override + public Permission getPermission() { + LOG.debug("enter HttpURLConnection.getPermission()"); throw new RuntimeException("Not implemented yet"); } @@ -344,24 +358,29 @@ * Not yet implemented. * @see java.net.HttpURLConnection#getContent() */ - public Object getContent() throws IOException { - LOG.trace("enter HttpURLConnection.getContent()"); + @Override + public Object getContent() { + LOG.debug("enter HttpURLConnection.getContent()"); throw new RuntimeException("Not implemented yet"); } /** * Not yet implemented. + * @param classes + * @return an error */ - public Object getContent(Class[] classes) throws IOException { - LOG.trace("enter HttpURLConnection.getContent(Class[])"); + @Override + public Object getContent(Class[] classes) { + LOG.debug("enter HttpURLConnection.getContent(Class[])"); throw new RuntimeException("Not implemented yet"); } /** * @see java.net.HttpURLConnection#getOutputStream() */ - public OutputStream getOutputStream() throws IOException { - LOG.trace("enter HttpURLConnection.getOutputStream()"); + @Override + public OutputStream getOutputStream() { + LOG.debug("enter HttpURLConnection.getOutputStream()"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -370,8 +389,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#setDoInput(boolean) */ + @Override public void setDoInput(boolean isInput) { - LOG.trace("enter HttpURLConnection.setDoInput()"); + LOG.debug("enter HttpURLConnection.setDoInput()"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -380,8 +400,9 @@ * Not yet implemented. * @see java.net.HttpURLConnection#getDoInput() */ + @Override public boolean getDoInput() { - LOG.trace("enter HttpURLConnection.getDoInput()"); + LOG.debug("enter HttpURLConnection.getDoInput()"); throw new RuntimeException("Not implemented yet"); } @@ -389,8 +410,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#setDoOutput(boolean) */ + @Override public void setDoOutput(boolean isOutput) { - LOG.trace("enter HttpURLConnection.setDoOutput()"); + LOG.debug("enter HttpURLConnection.setDoOutput()"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -399,8 +421,9 @@ * Not yet implemented. * @see java.net.HttpURLConnection#getDoOutput() */ + @Override public boolean getDoOutput() { - LOG.trace("enter HttpURLConnection.getDoOutput()"); + LOG.debug("enter HttpURLConnection.getDoOutput()"); throw new RuntimeException("Not implemented yet"); } @@ -408,8 +431,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#setAllowUserInteraction(boolean) */ + @Override public void setAllowUserInteraction(boolean isAllowInteraction) { - LOG.trace("enter HttpURLConnection.setAllowUserInteraction(boolean)"); + LOG.debug("enter HttpURLConnection.setAllowUserInteraction(boolean)"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -418,8 +442,9 @@ * Not yet implemented. * @see java.net.HttpURLConnection#getAllowUserInteraction() */ + @Override public boolean getAllowUserInteraction() { - LOG.trace("enter HttpURLConnection.getAllowUserInteraction()"); + LOG.debug("enter HttpURLConnection.getAllowUserInteraction()"); throw new RuntimeException("Not implemented yet"); } @@ -427,8 +452,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#setUseCaches(boolean) */ + @Override public void setUseCaches(boolean isUsingCaches) { - LOG.trace("enter HttpURLConnection.setUseCaches(boolean)"); + LOG.debug("enter HttpURLConnection.setUseCaches(boolean)"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -437,8 +463,9 @@ * Not yet implemented. * @see java.net.HttpURLConnection#getUseCaches() */ + @Override public boolean getUseCaches() { - LOG.trace("enter HttpURLConnection.getUseCaches()"); + LOG.debug("enter HttpURLConnection.getUseCaches()"); throw new RuntimeException("Not implemented yet"); } @@ -446,8 +473,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#setIfModifiedSince(long) */ + @Override public void setIfModifiedSince(long modificationDate) { - LOG.trace("enter HttpURLConnection.setIfModifiedSince(long)"); + LOG.debug("enter HttpURLConnection.setIfModifiedSince(long)"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -456,8 +484,9 @@ * Not yet implemented. * @see java.net.HttpURLConnection#getIfModifiedSince() */ + @Override public long getIfModifiedSince() { - LOG.trace("enter HttpURLConnection.getIfmodifiedSince()"); + LOG.debug("enter HttpURLConnection.getIfmodifiedSince()"); throw new RuntimeException("Not implemented yet"); } @@ -465,8 +494,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#getDefaultUseCaches() */ + @Override public boolean getDefaultUseCaches() { - LOG.trace("enter HttpURLConnection.getDefaultUseCaches()"); + LOG.debug("enter HttpURLConnection.getDefaultUseCaches()"); throw new RuntimeException("Not implemented yet"); } @@ -474,8 +504,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#setDefaultUseCaches(boolean) */ + @Override public void setDefaultUseCaches(boolean isUsingCaches) { - LOG.trace("enter HttpURLConnection.setDefaultUseCaches(boolean)"); + LOG.debug("enter HttpURLConnection.setDefaultUseCaches(boolean)"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -484,8 +515,9 @@ * Not available: the data must have already been retrieved. * @see java.net.HttpURLConnection#setRequestProperty(String,String) */ + @Override public void setRequestProperty(String key, String value) { - LOG.trace("enter HttpURLConnection.setRequestProperty()"); + LOG.debug("enter HttpURLConnection.setRequestProperty()"); throw new RuntimeException("This class can only be used with already" + "retrieved data"); } @@ -494,8 +526,9 @@ * Not yet implemented. * @see java.net.HttpURLConnection#getRequestProperty(String) */ + @Override public String getRequestProperty(String key) { - LOG.trace("enter HttpURLConnection.getRequestProperty()"); + LOG.debug("enter HttpURLConnection.getRequestProperty()"); throw new RuntimeException("Not implemented yet"); } diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java commons-httpclient/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java Sat Feb 26 14:01:52 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java Tue Jan 3 04:49:18 2006 @@ -31,10 +31,9 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; - import org.apache.commons.httpclient.HttpConnection; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A helper class for connection managers to track idle connections. @@ -47,10 +46,11 @@ */ public class IdleConnectionHandler { - private static final Log LOG = LogFactory.getLog(IdleConnectionHandler.class); - + private static final Logger LOG = LoggerFactory + .getLogger(IdleConnectionHandler.class); /** Holds connections and the time they were added. */ - private Map connectionToAdded = new HashMap(); + private Map connectionToAdded = + new HashMap(); /** * @@ -107,11 +107,12 @@ LOG.debug("Checking for connections, idleTimeout: " + idleTimeout); } - Iterator connectionIter = connectionToAdded.keySet().iterator(); + Iterator connectionIter = + connectionToAdded.keySet().iterator(); while (connectionIter.hasNext()) { - HttpConnection conn = (HttpConnection) connectionIter.next(); - Long connectionTime = (Long) connectionToAdded.get(conn); + HttpConnection conn = connectionIter.next(); + Long connectionTime = connectionToAdded.get(conn); if (connectionTime.longValue() <= idleTimeout) { if (LOG.isDebugEnabled()) { LOG.debug("Closing connection, connection time: " + connectionTime); diff -Nbaur --exclude=.svn --exclude=*.jar commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.java commons-httpclient/src/java/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.java --- commons-httpclient.orig/src/java/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.java Wed Dec 7 20:05:13 2005 +++ commons-httpclient/src/java/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.java Tue Jan 3 18:45:18 2006 @@ -29,9 +29,7 @@ package org.apache.commons.httpclient.util; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; - import org.apache.commons.httpclient.HttpConnectionManager; /** @@ -43,7 +41,8 @@ */ public class IdleConnectionTimeoutThread extends Thread { - private List connectionManagers = new ArrayList(); + private List connectionManagers = + new ArrayList(); private boolean shutdown = false; @@ -51,6 +50,9 @@ private long connectionTimeout = 3000; + /** + * Construct a new daemon thread. + */ public IdleConnectionTimeoutThread() { setDaemon(true); } @@ -85,18 +87,17 @@ /** * Closes idle connections. */ + @Override public synchronized void run() { while (!shutdown) { - Iterator iter = connectionManagers.iterator(); - - while (iter.hasNext()) { - HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next(); + for(HttpConnectionManager connectionManager : connectionManagers) { connectionManager.closeIdleConnections(connectionTimeout); } try { this.wait(timeoutI