rwaldhoff 01/07/27 15:53:53
Modified: httpclient/src/java/org/apache/commons/httpclient
Base64.java HeaderElement.java HttpClient.java
NameValuePair.java ResponseInputStream.java
Added: httpclient/src/conf .cvsignore log4j.properties.sample
Log:
converted to log4j for logging
Revision Changes Path
1.1 jakarta-commons/httpclient/src/conf/.cvsignore
Index: .cvsignore
===================================================================
log4j.properties
1.1 jakarta-commons/httpclient/src/conf/log4j.properties.sample
Index: log4j.properties.sample
===================================================================
######################################
# Configure the log4j logging system
######################################
# Set the root output level and appenders
log4j.rootCategory=INFO, consoleAppender
#log4j.category.org.apache.commons.httpclient.Base64=DEBUG
#log4j.category.org.apache.commons.httpclient.HeaderElement=DEBUG
#log4j.category.org.apache.commons.httpclient.HttpClient=DEBUG
# Create an appender that prints to the console
log4j.appender.consoleAppender=org.apache.log4j.FileAppender
log4j.appender.consoleAppender.File=System.out
log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.consoleAppender.layout.ConversionPattern=%-5p [%t] %c - %m: %d{DATE}\n
1.2 +43 -53
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java
Index: Base64.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Base64.java 2001/04/25 18:42:50 1.1
+++ Base64.java 2001/07/27 22:53:53 1.2
@@ -1,13 +1,13 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java,v
1.1 2001/04/25 18:42:50 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2001/04/25 18:42:50 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java,v
1.2 2001/07/27 22:53:53 rwaldhoff Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/07/27 22:53:53 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
@@ -59,26 +59,27 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.commons.httpclient;
+import org.apache.log4j.Category;
/**
* This class provides encode/decode for RFC 2045 Base64 as
- * defined by RFC 2045, N. Freed and N. Borenstein.
+ * defined by RFC 2045, N. Freed and N. Borenstein.
* RFC 2045: Multipurpose Internet Mail Extensions (MIME)
* Part One: Format of Internet Message Bodies. Reference
- * 1996 Available at: http://www.ietf.org/rfc/rfc2045.txt
+ * 1996 Available at: http://www.ietf.org/rfc/rfc2045.txt
* This class is used by XML Schema binary format validation
*
* @author Jeffrey Rodriguez
- * @version $Id: Base64.java,v 1.1 2001/04/25 18:42:50 remm Exp $
+ * @version $Id: Base64.java,v 1.2 2001/07/27 22:53:53 rwaldhoff Exp $
*/
public final class Base64 {
- static private final int BASELENGTH = 255;
+ static private final int BASELENGTH = 255;
static private final int LOOKUPLENGTH = 64;
static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
@@ -87,15 +88,14 @@
static private final int FOURBYTE = 4;
static private final int SIGN = -128;
static private final byte PAD = ( byte ) '=';
- static private final boolean fDebug = false;
- static private byte [] base64Alphabet = new byte[BASELENGTH];
+ static private byte [] base64Alphabet = new byte[BASELENGTH];
static private byte [] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
-
+ static private final Category log =
Category.getInstance("org.apache.commons.httpclient.Base64");
static {
for (int i = 0; i<BASELENGTH; i++ ) {
- base64Alphabet[i] = -1;
+ base64Alphabet[i] = -1;
}
for ( int i = 'Z'; i >= 'A'; i-- ) {
base64Alphabet[i] = (byte) (i-'A');
@@ -108,7 +108,7 @@
base64Alphabet[i] = (byte) (i-'0' + 52);
}
- base64Alphabet['+'] = 62;
+ base64Alphabet['+'] = 62;
base64Alphabet['/'] = 63;
for (int i = 0; i<=25; i++ )
@@ -131,7 +131,7 @@
public static boolean isBase64( byte octect ) {
//shall we ignore white space? JEFF??
- return(octect == PAD || base64Alphabet[octect] != -1 );
+ return(octect == PAD || base64Alphabet[octect] != -1 );
}
@@ -148,13 +148,13 @@
/**
* Encodes hex octects into Base64
- *
+ *
* @param binaryData Array containing binaryData
* @return Encoded Base64 array
*/
public static byte[] encode( byte[] binaryData ) {
int lengthDataBits = binaryData.length*EIGHTBIT;
- int fewerThan24bits = lengthDataBits%TWENTYFOURBITGROUP;
+ int fewerThan24bits = lengthDataBits%TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits/TWENTYFOURBITGROUP;
byte encodedData[] = null;
@@ -169,19 +169,15 @@
int encodedIndex = 0;
int dataIndex = 0;
int i = 0;
- if (fDebug ) {
- System.out.println("number of triplets = " + numberTriplets );
- }
+ log.debug("number of triplets = " + numberTriplets);
for ( i = 0; i<numberTriplets; i++ ) {
dataIndex = i*3;
- b1 = binaryData[dataIndex];
+ b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
b3 = binaryData[dataIndex + 2];
- if (fDebug) {
- System.out.println( "b1= " + b1 +", b2= " + b2 + ", b3= " + b3 );
- }
+ log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3);
l = (byte)(b2 & 0x0f);
k = (byte)(b1 & 0x03);
@@ -189,18 +185,15 @@
encodedIndex = i*4;
byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
- byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);
+ byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);
byte val3 = ((b3 & SIGN)==0)?(byte)(b3>>6):(byte)((b3)>>6^0xfc);
- encodedData[encodedIndex] = lookUpBase64Alphabet[ val1 ];
- if (fDebug) {
- System.out.println( "val2 = " + val2 );
- System.out.println( "k4 = " + (k<<4));
- System.out.println( "vak = " + (val2 | (k<<4)));
- }
-
+ encodedData[encodedIndex] = lookUpBase64Alphabet[ val1 ];
+ log.debug( "val2 = " + val2 );
+ log.debug( "k4 = " + (k<<4) );
+ log.debug( "vak = " + (val2 | (k<<4)) );
encodedData[encodedIndex+1] = lookUpBase64Alphabet[ val2 | ( k<<4 )];
- encodedData[encodedIndex+2] = lookUpBase64Alphabet[ (l <<2 ) | val3 ];
+ encodedData[encodedIndex+2] = lookUpBase64Alphabet[ (l <<2 ) | val3 ];
encodedData[encodedIndex+3] = lookUpBase64Alphabet[ b3 & 0x3f ];
}
@@ -210,13 +203,11 @@
if (fewerThan24bits == EIGHTBIT ) {
b1 = binaryData[dataIndex];
k = (byte) ( b1 &0x03 );
- if (fDebug ) {
- System.out.println("b1=" + b1);
- System.out.println("b1<<2 = " + (b1>>2) );
- }
+ log.debug("b1=" + b1);
+ log.debug("b1<<2 = " + (b1>>2) );
byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
encodedData[encodedIndex] = lookUpBase64Alphabet[ val1 ];
- encodedData[encodedIndex + 1] = lookUpBase64Alphabet[ k<<4 ];
+ encodedData[encodedIndex + 1] = lookUpBase64Alphabet[ k<<4 ];
encodedData[encodedIndex + 2] = PAD;
encodedData[encodedIndex + 3] = PAD;
} else if ( fewerThan24bits == SIXTEENBIT ) {
@@ -227,11 +218,11 @@
k = ( byte ) ( b1 &0x03 );
byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
- byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);
+ byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);
encodedData[encodedIndex] = lookUpBase64Alphabet[ val1 ];
encodedData[encodedIndex + 1] = lookUpBase64Alphabet[ val2 | ( k<<4 )];
- encodedData[encodedIndex + 2] = lookUpBase64Alphabet[ l<<2 ];
+ encodedData[encodedIndex + 2] = lookUpBase64Alphabet[ l<<2 ];
encodedData[encodedIndex + 3] = PAD;
}
return encodedData;
@@ -240,7 +231,7 @@
/**
* Decodes Base64 data into octects
- *
+ *
* @param binaryData Byte array containing Base64 data
* @return Array containind decoded data.
*/
@@ -258,10 +249,10 @@
for (int i = 0; i<numberQuadruple; i++ ) {
dataIndex = i*4;
- marker0 = base64Data[dataIndex +2];
- marker1 = base64Data[dataIndex +3];
+ marker0 = base64Data[dataIndex +2];
+ marker1 = base64Data[dataIndex +3];
- b1 = base64Alphabet[base64Data[dataIndex]];
+ b1 = base64Alphabet[base64Data[dataIndex]];
b2 = base64Alphabet[base64Data[dataIndex +1]];
if ( marker0 != PAD && marker1 != PAD ) { //No PAD e.g 3cQl
@@ -270,17 +261,17 @@
decodedData[encodedIndex] = (byte)( b1 <<2 | b2>>4 ) ;
decodedData[encodedIndex+1] = (byte)(((b2 & 0xf)<<4 ) |( (b3>>2) &
0xf) );
- decodedData[encodedIndex+2] = (byte)( b3<<6 | b4 );
+ decodedData[encodedIndex+2] = (byte)( b3<<6 | b4 );
} else if ( marker0 == PAD ) { //Two PAD e.g. 3c[Pad][Pad]
- decodedData[encodedIndex] = (byte)( b1 <<2 | b2>>4 ) ;
- decodedData[encodedIndex+1] = (byte)((b2 & 0xf)<<4 );
- decodedData[encodedIndex+2] = (byte) 0;
+ decodedData[encodedIndex] = (byte)( b1 <<2 | b2>>4 ) ;
+ decodedData[encodedIndex+1] = (byte)((b2 & 0xf)<<4 );
+ decodedData[encodedIndex+2] = (byte) 0;
} else if ( marker1 == PAD ) { //One PAD e.g. 3cQ[Pad]
b3 = base64Alphabet[ marker0 ];
decodedData[encodedIndex] = (byte)( b1 <<2 | b2>>4 );
decodedData[encodedIndex+1] = (byte)(((b2 & 0xf)<<4 ) |( (b3>>2) &
0xf) );
- decodedData[encodedIndex+2] = (byte)( b3<<6);
+ decodedData[encodedIndex+2] = (byte)( b3<<6);
}
encodedIndex += 3;
}
@@ -288,4 +279,3 @@
}
}
-
1.2 +4 -2
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HeaderElement.java
Index: HeaderElement.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HeaderElement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HeaderElement.java 2001/04/25 18:42:50 1.1
+++ HeaderElement.java 2001/07/27 22:53:53 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HeaderElement.java,v
1.1 2001/04/25 18:42:50 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2001/04/25 18:42:50 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HeaderElement.java,v
1.2 2001/07/27 22:53:53 rwaldhoff Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/07/27 22:53:53 $
*
* ====================================================================
*
@@ -67,6 +67,7 @@
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.Vector;
+import org.apache.log4j.Category;
/**
* Some HTTP headers (such as the set-cookie header) have values that
@@ -130,6 +131,7 @@
}
// -------------------------------------------------------- Class Variables
+ static private final Category log =
Category.getInstance("org.apache.commons.httpclient.HeaderElement");
private static final BitSet SEPARATORS = new BitSet(128);
private static final BitSet TOKEN_CHAR = new BitSet(128);
1.21 +38 -67
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
Index: HttpClient.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- HttpClient.java 2001/07/26 15:51:53 1.20
+++ HttpClient.java 2001/07/27 22:53:53 1.21
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
1.20 2001/07/26 15:51:53 morgand Exp $
- * $Revision: 1.20 $
- * $Date: 2001/07/26 15:51:53 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
1.21 2001/07/27 22:53:53 rwaldhoff Exp $
+ * $Revision: 1.21 $
+ * $Date: 2001/07/27 22:53:53 $
*
* ====================================================================
*
@@ -76,6 +76,7 @@
import java.lang.reflect.Method;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
+import org.apache.log4j.Category;
/**
* HTTP client main class.
@@ -91,7 +92,7 @@
* in your JRE's <tt>java.security</tt> file) and with the
* VM that is running the HttpClient (e.g., set the
* system property <tt>java.protocol.handler.pkgs</tt>
- * to include your provider, such as
+ * to include your provider, such as
* <tt>com.sun.net.ssl.internal.www.protocol</tt>
* for the reference implementation of JSSE).
*
@@ -103,6 +104,7 @@
// -------------------------------------------------------------- Constants
+ static private final Category log =
Category.getInstance("org.apache.commons.httpclient.HttpClient");
/**
* HTTP Date format pattern (RFC 2068, 822, 1123).
@@ -559,7 +561,7 @@
// Consume bytes returned (if any)
method.processResponseHeaders(responseHeaders);
ResponseInputStream responseInputStream =
- new ResponseInputStream(input, method,
+ new ResponseInputStream(input, method,
responseHeaders);
// FIXME : Really set the interceptors here ?
// The content is meant to be discarded
@@ -595,9 +597,8 @@
// During communication, save the status code.
if (e.getStatusCode() > 0)
method.setStatusCode(e.getStatusCode());
- if (debug > 1)
- System.err.println("HTTP Exception: " + e.getMessage() +
- ", Status Code: " + e.getStatusCode());
+ log.warn("HTTP Exception: " + e.getMessage() +
+ ", Status Code: " + e.getStatusCode(),e);
// If something goes wrong, disconnect, then reconnect
try {
closeConnection();
@@ -666,10 +667,9 @@
* Start a session.
*/
public void startSession(String host, int port, boolean https) {
- if (debug > 0)
- System.out.println("Start session : Host:" + host
- + " Port:" + port
- + " HTTPS:" + https);
+ log.debug("Start session : Host:" + host
+ + " Port:" + port
+ + " HTTPS:" + https);
if (state == null)
state = new State();
@@ -691,13 +691,12 @@
/**
* Start a session.
*/
- public void startSession(String host, int port, Credentials creds,
+ public void startSession(String host, int port, Credentials creds,
boolean https) {
- if (debug > 0)
- System.out.println("Start session : Host:" + host
- + " Port:" + port
- + " Credentials:" + creds
- + " HTTPS:" + https);
+ log.debug("Start session : Host:" + host
+ + " Port:" + port
+ + " Credentials:" + creds
+ + " HTTPS:" + https);
setCredentials(creds);
if (state == null)
state = new State();
@@ -718,13 +717,13 @@
*/
public void startSession(URL url) {
if("https".equalsIgnoreCase(url.getProtocol())) {
- startSession(url.getHost(), url.getPort() == -1 ? 443
+ startSession(url.getHost(), url.getPort() == -1 ? 443
: url.getPort(),true);
} else if("http".equalsIgnoreCase(url.getProtocol())) {
- startSession(url.getHost(), url.getPort() == -1 ? 80
+ startSession(url.getHost(), url.getPort() == -1 ? 80
: url.getPort(),false);
} else {
- throw new IllegalArgumentException("Protocol " + url.getProtocol()
+ throw new IllegalArgumentException("Protocol " + url.getProtocol()
+ " not supported in URL " + url);
}
}
@@ -747,7 +746,7 @@
/**
* Start a session with a proxy server.
*/
- public void startSession(String host, int port,
+ public void startSession(String host, int port,
String proxyhost, int proxyport) {
this.proxyHost = proxyhost;
this.proxyPort = proxyport;
@@ -761,8 +760,7 @@
public void endSession()
throws IOException {
- if (debug > 0)
- System.out.println("End session");
+ log.debug("End session");
closeConnection();
@@ -782,10 +780,8 @@
try {
if (socket == null) {
if (proxyHost == null || proxyPort < 0) {
- if (debug > 0)
- System.out.println
- ("Reopen connection : Host:"
- + sessionHost + " Port:" + sessionPort);
+ log.debug("Reopen connection : Host:"
+ + sessionHost + " Port:" + sessionPort);
if(https) {
socket = SSLSocketFactory.getDefault().createSocket
(this.sessionHost, this.sessionPort);
@@ -794,9 +790,8 @@
(this.sessionHost, this.sessionPort);
}
} else {
- if (debug > 0)
- System.out.println("Reopen connection : Host:"
- + proxyHost + " Port:" + proxyPort);
+ log.debug("Reopen connection : Host:"
+ + proxyHost + " Port:" + proxyPort);
socket = new Socket(this.proxyHost, this.proxyPort);
}
}
@@ -826,8 +821,7 @@
protected void closeConnection() throws IOException {
- if (debug > 0)
- System.out.println("Closing connection");
+ log.debug("Closing connection");
// Close socket
if (input != null)
@@ -874,10 +868,6 @@
else
requestLine = method.generateRequestLine(getHost(), getPort());
- if (debug > 0) {
- System.out.println();
- }
-
String hostName = sessionHost;
if (sessionPort != 80)
hostName = hostName + ":" + sessionPort;
@@ -887,8 +877,7 @@
Enumeration headersList = method.getHeaders();
// Sending request line
- if (debug > 1)
- System.out.print(requestLine);
+ log.debug(requestLine);
output.write(requestLine.getBytes());
// Sending headers
@@ -899,17 +888,15 @@
queryStr = new String();
query = queryStr.getBytes("UTF8");
if (method.needContentLength()) {
- if (debug > 1)
- System.out.print("Content-Length: "
- + query.length + "\r\n");
+ log.debug("Content-Length: "
+ + query.length + "\r\n");
output.write(("Content-Length: "
+ query.length + "\r\n").getBytes());
}
} else {
// Chunking
if ((http11) && (method.getHeader("Content-Length") == null)) {
- if (debug > 1)
- System.out.print("Transfer-Encoding: chunked\r\n");
+ log.debug("Transfer-Encoding: chunked\r\n");
output.write(("Transfer-Encoding: chunked\r\n").getBytes());
}
}
@@ -919,9 +906,8 @@
String challengeResponse = Authenticator.challengeResponse
(state, credentials);
if (challengeResponse != null) {
- if (debug > 1)
- System.out.print("Authorization: "
- + challengeResponse + "\r\n");
+ log.debug("Authorization: "
+ + challengeResponse + "\r\n");
output.write(("Authorization: "
+ challengeResponse + "\r\n").getBytes());
if (connectionInterceptor != null) {
@@ -940,13 +926,10 @@
while (headersList.hasMoreElements()) {
Header header = (Header) headersList.nextElement();
- if (debug > 1)
- System.out.print(header.toString());
+ log.debug(header.toString());
output.write(header.toString().getBytes());
}
- if (debug > 1)
- System.out.print("\r\n");
output.write("\r\n".getBytes());
return query;
@@ -974,10 +957,7 @@
}
method.streamQuery(requestOutputStream);
} else {
- if (debug > 10) {
- System.out.println(new String(query, "UTF8"));
- System.out.println();
- }
+ log.debug(new String(query,"UTF8"));
requestOutputStream.write(query);
}
@@ -1032,11 +1012,8 @@
while (statusLine != null && !statusLine.startsWith("HTTP/")) {
statusLine = readLine(input);
- }
- if (debug > 0) {
- System.out.println();
- System.out.println(statusLine);
}
+ log.debug(statusLine);
if (statusLine == null)
throw new HttpException
("Error in parsing the response: " + statusLine);
@@ -1108,9 +1085,7 @@
Header header = new Header(name, value);
result.put(match, header);
- if (debug > 0) {
- System.out.println(name + ": " + value);
- }
+ log.debug(name + ": " + value);
}
@@ -1132,10 +1107,6 @@
}
}
- if (debug > 0) {
- System.out.println();
- }
-
return result;
}
@@ -1190,7 +1161,7 @@
*/
protected boolean needToCloseOutput(HttpMethod method) {
if (!http11) {
- if ((method.isStreamedQuery())
+ if ((method.isStreamedQuery())
&& (method.getHeader("Content-Length") == null)
&& (method.needContentLength())) {
return true;
1.2 +34 -34
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java
Index: NameValuePair.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/NameValuePair.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NameValuePair.java 2001/04/25 18:42:51 1.1
+++ NameValuePair.java 2001/07/27 22:53:53 1.2
@@ -3,7 +3,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -11,7 +11,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -19,15 +19,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
@@ -55,7 +55,7 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.commons.httpclient;
@@ -63,15 +63,15 @@
/**
* Simple Name Value Pair class.
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">B.C. Holmes</a>
*/
public class NameValuePair implements Serializable {
-
-
+
+
// ----------------------------------------------------------- Constructors
-
-
+
+
/**
* Default constructor.
*/
@@ -82,69 +82,69 @@
* Constructor.
*/
public NameValuePair(String name, String value) {
-
+
this.name = name;
this.value = value;
-
+
}
-
+
// ----------------------------------------------------- Instance Variables
/**
* Name.
*/
protected String name = null;
-
+
/**
* Value.
*/
protected String value = null;
-
-
+
+
// ------------------------------------------------------------- Properties
-
+
/**
* Name property setter.
- *
- * @param name
+ *
+ * @param name
*/
public void setName(String name) {
this.name = name;
}
-
-
+
+
/**
* Name property getter.
- *
+ *
* @return String name
*/
public String getName() {
return name;
}
-
-
+
+
/**
* Value property setter.
- *
- * @param value
+ *
+ * @param value
*/
public void setValue(String value) {
this.value = value;
}
-
-
+
+
/**
* Value property getter.
- *
+ *
* @return String value
*/
public String getValue() {
return value;
}
-
-
+
+
// --------------------------------------------------------- Public Methods
-
+
/**
* Get a String representation of the header.
*/
@@ -157,7 +157,7 @@
return true;
} else if (this.getClass().equals(object.getClass())) {
NameValuePair pair = (NameValuePair) object;
- return (this.name.equals(pair.name) &&
+ return (this.name.equals(pair.name) &&
this.value.equals(pair.value));
} else {
return false;
1.6 +25 -25
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java
Index: ResponseInputStream.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ResponseInputStream.java 2001/06/20 16:00:34 1.5
+++ ResponseInputStream.java 2001/07/27 22:53:53 1.6
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v
1.5 2001/06/20 16:00:34 remm Exp $
- * $Revision: 1.5 $
- * $Date: 2001/06/20 16:00:34 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v
1.6 2001/07/27 22:53:53 rwaldhoff Exp $
+ * $Revision: 1.6 $
+ * $Date: 2001/07/27 22:53:53 $
*
* ====================================================================
*
@@ -74,7 +74,7 @@
* Socket input stream wrapper.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.5 $ $Date: 2001/06/20 16:00:34 $
+ * @version $Revision: 1.6 $ $Date: 2001/07/27 22:53:53 $
*/
public class ResponseInputStream
@@ -89,7 +89,7 @@
*
* @param request The associated request
*/
- public ResponseInputStream(InputStream stream, HttpMethod method,
+ public ResponseInputStream(InputStream stream, HttpMethod method,
Hashtable responseHeaders) {
super();
@@ -108,7 +108,7 @@
(Header) responseHeaders.get("content-length");
if (contentLength != null) {
try {
- this.contentLength =
+ this.contentLength =
Integer.parseInt(contentLength.getValue());
} catch (NumberFormatException e) {
}
@@ -267,7 +267,7 @@
avail = length - pos;
if (avail == 0)
return (-1);
-
+
int toCopy = avail;
if (toCopy < 0) {
@@ -298,7 +298,7 @@
}
return (buffer[pos++] & 0xff);
-
+
}
@@ -308,9 +308,9 @@
/**
* Fill the chunk buffer.
*/
- private boolean fillBuffer()
+ private boolean fillBuffer()
throws IOException {
-
+
// Has this stream been closed?
if (closed)
return false;
@@ -329,9 +329,9 @@
}
pos = 0;
-
+
if (chunk) {
-
+
try {
String numberValue = readLineFromStream();
if (numberValue == null) {
@@ -347,31 +347,31 @@
closed = true;
return false;
}
-
+
if (length == 0) {
-
+
// Skipping trailing headers, if any
String trailingLine = readLineFromStream();
while (!trailingLine.equals(""))
trailingLine = readLineFromStream();
endChunk = true;
return false;
-
+
} else {
-
+
if ((buffer == null)
|| (length > buffer.length))
buffer = new byte[length];
-
+
// Now read the whole chunk into the buffer
-
+
int nbRead = 0;
int currentRead = 0;
-
+
while (nbRead < length) {
try {
- currentRead =
- stream.read(buffer, nbRead,
+ currentRead =
+ stream.read(buffer, nbRead,
length - nbRead);
} catch (Throwable t) {
t.printStackTrace();
@@ -382,10 +382,10 @@
}
nbRead += currentRead;
}
-
+
// Skipping the CRLF
String blank = readLineFromStream();
-
+
}
} else {
@@ -401,13 +401,13 @@
}
}
-
+
if (interceptor != null) {
interceptor.bytesRead(buffer, 0, length);
}
return true;
-
+
}