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 @@
@@ -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
- *
@@ -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
- * One element of an HTTP header's value.
- * 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);
+ Listtrue 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.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;
/**
*
- * 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, ';'); + Listtrue 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.
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
- * 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
- * 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.
- *
@@ -68,38 +66,24 @@
* Map of {@link Credentials credentials} by realm that this
* HTTP state contains.
*/
- private HashMap credMap = new HashMap();
+ private HashMap
* 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
- * 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.
*
*
* @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 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.
- * Abstract authentication scheme class that implements {@link AuthScheme}
- * interface and provides a default contstructor.
- *
@@ -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
@@ -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 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. 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 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. Supported versions:
- *
- * 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.
- *
- * 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.
- *
@@ -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.
- *
- * 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.
- *
- * The HTTP multipart POST method is defined in section 3.3 of
- * RFC1867:
- *
- *
- * @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.
- * 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}.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();
+ ArrayListtrue 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
- * 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 Maptrue 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();
+ LinkedListtrue 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;
-
/**
* 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 ]
- *
* 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 @@
* 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 Mapbasic
@@ -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;
/**
* 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
- *
- * 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.
- *
- * 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.
- *
- *
- *
- *
- * @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
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.
- * @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.
- *
- *
- * 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;
/**
* 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
- *
- * 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.
- *
- * NameValuePairs.
*/
- private Vector params = new Vector();
+ private Vectornull. 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 @@
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
- * 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