? log2.diff
? log3.diff
Index: java/org/apache/commons/httpclient/Authenticator.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Authenticator.java,v
retrieving revision 1.22
diff -u -u -r1.22 Authenticator.java
--- java/org/apache/commons/httpclient/Authenticator.java 26 Jul 2002 00:45:01 -0000 1.22
+++ java/org/apache/commons/httpclient/Authenticator.java 28 Jul 2002 17:55:09 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -98,7 +98,7 @@
class Authenticator {
/** org.apache.commons.httpclient.Authenticator log. */
- private static final Log log = LogFactory.getLog(Authenticator.class.getName());
+ private static final Log log = LogFactory.getLog(Authenticator.class);
/** Base 64 encoder. */
private static Base64 base64 = new Base64();
@@ -149,13 +149,12 @@
* @see #authenticate(HttpMethod,HttpState,Header,String)
*/
static boolean authenticate(HttpMethod method, HttpState state)
- throws HttpException, UnsupportedOperationException {
+ throws HttpException, UnsupportedOperationException {
+ log.trace("enter Authenticator.authenticate(HttpMethod, HttpState)");
- log.debug("enter Authenticator.authenticate(HttpMethod, HttpState)");
- Header challengeHeader = method.getResponseHeader(WWW_AUTH);
-
- return authenticate(method, state, challengeHeader, WWW_AUTH_RESP);
- }
+ Header challengeHeader = method.getResponseHeader(WWW_AUTH);
+ return authenticate(method, state, challengeHeader, WWW_AUTH_RESP);
+ }
/**
* Add requisite proxy authentication credentials to the given method
@@ -172,13 +171,12 @@
* @see #authenticate(HttpMethod,HttpState,Header,String)
*/
static boolean authenticateProxy(HttpMethod method, HttpState state)
- throws HttpException, UnsupportedOperationException {
-
- log.debug("enter Authenticator.authenticateProxy(HttpMethod, HttpState)");
- Header challengeHeader = method.getResponseHeader(PROXY_AUTH);
+ throws HttpException, UnsupportedOperationException {
+ log.trace("enter Authenticator.authenticateProxy(HttpMethod, HttpState)");
- return authenticate(method, state, challengeHeader, PROXY_AUTH_RESP);
- }
+ Header challengeHeader = method.getResponseHeader(PROXY_AUTH);
+ return authenticate(method, state, challengeHeader, PROXY_AUTH_RESP);
+ }
/**
@@ -202,8 +200,10 @@
* @see #digest
* @see HttpMethod#addRequestHeader
*/
- private static boolean authenticate(HttpMethod method, HttpState state, Header challengeHeader, String respHeader) throws HttpException, UnsupportedOperationException {
- log.debug("enter Authenticator.authenticate(HttpMethod, HttpState, Header, String)");
+ private static boolean authenticate(HttpMethod method, HttpState state, Header challengeHeader, String respHeader)
+ throws HttpException, UnsupportedOperationException {
+
+ log.trace("enter Authenticator.authenticate(HttpMethod, HttpState, Header, String)");
//check the preemptive policy
//TODO: this needs to be a service from some configuration class
@@ -296,9 +296,10 @@
*
* @throws HttpException when no matching credentials are available
*/
- static Header basic(String realm, HttpState state, String respHeader) throws HttpException {
+ static Header basic(String realm, HttpState state, String respHeader)
+ throws HttpException {
+ log.trace("enter Authenticator.basic(String, HttpState, String)");
- log.debug("enter Authenticator.basic(String, HttpState)");
boolean proxy = PROXY_AUTH_RESP.equals(respHeader);
UsernamePasswordCredentials cred = null;
try {
@@ -320,7 +321,10 @@
* Return a Basic Authorization header value for the
* given {@link UsernamePasswordCredentials}.
*/
- static String basic(UsernamePasswordCredentials cred) throws HttpException {
+ static String basic(UsernamePasswordCredentials cred)
+ throws HttpException {
+ log.trace("enter Authenticator.basic(UsernamePasswordCredentials)");
+
String authString = cred.getUserName() + ":" + cred.getPassword();
return "Basic " + new String(base64.encode(authString.getBytes()));
}
@@ -338,8 +342,10 @@
*
* @throws HttpException when no matching credentials are available
*/
- static Header digest(String realm, HttpMethod method, HttpState state, String respHeader) throws HttpException {
- log.debug("Authenticator.digest(String,HttpState)");
+ static Header digest(String realm, HttpMethod method, HttpState state, String respHeader)
+ throws HttpException {
+ log.trace("enter Authenticator.digest(String, HttpMethod, HttpState, String)");
+
boolean proxy = PROXY_AUTH_RESP.equals(respHeader);
UsernamePasswordCredentials cred = null;
try {
@@ -377,7 +383,10 @@
* Return a Digest Authorization header value for the
* given {@link UsernamePasswordCredentials}.
*/
- static String digest(UsernamePasswordCredentials cred, Hashtable headers) throws HttpException {
+ static String digest(UsernamePasswordCredentials cred, Hashtable headers)
+ throws HttpException {
+ log.trace("enter Authenticator.digest(UsernamePasswordCredentials, Hashtable)");
+
String digest = createDigest(cred.getUserName(), cred.getPassword(), headers);
return "Digest " + createDigestHeader(cred.getUserName(), headers, digest);
}
@@ -394,8 +403,11 @@
* @return The created digest as string. This will be the response tag's
* value in the Authentication HTTP header.
*/
- public static String createDigest(String uname, String pwd, Hashtable dCreds) throws HttpException {
- String digAlg = "MD5";
+ public static String createDigest(String uname, String pwd, Hashtable dCreds)
+ throws HttpException {
+ log.trace("enter Authenticator.createDigest(String, String, Hashtable)");
+
+ final String digAlg = "MD5";
// Collecting required tokens
String uri = removeQuotes((String)dCreds.get("uri"));
@@ -437,8 +449,10 @@
* @throws AxisFault if MD5 algorithm is not supported.
*/
private static String createCnonce() throws HttpException {
+ log.trace("enter Authenticator.createCnonce()");
+
String cnonce;
- String digAlg = "MD5";
+ final String digAlg = "MD5";
MessageDigest md5Helper;
try {
md5Helper = MessageDigest.getInstance(digAlg);
@@ -460,10 +474,12 @@
* @param uname Username
* @param dCreds Hashtable containing header information (uri, realm,
* nonce, nc, cnonce, opaque, qop).
- * @digest The response tag's value as String.
+ * @param digest The response tag's value as String.
* @return The digest-response as String.
*/
private static String createDigestHeader(String uname, Hashtable dCreds, String digest) {
+ log.trace("enter Authenticator.createDigestHeader(String, Hashtable, String)");
+
StringBuffer sb = new StringBuffer();
String uri = removeQuotes((String)dCreds.get("uri"));
String realm = removeQuotes((String)dCreds.get("realm"));
@@ -502,6 +518,8 @@
* str
*/
private static String removeQuotes(String str) {
+ log.trace("enter Authenticator.removeQuotes(String)");
+
if (str == null)
return null;
@@ -522,6 +540,7 @@
* @return encoded MD5, or null if encoding failed
*/
private static String encode( byte[] binaryData ) {
+ log.trace("enter Authenticator.encode(byte[])");
if (binaryData.length != 16)
return null;
@@ -555,9 +574,13 @@
* @return The parameters from www-authenticate header as a Hashtable
*/
private static Hashtable getHTTPDigestCredentials(HttpMethod method) {
+ log.trace("enter Authenticator.getHTTPDigestCredentials(HttpMethod)");
+
String authHeader = method.getResponseHeader("www-authenticate").getValue();
Hashtable ht = new Hashtable(15);
- if (authHeader == null) return ht;
+ if (authHeader == null) {
+ return ht;
+ }
authHeader = authHeader.substring(7).trim();
int i = 0;
int j = authHeader.indexOf(",");
@@ -583,6 +606,8 @@
* entry is placed (only if it has "xxx=yyy" format).
*/
private static void processDigestToken(String token, Hashtable ht) {
+ log.trace("enter Authenticator.processDigestToken(String, Hashtable)");
+
int eqpos = token.indexOf("=");
if (eqpos > 0 && eqpos < token.length()-1)
Index: java/org/apache/commons/httpclient/Base64.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java,v
retrieving revision 1.9
diff -u -u -r1.9 Base64.java
--- java/org/apache/commons/httpclient/Base64.java 10 Jul 2002 05:09:16 -0000 1.9
+++ java/org/apache/commons/httpclient/Base64.java 28 Jul 2002 17:55:10 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
Index: java/org/apache/commons/httpclient/ConnectMethod.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ConnectMethod.java,v
retrieving revision 1.1
diff -u -u -r1.1 ConnectMethod.java
--- java/org/apache/commons/httpclient/ConnectMethod.java 23 Jul 2002 14:38:31 -0000 1.1
+++ java/org/apache/commons/httpclient/ConnectMethod.java 28 Jul 2002 17:55:11 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -80,6 +80,7 @@
* Create a connect method wrapping the existing method
*/
public ConnectMethod(HttpMethod method) {
+ log.trace("enter ConnectMethod(HttpMethod)");
this.method = method;
}
@@ -87,7 +88,10 @@
return NAME;
}
- public int execute(HttpState state, HttpConnection connection) throws IOException, HttpException {
+ public int execute(HttpState state, HttpConnection connection)
+ throws IOException, HttpException {
+
+ log.trace("enter ConnectMethod.execute(HttpState, HttpConnection)");
int code = super.execute(state, connection);
log.debug("CONNECT status code "+ code);
if ((code >= 200) && (code < 300)) {
@@ -100,7 +104,10 @@
/**
* Writes a minimal set of headers to the proxy.
*/
- protected void writeRequestHeaders(HttpState state, HttpConnection conn) throws HttpException, IOException {
+ protected void writeRequestHeaders(HttpState state, HttpConnection conn)
+ throws HttpException, IOException {
+ log.trace("enter ConnectMethod.writeRequestHeaders(HttpState, HttpConnection)");
+
if (method instanceof HttpMethodBase) {
((HttpMethodBase) method).addRequestHeaders(state, conn);
}
@@ -122,8 +129,13 @@
conn.printLine(line);
}
- /** the log for output */
- static private final Log log = LogFactory.getLog(ConnectMethod.class);
+
+ /** Log object for this class. */
+ private static final Log log = LogFactory.getLog(ConnectMethod.class);
+
+ /** Log for any wire messages. */
+ private static final Log wireLog = LogFactory.getLog("httpclient.wirelog");
+
/** The wrapped method */
private HttpMethod method;
-}
\ No newline at end of file
+}
Index: java/org/apache/commons/httpclient/Cookie.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
retrieving revision 1.20
diff -u -u -r1.20 Cookie.java
--- java/org/apache/commons/httpclient/Cookie.java 21 Jul 2002 04:12:44 -0000 1.20
+++ java/org/apache/commons/httpclient/Cookie.java 28 Jul 2002 17:55:14 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -123,6 +123,7 @@
*/
public Cookie(String domain, String name, String value, String path, Date expires, boolean secure) {
super(name, value);
+ log.trace("enter Cookie(String, String, String, String, Date, boolean)");
this.setPath(path);
this.setDomain(domain);
this.setExpiryDate(expires);
@@ -408,6 +409,7 @@
* Two cookies are equal if the name, path and domain match.
*/
public boolean equals(Object obj) {
+ log.trace("enter Cookie.equals(Object)");
if ((obj != null) && (obj instanceof Cookie)) {
Cookie that = (Cookie) obj;
return (null == this.getName() ? null == that.getName() : this.getName().equals(that.getName())) &&
@@ -447,6 +449,7 @@
* @param date the time at which the request is submitted
*/
public boolean matches(String domain, int port, String path, boolean secure, Date now) {
+ log.trace("enter Cookie.matches(Strinng, int, String, boolean, Date");
// FIXME: RFC2109 doesn't consider ports when filtering/matching
// cookies. Quoting from Section 2 - Terminology:
// The terms request-host and request-URI refer to
@@ -484,7 +487,8 @@
* @param path the path to which the request is being submitted
*/
public boolean matches(String domain, int port, String path, boolean secure) {
- return matches(domain,port,path,secure,new Date());
+ log.trace("enter Cookie.matches(String, int, String, boolean");
+ return matches(domain, port, path, secure, new Date());
}
/**
@@ -497,6 +501,7 @@
* If no cookies match, returns null.
*/
public static Header createCookieHeader(String domain, String path, Cookie[] cookies) {
+ log.trace("enter Cookie.createCookieHeader(String, String, Cookie[])");
return Cookie.createCookieHeader(domain,path,false,cookies);
}
@@ -510,7 +515,10 @@
* @exception java.lang.IllegalArgumentException if domain or path is null
* @deprecated use the version which includes port number and date
*/
- public static Header createCookieHeader(String domain, String path, boolean secure, Cookie[] cookies) throws IllegalArgumentException {
+ public static Header createCookieHeader(String domain, String path, boolean secure, Cookie[] cookies)
+ throws IllegalArgumentException {
+ log.trace("enter Cookie.createCookieHeader(String, String, boolean, Cookie[])");
+
// Make sure domain isn't null here. Path will be validated in subsequent call to createCookieHeader
if(domain == null){
throw new IllegalArgumentException("null domain in createCookieHeader.");
@@ -538,8 +546,10 @@
* If no cookies match, returns null.
* @exception java.lang.IllegalArgumentException if domain or path is null
*/
- public static Header createCookieHeader(String domain, int port, String path, boolean secure, Cookie[] cookies) throws IllegalArgumentException {
- return Cookie.createCookieHeader(domain,port,path,secure,new Date(),cookies);
+ public static Header createCookieHeader(String domain, int port, String path, boolean secure, Cookie[] cookies)
+ throws IllegalArgumentException {
+ log.trace("enter Cookie.createCookieHeader(String, int, String, bookean, Cookie[])");
+ return Cookie.createCookieHeader(domain, port, path, secure, new Date(), cookies);
}
/**
@@ -552,7 +562,10 @@
* If no cookies match, returns null.
* @exception java.lang.IllegalArgumentException if domain or path is null
*/
- public static Header createCookieHeader(String domain, int port, String path, boolean secure, Date now, Cookie[] cookies) throws IllegalArgumentException {
+ public static Header createCookieHeader(String domain, int port, String path, boolean secure, Date now, Cookie[] cookies)
+ throws IllegalArgumentException {
+ log.trace("enter Cookie.createCookieHeader(String, int, String, bookean, Date, Cookie[])");
+
// Validate the domain and path
if(domain == null){
throw new IllegalArgumentException("null domain in createCookieHeader.");
@@ -604,6 +617,8 @@
* of RFC2109
true, create an HTTPS session
* @see #endSession()
*/
- public void startSession(String host, int port, Credentials creds,
- boolean https) {
+ public void startSession(String host, int port, Credentials creds, boolean https) {
+ log.trace("enter HttpClient.startSession(String, int, Credentials, boolean)");
+
if (log.isDebugEnabled()) {
log.debug(
- "HttpClient.startSession(String,int,Credentials,boolean): Host:"
- + host + " Port:" + port + " Credentials:" + creds
+ "Starting HttpClient session"
+ + " Host:" + host
+ + " Port:" + port + " Credentials:" + creds
+ " HTTPS:" + https);
}
getState().setCredentials(null, creds);
@@ -243,16 +249,18 @@
*
*/
public void startSession(URL url) {
- if ("https".equalsIgnoreCase(url.getProtocol())) {
- startSession(url.getHost(), url.getPort() == -1 ? 443
- : url.getPort(), true);
- } else if ("http".equalsIgnoreCase(url.getProtocol())) {
- startSession(url.getHost(), url.getPort() == -1 ? 80
- : url.getPort(), false);
- } else {
- throw new IllegalArgumentException("Protocol " + url.getProtocol()
- + " not supported in URL " + url);
- }
+ log.trace("enter HttpClient.startSession(String, int, Credentials, boolean)");
+
+ if ("https".equalsIgnoreCase(url.getProtocol())) {
+ startSession(url.getHost(), url.getPort() == -1 ? 443
+ : url.getPort(), true);
+ } else if ("http".equalsIgnoreCase(url.getProtocol())) {
+ startSession(url.getHost(), url.getPort() == -1 ? 80
+ : url.getPort(), false);
+ } else {
+ throw new IllegalArgumentException("Protocol " + url.getProtocol()
+ + " not supported in URL " + url);
+ }
}
/**
@@ -271,6 +279,7 @@
*
*/
public void startSession(URL url, Credentials creds) {
+ log.trace("enter HttpClient.startSession(URL, Credentials)");
getState().setCredentials(null, creds);
startSession(url);
}
@@ -287,8 +296,8 @@
* @see #endSession()
*
*/
- public void startSession(String host, int port,
- String proxyhost, int proxyport) {
+ public void startSession(String host, int port, String proxyhost, int proxyport) {
+ log.trace("enter HttpClient.startSession(String, int, String, int)");
startSession(host, port, proxyhost, proxyport, false);
}
@@ -306,11 +315,9 @@
* @see #endSession()
*
*/
- public void startSession(String host, int port,
- String proxyhost, int proxyport,
- boolean secure) {
- connection = new HttpConnection(proxyhost, proxyport, host, port,
- secure);
+ public void startSession(String host, int port, String proxyhost, int proxyport, boolean secure) {
+ log.trace("enter HttpClient.startSession(String, int, String, int, boolean)");
+ connection = new HttpConnection(proxyhost, proxyport, host, port, secure);
}
/**
@@ -324,8 +331,9 @@
* @throws HttpException if a protocol exception occurs
* @throws IllegalStateException if the session has not been started
*/
- public synchronized int executeMethod(HttpMethod method) throws IOException,
- HttpException, IllegalStateException {
+ public synchronized int executeMethod(HttpMethod method)
+ throws IOException, HttpException, IllegalStateException {
+ log.trace("enter HttpClient.executeMethod(HttpMethod)");
if (null == method) {
throw new NullPointerException("HttpMethod parameter");
@@ -361,7 +369,7 @@
* @throws IOException when i/o errors occur closing the connection
*/
public void endSession() throws IOException {
- log.debug("HttpClient.endSession()");
+ log.trace("enter HttpClient.endSession()");
if (null != connection) {
connection.close();
connection = null;
Index: java/org/apache/commons/httpclient/HttpConnection.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnection.java,v
retrieving revision 1.12
diff -u -u -r1.12 HttpConnection.java
--- java/org/apache/commons/httpclient/HttpConnection.java 23 Jul 2002 14:38:31 -0000 1.12
+++ java/org/apache/commons/httpclient/HttpConnection.java 28 Jul 2002 17:55:19 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -302,8 +302,8 @@
* protocol, such as a TCP error.
* @throws IllegalStateException if I am not connected
*/
- public void setSoTimeout(int timeout) throws SocketException,
- IllegalStateException {
+ public void setSoTimeout(int timeout)
+ throws SocketException, IllegalStateException {
log.debug("HttpConnection.setSoTimeout("+ timeout +")");
_so_timeout = timeout;
if(_socket != null){
@@ -318,7 +318,8 @@
* @throws IOException when there are errors opening the connection
*/
public void open() throws IOException {
- log.debug("HttpConnection.open()");
+ log.trace("enter HttpConnection.open()");
+
assertNotOpen(); // ??? is this worth doing?
try {
if (null == _socket) {
@@ -358,8 +359,14 @@
* @throws IOException if an error occured creating the secure socket
*/
public void tunnelCreated() throws IllegalStateException, IOException {
- if (!isSecure() || !isProxied()) throw new IllegalStateException("Connection must be secure and proxied to use this feature");
- if (_usingSecureSocket) throw new IllegalStateException("Already using a secure socket");
+ log.trace("enter HttpConnection.tunnelCreated()");
+
+ if (!isSecure() || !isProxied()) {
+ throw new IllegalStateException("Connection must be secure and proxied to use this feature");
+ }
+ if (_usingSecureSocket) {
+ throw new IllegalStateException("Already using a secure socket");
+ }
if (sslSocketFactory == null) {
sslSocketFactory = SSLSocketFactory.getDefault();
@@ -392,9 +399,9 @@
* @return a stream to write the request to
*/
public OutputStream getRequestOutputStream() throws IOException, IllegalStateException {
+ log.trace("enter HttpConnection.getRequestOutputStream()");
assertOpen();
- RequestOutputStream out = new RequestOutputStream(_output);
- return out;
+ return new RequestOutputStream(_output);
}
/**
@@ -407,10 +414,12 @@
* @throws IOException if an I/O problem occurs
* @return a stream to write the request to
*/
- public OutputStream getRequestOutputStream(boolean useChunking) throws IOException, IllegalStateException {
+ public OutputStream getRequestOutputStream(boolean useChunking)
+ throws IOException, IllegalStateException {
+ log.trace("enter HttpConnection.getRequestOutputStream(boolean)");
+
assertOpen();
- RequestOutputStream out = new RequestOutputStream(_output,useChunking);
- return out;
+ return new RequestOutputStream(_output, useChunking);
}
/**
@@ -429,6 +438,7 @@
*/
public InputStream getResponseInputStream(HttpMethod method)
throws IOException, IllegalStateException {
+ log.trace("enter HttpConnection.getRequestOutputStream(HttpMethod)");
assertOpen();
return new ResponseInputStream(_input,method);
}
@@ -442,27 +452,22 @@
* @throws IllegalStateException if I am not connected
* @throws IOException if an I/O problem occurs
*/
- public void write(byte[] data) throws IOException, IllegalStateException,
- HttpRecoverableException {
- if(log.isDebugEnabled()){
- log.debug("HttpConnection.write(byte[])");
- }
+ public void write(byte[] data)
+ throws IOException, IllegalStateException, HttpRecoverableException {
+ log.trace("enter HttpConnection.write(byte[])");
+
assertOpen();
if(wireLog.isInfoEnabled() && (data.length > 0)) {
wireLog.info(">> \"" + new String(data) + "\"");
}
try {
_output.write(data);
- } catch(SocketException e){
- if(log.isDebugEnabled()) {
- log.debug("HttpConnection: Socket exception while writing data",e);
- }
- throw new HttpRecoverableException(e.toString());
- } catch(IOException e) {
- if(log.isDebugEnabled()) {
- log.debug("HttpConnection: Exception while writing data",e);
- }
- throw e;
+ } catch(SocketException se){
+ log.debug("HttpConnection: Socket exception while writing data", se);
+ throw new HttpRecoverableException(se.toString());
+ } catch(IOException ioe) {
+ log.debug("HttpConnection: Exception while writing data", ioe);
+ throw ioe;
}
}
@@ -477,6 +482,7 @@
* @param len the number of bytes to write.
*/
public void write(byte[] data, int off, int len) throws IOException {
+ log.trace("enter HttpConnection.write(byte[], int, int)");
_output.write(data, off, len);
}
@@ -485,16 +491,14 @@
* output stream.
*
* @param data the bytes to be written
- * @throws HttpRecoverableException when socket exceptions occur writing
- * data
+ * @throws HttpRecoverableException when socket exceptions occur writing data
* @throws IllegalStateException if I am not connected
* @throws IOException if an I/O problem occurs
*/
- public void writeLine(byte[] data) throws IOException,
- IllegalStateException, HttpRecoverableException {
- if(log.isDebugEnabled()){
- log.debug("HttpConnection.writeLine(byte[])");
- }
+ public void writeLine(byte[] data)
+ throws IOException, IllegalStateException, HttpRecoverableException {
+ log.trace("enter HttpConnection.writeLine(byte[])");
+
assertOpen();
if(wireLog.isInfoEnabled() && (data.length > 0)) {
wireLog.info(">> \"" + new String(data) + "\"");
@@ -520,21 +524,19 @@
* @throws IllegalStateException if I am not connected
* @throws IOException if an I/O problem occurs
*/
- public void writeLine() throws IOException, IllegalStateException,
- HttpRecoverableException {
- if(log.isDebugEnabled()){
- log.debug("HttpConnection.writeLine()");
- }
+ public void writeLine()
+ throws IOException, IllegalStateException, HttpRecoverableException {
+ log.trace("enter HttpConnection.writeLine()");
+
wireLog.info(">> \\r\\n");
try{
_output.write(CRLF);
- } catch(SocketException e){
- if(log.isDebugEnabled()) {
- log.debug("HttpConnection: Socket exception while writing data",e);
- }
- throw new HttpRecoverableException(e.toString());
- } catch(IOException e){
- throw e;
+ } catch(SocketException se){
+ log.warn("HttpConnection: Socket exception while writing data", se);
+ throw new HttpRecoverableException(se.toString());
+ } catch(IOException ioe){
+ log.warn("HttpConnection: IO exception while writing data", ioe);
+ throw ioe;
}
}
@@ -547,8 +549,9 @@
* @throws IllegalStateException if I am not connected
* @throws IOException if an I/O problem occurs
*/
- public void print(String data) throws IOException, IllegalStateException,
- HttpRecoverableException {
+ public void print(String data)
+ throws IOException, IllegalStateException, HttpRecoverableException {
+ log.trace("enter HttpConnection.print(String)");
write(data.getBytes());
}
@@ -562,8 +565,9 @@
* @throws IllegalStateException if I am not connected
* @throws IOException if an I/O problem occurs
*/
- public void printLine(String data) throws IOException,
- IllegalStateException, HttpRecoverableException {
+ public void printLine(String data)
+ throws IOException, IllegalStateException, HttpRecoverableException {
+ log.trace("enter HttpConnection.printLine(String)");
writeLine(data.getBytes());
}
@@ -577,6 +581,7 @@
*/
public void printLine() throws IOException, IllegalStateException,
HttpRecoverableException {
+ log.trace("enter HttpConnection.printLine()");
writeLine();
}
@@ -587,8 +592,10 @@
* @throws IOException if an I/O problem occurs
* @return a line from the response
*/
- public String readLine() throws IOException, IllegalStateException {
- log.debug("HttpConnection.readLine()");
+ public String readLine()
+ throws IOException, IllegalStateException {
+ log.trace("enter HttpConnection.readLine()");
+
assertOpen();
StringBuffer buf = new StringBuffer();
for(;;) {
@@ -618,7 +625,8 @@
* Shutdown my {@link Socket}'s output, via {@link Socket#shutdownOutput}.
*/
public void shutdownOutput() {
- log.debug("HttpConnection.shutdownOutput()");
+ log.trace("enter HttpConnection.shutdownOutput()");
+
try {
// Socket.shutdownOutput is a JDK 1.3
// method. We'll use reflection in case
@@ -628,7 +636,8 @@
("shutdownOutput", paramsClasses);
Object[] params = new Object[0];
shutdownOutput.invoke(_socket, params);
- } catch (Exception e) {
+ } catch (Exception ex) {
+ log.debug("Unexpected Exception caught", ex);
// Ignore, and hope everything goes right
}
// close output stream?
@@ -638,7 +647,7 @@
* Close my socket and streams.
*/
public void close() {
- log.debug("HttpConnection.close()");
+ log.trace("enter HttpConnection.close()");
closeSocketAndStreams();
}
@@ -649,24 +658,27 @@
* Close everything out.
*/
protected void closeSocketAndStreams() {
- log.debug("HttpConnection.closeSocketAndStreams()");
+ log.trace("enter HttpConnection.closeSockedAndStreams()");
try {
_input.close();
- } catch(Exception e) {
+ } catch(Exception ex) {
+ log.debug("Exception caught when closing input", ex);
// ignored
}
_input = null;
try {
_output.close();
- } catch(Exception e) {
+ } catch(Exception ex) {
+ log.debug("Exception caught when closing output", ex);
// ignored
}
_output = null;
try {
_socket.close();
- } catch(Exception e) {
+ } catch(Exception ex) {
+ log.debug("Exception caught when closing socket", ex);
// ignored
}
_socket = null;
@@ -680,7 +692,8 @@
*
* @throws IllegalStateException if connected
*/
- protected void assertNotOpen() throws IllegalStateException {
+ protected void assertNotOpen()
+ throws IllegalStateException {
if(_open) {
throw new IllegalStateException("Connection is open");
}
@@ -691,7 +704,8 @@
*
* @throws IllegalStateException if not connected
*/
- protected void assertOpen() throws IllegalStateException {
+ protected void assertOpen()
+ throws IllegalStateException {
if(!_open) {
throw new IllegalStateException("Connection is not open");
}
@@ -699,10 +713,10 @@
// ------------------------------------------------------------- Attributes
- /** org.apache.commons.httpclient.HttpConnection log. */
- static private final Log log = LogFactory.getLog(HttpConnection.class.getName());
- /** httpclient.wire log. */
- static private final Log wireLog = LogFactory.getLog("httpclient.wire");
+ /** Log object for this class. */
+ private static final Log log = LogFactory.getLog(HttpConnection.class);
+ /** Log for any wire messages. */
+ private static final Log wireLog = LogFactory.getLog("httpclient.wire");
/** My host. */
private String _host = null;
/** My port. */
Index: java/org/apache/commons/httpclient/HttpConnectionManager.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpConnectionManager.java,v
retrieving revision 1.8
diff -u -u -r1.8 HttpConnectionManager.java
--- java/org/apache/commons/httpclient/HttpConnectionManager.java 23 Jul 2002 14:38:31 -0000 1.8
+++ java/org/apache/commons/httpclient/HttpConnectionManager.java 28 Jul 2002 17:55:20 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -79,8 +79,8 @@
public class HttpConnectionManager
{
// -------------------------------------------------------- Class Variables
- private static final Log log = LogFactory.getLog(
- HttpConnectionManager.class);
+ /** Log object for this class. */
+ private static final Log log = LogFactory.getLog(HttpConnectionManager.class);
// ----------------------------------------------------- Instance Variables
private HashMap mapHosts = new HashMap();
@@ -92,8 +92,7 @@
/**
* No-args constructor
*/
- public HttpConnectionManager()
- {
+ public HttpConnectionManager() {
}
/**
@@ -101,8 +100,7 @@
*
* @param proxyHost - the proxy host name
*/
- public void setProxyHost(String proxyHost)
- {
+ public void setProxyHost(String proxyHost) {
this.proxyHost = proxyHost;
}
@@ -111,8 +109,7 @@
*
* @return the proxy host name
*/
- public String getProxyHost()
- {
+ public String getProxyHost() {
return proxyHost;
}
@@ -121,8 +118,7 @@
*
* @param proxyPort - the proxy port number
*/
- public void setProxyPort(int proxyPort)
- {
+ public void setProxyPort(int proxyPort) {
this.proxyPort = proxyPort;
}
@@ -131,8 +127,7 @@
*
* @return the proxy port number
*/
- public int getProxyPort()
- {
+ public int getProxyPort() {
return proxyPort;
}
@@ -142,8 +137,7 @@
*
* @param maxConnections - number of connections allowed for each host:port
*/
- public void setMaxConnectionsPerHost(int maxConnections)
- {
+ public void setMaxConnectionsPerHost(int maxConnections) {
this.maxConnections = maxConnections;
}
@@ -152,8 +146,7 @@
*
* @return The maximum number of connections allowed for a given host:port.
*/
- public int getMaxConnectionsPerHost()
- {
+ public int getMaxConnectionsPerHost() {
return maxConnections;
}
@@ -168,9 +161,8 @@
* @exception java.net.MalformedURLException
* @exception org.apache.commons.HttpException - If no connection becomes availble before the timeout expires
*/
- public HttpConnection getConnection(String sURL) throws HttpException,
- MalformedURLException
- {
+ public HttpConnection getConnection(String sURL)
+ throws HttpException, MalformedURLException {
return getConnection(sURL, 0);
}
@@ -186,6 +178,8 @@
* @return the port for the specified port and protocol.
*/
private static int getPort(String protocol, int port) {
+ log.trace("HttpConnectionManager.getPort(String, port)");
+
// default to provided port
int portForProtocol = port;
if (portForProtocol == -1) {
@@ -215,8 +209,9 @@
* availble before the timeout expires
*/
public HttpConnection getConnection(String sURL, long timeout)
- throws HttpException, MalformedURLException
- {
+ throws HttpException, MalformedURLException {
+ log.trace("enter HttpConnectionManager.getConnection(String, long)");
+
// FIXME: This method is too big
if (sURL == null) {
throw new MalformedURLException("URL is null");
@@ -269,6 +264,8 @@
* @return a pool (list) of connections available for the given key
*/
private LinkedList getConnections(String hostAndPort) {
+ log.trace("enter HttpConnectionManager.getConnections(String)");
+
// Look for a list of connections for the given host:port
LinkedList listConnections = null;
synchronized (mapHosts) {
@@ -290,8 +287,10 @@
* @return the number of connections in use for the given key
*/
public Integer getConnectionsInUse(String hostAndPort) {
+ log.trace("enter HttpConnectionManager.getConnectionsInUse(String)");
// FIXME: Shouldn't this be synchronized on mapNumConnections? or
// mapHosts?
+
Integer numConnections = (Integer)mapNumConnections.get(hostAndPort);
if (numConnections == null) {
log.error("HttpConnectionManager.getConnection: "
@@ -308,6 +307,8 @@
*/
private HttpConnection waitForConnection(LinkedList pool, long timeout)
throws HttpException {
+ log.trace("enter HttpConnectionManager.waitForConnection(LinkedList, long)");
+
// No connections available, so wait
// Start the timeout thread
TimeoutThread threadTimeout = new TimeoutThread();
@@ -340,8 +341,9 @@
*
* @param conn - The HttpConnection to make available.
*/
- public void releaseConnection(HttpConnection conn)
- {
+ public void releaseConnection(HttpConnection conn) {
+ log.trace("enter HttpConnectionManager.releaseConnection(HttpConnection)");
+
String host = conn.getHost();
int port = conn.getPort();
String key = host + ":" + port;
@@ -377,8 +379,8 @@
* an outside mechanism to interrupt the waiting thread after the specified
* timeout interval.
*/
- private static class TimeoutThread extends Thread
- {
+ private static class TimeoutThread extends Thread {
+
private long timeout = 0;
private Thread thrdWakeup = null;
@@ -402,8 +404,8 @@
return thrdWakeup;
}
- public void run()
- {
+ public void run() {
+ log.trace("TimeoutThread.run()");
if(timeout == 0){
return;
}
@@ -415,6 +417,7 @@
sleep(timeout);
thrdWakeup.interrupt();
}catch(InterruptedException e){
+ log.debug("InterruptedException caught as expected");
// This is expected
}
}
Index: java/org/apache/commons/httpclient/HttpException.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpException.java,v
retrieving revision 1.5
diff -u -u -r1.5 HttpException.java
--- java/org/apache/commons/httpclient/HttpException.java 5 Jan 2002 11:16:00 -0000 1.5
+++ java/org/apache/commons/httpclient/HttpException.java 28 Jul 2002 17:55:20 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
Index: java/org/apache/commons/httpclient/HttpMethod.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
retrieving revision 1.13
diff -u -u -r1.13 HttpMethod.java
--- java/org/apache/commons/httpclient/HttpMethod.java 21 Jul 2002 04:12:45 -0000 1.13
+++ java/org/apache/commons/httpclient/HttpMethod.java 28 Jul 2002 17:55:21 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
Index: java/org/apache/commons/httpclient/HttpMethodBase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.37
diff -u -u -r1.37 HttpMethodBase.java
--- java/org/apache/commons/httpclient/HttpMethodBase.java 28 Jul 2002 06:24:51 -0000 1.37
+++ java/org/apache/commons/httpclient/HttpMethodBase.java 28 Jul 2002 17:55:25 -0000
@@ -6,7 +6,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -170,8 +170,7 @@
* NOTE: StrictMode is currently experimental and its functionlaity may change in the future.
*
*/
- public void setStrictMode(boolean strictMode)
- {
+ public void setStrictMode(boolean strictMode) {
this.strictMode = strictMode;
}
@@ -182,8 +181,7 @@
*
* @return true if strict mode is enabled.
*/
- public boolean isStrictMode()
- {
+ public boolean isStrictMode() {
return strictMode;
}
@@ -249,7 +247,7 @@
// semantics of the message, by appending each subsequent field-value
// to the first, each separated by a comma."
// - HTTP/1.0 (4.3)
- log.debug("HttpMethodBase.addRequestHeader(Header)");
+ log.trace("HttpMethodBase.addRequestHeader(Header)");
if (header == null){
log.debug("null header value ignored");
@@ -316,6 +314,8 @@
* to add as query string parameterss
*/
public void setQueryString(NameValuePair[] params) {
+ log.trace("enter HttpMethodBase.setQueryString(NameValuePair[])");
+
StringBuffer buf = new StringBuffer();
boolean needAmp = false;
for(int i=0;i
* A container for HTTP attributes that may persist from request
@@ -97,6 +100,11 @@
*/
private ArrayList cookies = new ArrayList();
+ // -------------------------------------------------------- Class Variables
+
+ /** Log object for this class. */
+ public static final Log log = LogFactory.getLog(HttpState.class);
+
// ------------------------------------------------------------- Properties
/**
@@ -106,6 +114,8 @@
* @param cookie the {@link Cookie} to add
*/
public void addCookie(Cookie cookie) {
+ log.trace("enter HttpState.addCookie(Cookie)");
+
if (cookie != null) {
// first remove any old cookie that is equivalent
for (Iterator it = cookies.iterator();it.hasNext(); ) {
@@ -128,6 +138,8 @@
* @param newcookies the {@link Cookie}s to add
*/
public void addCookies(Cookie[] newcookies) {
+ log.trace("enter HttpState.addCookies(Cookie[])");
+
if (newcookies != null) {
for (int i = 0; i < newcookies.length; i++) {
this.addCookie(newcookies[i]);
@@ -140,6 +152,7 @@
* @return an array of my {@link Cookie}s.
*/
public Cookie[] getCookies() {
+ log.trace("enter HttpState.getCookies()");
return (Cookie[])(cookies.toArray(new Cookie[cookies.size()]));
}
@@ -155,6 +168,8 @@
* @see Cookie#matches
*/
public Cookie[] getCookies(String domain, int port, String path, boolean secure, Date now) {
+ log.trace("enter HttpState.getCookies(String, int, String, boolean, Date)");
+
ArrayList list = new ArrayList(cookies.size());
for(int i=0,m=cookies.size();i
{@link InputStream} wrapper supporting the chunked transfer encoding.
* @@ -78,6 +80,15 @@ */ public class ResponseInputStream extends InputStream { + // -------------------------------------------------------- Class Variables + + /** Log object for this class. */ + public static final Log log = LogFactory.getLog(ResponseInputStream.class); + + /** Log for wire messages. */ + public static final Log wireLog = LogFactory.getLog("httpclient.wire"); + + // ----------------------------------------------------------- Constructors /** @@ -88,6 +99,8 @@ * */ public ResponseInputStream(InputStream stream, boolean chunked, int contentLength) { + log.trace("enter ResponseInputStream(InputStream, boolean, int)"); + if (null == stream) { throw new NullPointerException("InputStream parameter is null"); } @@ -107,6 +120,7 @@ */ public ResponseInputStream(InputStream stream, HttpMethod method) { super(); + log.trace("enter ResponseInputStream(InputStream, HttpMethod)"); if (null == stream) { throw new NullPointerException("InputStream parameter is null"); @@ -198,15 +212,16 @@ * If a content length has been set but not all of the bytes have yet been * consumed, the remaining bytes will be swallowed. */ - public void close() - throws IOException { -/* + public void close() throws IOException { + log.trace("enter ResponseInputStream.close()"); + /* // Xerces appears to doubly-close the input stream... if(closed) { throw new IOException("Stream is already closed"); } -*/ + */ + //TODO: This close code is not very robust if (!closed) { try { if (chunk) { @@ -248,7 +263,9 @@ * * @exception IOException if an input/output error occurs */ - public int read(byte b[], int off, int len) throws IOException { + public int read(byte b[], int off, int len) + throws IOException { + log.trace("enter ResponseInputStream.read(byte, int, int)"); int avail = length - pos; if ((avail == 0) && (!fillBuffer())) @@ -269,7 +286,6 @@ System.arraycopy(buffer, pos, b, off, toCopy); pos += toCopy; return toCopy; - } /** @@ -279,7 +295,8 @@ * @exception IOException if an input/output error occurs */ public int read() - throws IOException { + throws IOException { + log.trace("enter ResponseInputStream.read()"); if (pos == length) { if (!fillBuffer()) @@ -297,6 +314,7 @@ * Fill the chunk buffer. */ private boolean fillBuffer() throws IOException { + log.trace("enter ResponseInputStream.fillBuffer()"); // Has this stream been closed? if (closed) @@ -400,8 +418,10 @@ * @exception IOException if an input or output exception has occurred */ private String readLineFromStream() - throws IOException { + throws IOException { + log.trace("enter ResponseInputStream.ReadLineFromStream()"); + //TODO: Reformat this code StringBuffer sb = new StringBuffer(); while (true) { int ch = stream.read(); Index: java/org/apache/commons/httpclient/URIUtil.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/URIUtil.java,v retrieving revision 1.8 diff -u -u -r1.8 URIUtil.java --- java/org/apache/commons/httpclient/URIUtil.java 22 Jul 2002 15:35:12 -0000 1.8 +++ java/org/apache/commons/httpclient/URIUtil.java 28 Jul 2002 17:55:33 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without Index: java/org/apache/commons/httpclient/UsernamePasswordCredentials.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/UsernamePasswordCredentials.java,v retrieving revision 1.4 diff -u -u -r1.4 UsernamePasswordCredentials.java --- java/org/apache/commons/httpclient/UsernamePasswordCredentials.java 5 Jan 2002 11:16:00 -0000 1.4 +++ java/org/apache/commons/httpclient/UsernamePasswordCredentials.java 28 Jul 2002 17:55:33 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without Index: java/org/apache/commons/httpclient/methods/DeleteMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/DeleteMethod.java,v retrieving revision 1.5 diff -u -u -r1.5 DeleteMethod.java --- java/org/apache/commons/httpclient/methods/DeleteMethod.java 21 Jul 2002 04:12:46 -0000 1.5 +++ java/org/apache/commons/httpclient/methods/DeleteMethod.java 28 Jul 2002 17:55:34 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without Index: java/org/apache/commons/httpclient/methods/GetMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/GetMethod.java,v retrieving revision 1.12 diff -u -u -r1.12 GetMethod.java --- java/org/apache/commons/httpclient/methods/GetMethod.java 23 Jul 2002 14:38:31 -0000 1.12 +++ java/org/apache/commons/httpclient/methods/GetMethod.java 28 Jul 2002 17:55:34 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,10 +91,10 @@ // -------------------------------------------------------------- Constants - /** org.apache.commons.httpclient.methods.GetMethod log. */ - private static final Log log = LogFactory.getLog(GetMethod.class.getName()); + /** Log object for this class. */ + private static final Log log = LogFactory.getLog(GetMethod.class); - /** httpclient.wire log. */ + /** Log for any wire messages. */ private static final Log wireLog = LogFactory.getLog("httpclient.wire"); /** Temporary directory. */ @@ -117,6 +117,7 @@ */ public GetMethod(String path) { super(path); + log.trace("enter GetMethod(String)"); setFollowRedirects(true); } @@ -128,6 +129,7 @@ */ public GetMethod(String path, String tempDir) { super(path); + log.trace("enter GetMethod(String, String)"); setUseDisk(true); setTempDir(tempDir); setFollowRedirects(true); @@ -141,6 +143,7 @@ */ public GetMethod(String path, String tempDir, String tempFile) { super(path); + log.trace("enter GetMethod(String, String, String)"); setUseDisk(true); setTempDir(tempDir); setTempFile(tempFile); @@ -154,6 +157,7 @@ */ public GetMethod(String path, File fileData) { this(path); + log.trace("enter GetMethod(String, File)"); useDisk = true; this.fileData = fileData; setFollowRedirects(true); @@ -285,6 +289,8 @@ // override recycle to reset redirects default public void recycle() { + log.trace("enter GetMethod.recycle()"); + super.recycle(); this.memoryData = null; this.fileData = null; @@ -297,6 +303,8 @@ * Otherwise return null. */ public byte[] getResponseBody() { + log.trace("enter GetMethod.getResponseBody()"); + checkUsed(); if(useDisk) { try { @@ -327,6 +335,8 @@ * Otherwise return null. */ public String getResponseBodyAsString() { + log.trace("enter GetMethod.getResponseBodyAsString()"); + byte[] data = getResponseBody(); if(null == data) { return null; @@ -341,7 +351,10 @@ * as an {@link InputStream}. * Otherwise return null. */ - public InputStream getResponseBodyAsStream() throws IOException { + public InputStream getResponseBodyAsStream() + throws IOException { + log.trace("enter GetMethod.getResponseBodyAsStream()"); + checkUsed(); if (useDisk) { return new FileInputStream(fileData); @@ -361,8 +374,10 @@ * Overrides method in {@link HttpMethodBase} to * write data to the appropriate buffer. */ - protected void readResponseBody(HttpState state, HttpConnection conn) throws IOException { - log.debug("GetMethod.readResponseBody(HttpState,HttpConnection)"); + protected void readResponseBody(HttpState state, HttpConnection conn) + throws IOException { + log.trace("enter GetMethod.readResponseBody(HttpState, HttpConnection)"); + OutputStream out = null; if (useDisk) { if (fileData == null) { Index: java/org/apache/commons/httpclient/methods/HeadMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/HeadMethod.java,v retrieving revision 1.8 diff -u -u -r1.8 HeadMethod.java --- java/org/apache/commons/httpclient/methods/HeadMethod.java 21 Jul 2002 04:12:46 -0000 1.8 +++ java/org/apache/commons/httpclient/methods/HeadMethod.java 28 Jul 2002 17:55:35 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,6 +66,7 @@ import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.HttpState; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -128,14 +129,15 @@ * presence of a Content-Length or * Transfer-Encoding header. */ - protected void readResponseBody(HttpState state, HttpConnection conn) throws IOException, HttpException { - log.debug("HeadMethod.readResponseBody(HttpState,HttpConnection)"); + protected void readResponseBody(HttpState state, HttpConnection conn) + throws IOException, HttpException { + log.trace("enter HeadMethod.readResponseBody(HttpState, HttpConnection)"); return; // despite the possible presence of a content-length header, HEAD returns no response body } - // -------------------------------------------------------------- Constants + // -------------------------------------------------------------- Class Variables - /** org.apache.commons.httpclient.methods.HeadMethod log. */ - private static final Log log = LogFactory.getLog(HeadMethod.class.getName()); + /** Log object for this class. */ + private static final Log log = LogFactory.getLog(HeadMethod.class); } Index: java/org/apache/commons/httpclient/methods/OptionsMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/OptionsMethod.java,v retrieving revision 1.6 diff -u -u -r1.6 OptionsMethod.java --- java/org/apache/commons/httpclient/methods/OptionsMethod.java 21 Jul 2002 04:12:46 -0000 1.6 +++ java/org/apache/commons/httpclient/methods/OptionsMethod.java 28 Jul 2002 17:55:35 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -67,6 +67,8 @@ import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.HttpState; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; import java.util.Enumeration; import java.util.StringTokenizer; import java.util.Vector; @@ -81,8 +83,10 @@ extends HttpMethodBase { - // -------------------------------------------------------------- Constants + // --------------------------------------------------------- Class Variables + /** Log object for this class. */ + private static final Log log = LogFactory.getLog(OptionsMethod.class); // ----------------------------------------------------------- Constructors @@ -139,6 +143,8 @@ // ----------------------------------------------------- HttpMethod Methods protected void processResponseHeaders(HttpState state, HttpConnection conn) { + log.trace("enter OptionsMethod.processResponseHeaders(HttpState, HttpConnection)"); + Header allowHeader = getResponseHeader("allow"); if (allowHeader != null) { String allowHeaderValue = allowHeader.getValue(); Index: java/org/apache/commons/httpclient/methods/PostMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v retrieving revision 1.14 diff -u -u -r1.14 PostMethod.java --- java/org/apache/commons/httpclient/methods/PostMethod.java 24 Jul 2002 03:00:11 -0000 1.14 +++ java/org/apache/commons/httpclient/methods/PostMethod.java 28 Jul 2002 17:55:37 -0000 @@ -184,6 +184,7 @@ * to clear my request body. */ public void recycle() { + log.trace("enter PostMethod.recycle()"); super.recycle(); requestBody = null; requestContentLength = CONTENT_LENGTH_AUTO; @@ -199,6 +200,8 @@ * @deprecated use #removeParameter followed by #setParameter */ public void setParameter(String parameterName, String parameterValue) { + log.trace("enter PostMethod.setParameter(String, String)"); + if(null != requestBody) { throw new IllegalStateException("Request body already generated."); } @@ -224,6 +227,8 @@ * */ public void setRequestContentLength(int length) { + log.trace("enter PostMethod.setRequestContentLength(int)"); + if ((length == CONTENT_LENGTH_CHUNKED) && !isHttp11()) { throw new RuntimeException("Chunked transfer encoding not allowed for HTTP/1.0"); } @@ -239,6 +244,8 @@ * @throws IllegalArgumentException if either argument is null */ public void addParameter(String paramName, String paramValue) { + log.trace("enter PostMethod.addParameter(String, String)"); + if(null != requestBody) { throw new IllegalStateException("Request body already generated."); } @@ -260,6 +267,8 @@ * @since 2.0 */ public void addParameter(NameValuePair param) { + log.trace("enter PostMethod.addParameter(NameValuePair)"); + if(null != requestBody) { throw new IllegalStateException("Request body already generated."); } @@ -280,6 +289,8 @@ * @since 2.0 */ public void addParameters(NameValuePair[] parameters) { + log.trace("enter PostMethod.addParameters(NameValuePair[])"); + if(null != requestBody) { throw new IllegalStateException("Request body already generated."); } @@ -304,6 +315,8 @@ * @since 2.0 */ public NameValuePair getParameter(String paramName){ + log.trace("enter PostMethod.getParameter(String)"); + if (paramName == null){ return null; } @@ -331,6 +344,8 @@ * @since 2.0 */ public NameValuePair[] getParameters(){ + log.trace("enter PostMethod.getParameters()"); + int numPairs = parameters.size(); Object[] objectArr= parameters.toArray(); NameValuePair[] nvPairArr = new NameValuePair[numPairs]; @@ -351,6 +366,8 @@ * @throws IllegalStateException if my request body has already been generated. */ public boolean removeParameter(String paramName) { + log.trace("enter PostMethod.removeParameter(String)"); + if(null != requestBody) { throw new IllegalStateException("Request body already generated."); } @@ -380,6 +397,8 @@ * @throws IllegalStateException if my request body has already been generated. */ public boolean removeParameter(String paramName, String paramValue) { + log.trace("enter PostMethod.removeParameter(String, String)"); + if(null != requestBody) { throw new IllegalStateException("Request body already generated."); } @@ -408,6 +427,8 @@ * encoding. Use setRequestBody(InputStream) instead. */ public void setRequestBody(String body) { + log.trace("enter PostMethod.setRequestBody(String)"); + if(!parameters.isEmpty()) { throw new IllegalStateException("Request parameters have already been added."); } @@ -415,6 +436,8 @@ } public void setRequestBody(InputStream body) { + log.trace("enter PostMethod.getRequestBody(InputStream)"); + if(!parameters.isEmpty()) { throw new IllegalStateException("Request parameters have already been added."); } @@ -429,6 +452,8 @@ * @since 2.0 */ public InputStream getRequestBody() { + log.trace("enter PostMethod.getRequestBody()"); + if (requestBody != null) { return requestBody; } else if (!parameters.isEmpty()) { @@ -442,6 +467,8 @@ *@return the request body as a string */ public String getRequestBodyAsString() throws IOException{ + log.trace("enter PostMethod.getRequestBodyAsString()"); + StringBuffer buffer = new StringBuffer(); InputStream requestBody = getRequestBody(); int data = requestBody.read(); @@ -454,10 +481,12 @@ /** - * Override method of {@link org.apache.commons.httpclient.HttpMethodBase} to also add Content-Type header + * Override method of {@link org.apache.commons.httpclient.HttpMethodBase} to + * also add Content-Type header * when appropriate. */ - protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException { + protected void addRequestHeaders(HttpState state, HttpConnection conn) + throws IOException, HttpException { super.addRequestHeaders(state,conn); if(!parameters.isEmpty()) { //there are some parameters, so set the contentType header setRequestHeader(CONTENT_TYPE); @@ -476,8 +505,10 @@ * * @return always returns true */ - protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException { - log.debug("PostMethod.writeRequestBody(HttpState,HttpConnection)"); + protected boolean writeRequestBody(HttpState state, HttpConnection conn) + throws IOException, HttpException { + log.trace("enter PostMethod.writeRequestBody(HttpState, HttpConnection)"); + if(null == requestBody) { requestBody = generateRequestBody(parameters); } @@ -516,6 +547,8 @@ @return number of bytes in the request body */ protected int getRequestContentLength() { + log.trace("enter PostMethod.getRequestContentLength()"); + if(null == requestBody) { requestBody = generateRequestBody(parameters); bufferContent(); @@ -535,6 +568,8 @@ * If the method was called earlier it returns immediately. */ private void bufferContent() { + log.trace("enter PostMethod.bufferContent()"); + if (buffer != null) return; try { buffer = new ByteArrayOutputStream(); @@ -563,6 +598,8 @@ * @return urlencoded string */ static InputStream generateRequestBody(List params) { + log.trace("enter PostMethod.generateRequestBody(List)"); + Iterator it = params.iterator(); StringBuffer sb = new StringBuffer(); while(it.hasNext()) { @@ -588,8 +625,8 @@ // -------------------------------------------------------------- Constants - /** org.apache.commons.httpclient.methods.PostMethod log. */ - private static final Log log = LogFactory.getLog(PostMethod.class.getName()); + /** Log object for this class. */ + private static final Log log = LogFactory.getLog(PostMethod.class); /** The Content-Type header for www-form-urlcoded. */ static final Header CONTENT_TYPE = new Header ("Content-Type","application/x-www-form-urlencoded"); Index: java/org/apache/commons/httpclient/methods/PutMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v retrieving revision 1.11 diff -u -u -r1.11 PutMethod.java --- java/org/apache/commons/httpclient/methods/PutMethod.java 23 Jul 2002 14:38:31 -0000 1.11 +++ java/org/apache/commons/httpclient/methods/PutMethod.java 28 Jul 2002 17:55:38 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,8 +85,7 @@ * * @author Remy Maucherat */ -public class PutMethod - extends HttpMethodBase { +public class PutMethod extends HttpMethodBase { // ----------------------------------------------------------- Constructors @@ -179,7 +178,10 @@ * memory. To upload large entities, it is recommended to first buffer the * data into a temporary file, and then send that file. */ - public void setRequestBody(InputStream is) throws IOException { + public void setRequestBody(InputStream is) + throws IOException { + log.trace("enter PutMethod.setRequestBody(InputStream)"); + checkNotUsed(); byte[] buffer = new byte[4096]; ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -203,7 +205,10 @@ * not already been set, in addition to the "standard" * set of headers. */ - protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException { + protected void addRequestHeaders(HttpState state, HttpConnection conn) + throws IOException, HttpException { + log.trace("enter PutMethod.addRequestHeaders(HttpState, HttpConnection)"); + super.addRequestHeaders(state,conn); // Send expectation header if(isHttp11() && null == getRequestHeader("expect")) { @@ -217,7 +222,10 @@ * the 100 Continue status has not be * read. */ - protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException { + protected boolean writeRequestBody(HttpState state, HttpConnection conn) + throws IOException, HttpException { + log.trace("enter PutMethod.writeRequestBody(HttpState, HttpConnection)"); + if(null != getRequestHeader("expect") && getStatusCode() != HttpStatus.SC_CONTINUE) { return false; } @@ -253,6 +261,8 @@ * to return the appropriate content length. */ protected int getRequestContentLength() { + log.trace("enter PutMethod.getRequestContentLength()"); + if(null != data) { return data.length; } else if(null != file && file.exists()) { @@ -273,6 +283,6 @@ file = null; } - /** org.apache.commons.httpclient.methods.PutMethod log. */ - private static final Log log = LogFactory.getLog(PutMethod.class.getName()); + /** Log object for this class. */ + private static final Log log = LogFactory.getLog(PutMethod.class); } Index: java/org/apache/commons/httpclient/methods/UrlDeleteMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlDeleteMethod.java,v retrieving revision 1.5 diff -u -u -r1.5 UrlDeleteMethod.java --- java/org/apache/commons/httpclient/methods/UrlDeleteMethod.java 21 Jul 2002 04:12:46 -0000 1.5 +++ java/org/apache/commons/httpclient/methods/UrlDeleteMethod.java 28 Jul 2002 17:55:38 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,6 +74,7 @@ */ public class UrlDeleteMethod extends DeleteMethod implements HttpUrlMethod { + // ----------------------------------------------------- Instance Variables private String url; @@ -101,8 +102,7 @@ * * @param url - the URL for this request. */ - public void setUrl(String url) throws MalformedURLException - { + public void setUrl(String url) throws MalformedURLException { setPath(URIUtil.getPath(url)); this.url = url; String query = URIUtil.getQueryString(url); @@ -112,10 +112,9 @@ } /** - * + * Gets the Url. */ - public String getUrl() - { + public String getUrl() { return url; } Index: java/org/apache/commons/httpclient/methods/UrlGetMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlGetMethod.java,v retrieving revision 1.5 diff -u -u -r1.5 UrlGetMethod.java --- java/org/apache/commons/httpclient/methods/UrlGetMethod.java 21 Jul 2002 04:12:46 -0000 1.5 +++ java/org/apache/commons/httpclient/methods/UrlGetMethod.java 28 Jul 2002 17:55:38 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without Index: java/org/apache/commons/httpclient/methods/UrlHeadMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlHeadMethod.java,v retrieving revision 1.5 diff -u -u -r1.5 UrlHeadMethod.java --- java/org/apache/commons/httpclient/methods/UrlHeadMethod.java 21 Jul 2002 04:12:46 -0000 1.5 +++ java/org/apache/commons/httpclient/methods/UrlHeadMethod.java 28 Jul 2002 17:55:39 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without Index: java/org/apache/commons/httpclient/methods/UrlOptionsMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlOptionsMethod.java,v retrieving revision 1.5 diff -u -u -r1.5 UrlOptionsMethod.java --- java/org/apache/commons/httpclient/methods/UrlOptionsMethod.java 21 Jul 2002 04:12:46 -0000 1.5 +++ java/org/apache/commons/httpclient/methods/UrlOptionsMethod.java 28 Jul 2002 17:55:39 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without Index: java/org/apache/commons/httpclient/methods/UrlPostMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlPostMethod.java,v retrieving revision 1.5 diff -u -u -r1.5 UrlPostMethod.java --- java/org/apache/commons/httpclient/methods/UrlPostMethod.java 21 Jul 2002 04:12:46 -0000 1.5 +++ java/org/apache/commons/httpclient/methods/UrlPostMethod.java 28 Jul 2002 17:55:39 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without Index: java/org/apache/commons/httpclient/methods/UrlPutMethod.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/UrlPutMethod.java,v retrieving revision 1.5 diff -u -u -r1.5 UrlPutMethod.java --- java/org/apache/commons/httpclient/methods/UrlPutMethod.java 21 Jul 2002 04:12:46 -0000 1.5 +++ java/org/apache/commons/httpclient/methods/UrlPutMethod.java 28 Jul 2002 17:55:40 -0000 @@ -6,7 +6,7 @@ * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without