rwaldhoff 01/08/27 12:26:38
Modified: httpclient/src/java/org/apache/commons/httpclient Tag:
rlwrefactoring Authenticator.java Cookie.java
HttpClient.java HttpConnection.java
HttpConnectionImpl.java HttpMethod.java
HttpMethodBase.java RequestOutputStream.java
ResponseInputStream.java
httpclient/src/java/org/apache/commons/httpclient/methods
Tag: rlwrefactoring PostMethod.java PutMethod.java
Log:
documentation improvements
Revision Changes Path
No revision
No revision
1.6.2.5 +8 -4
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Authenticator.java
Index: Authenticator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Authenticator.java,v
retrieving revision 1.6.2.4
retrieving revision 1.6.2.5
diff -u -r1.6.2.4 -r1.6.2.5
--- Authenticator.java 2001/08/27 15:32:59 1.6.2.4
+++ Authenticator.java 2001/08/27 19:26:37 1.6.2.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Authenticator.java,v
1.6.2.4 2001/08/27 15:32:59 rwaldhoff Exp $
- * $Revision: 1.6.2.4 $
- * $Date: 2001/08/27 15:32:59 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Authenticator.java,v
1.6.2.5 2001/08/27 19:26:37 rwaldhoff Exp $
+ * $Revision: 1.6.2.5 $
+ * $Date: 2001/08/27 19:26:37 $
*
* ====================================================================
*
@@ -75,7 +75,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
* @author Rodney Waldhoff
- * @version $Revision: 1.6.2.4 $ $Date: 2001/08/27 15:32:59 $
+ * @version $Revision: 1.6.2.5 $ $Date: 2001/08/27 19:26:37 $
*/
public class Authenticator {
@@ -171,6 +171,10 @@
}
}
+ /**
+ * Return a Basic <tt>Authorization</tt> header value for the
+ * given {@link UsernamePasswordCredentials}.
+ */
public static String basic(UsernamePasswordCredentials cred) throws
HttpException {
String authString = cred.getUserName() + ":" + cred.getPassword();
return "Basic " + new String(base64.encode(authString.getBytes()));
1.4.2.5 +48 -9
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java
Index: Cookie.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
retrieving revision 1.4.2.4
retrieving revision 1.4.2.5
diff -u -r1.4.2.4 -r1.4.2.5
--- Cookie.java 2001/08/27 15:32:59 1.4.2.4
+++ Cookie.java 2001/08/27 19:26:38 1.4.2.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
1.4.2.4 2001/08/27 15:32:59 rwaldhoff Exp $
- * $Revision: 1.4.2.4 $
- * $Date: 2001/08/27 15:32:59 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
1.4.2.5 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.4.2.5 $
+ * $Date: 2001/08/27 19:26:38 $
*
* ====================================================================
*
@@ -342,6 +342,15 @@
return buf.toString();
}
+ /**
+ * Return <tt>true</tt> if I should be submitted with a request with
+ * given attributes, <tt>false</tt> otherwise.
+ * @param domain the host to which the request is being submitted
+ * @param port the port to which the request is being submitted (currenlty
ignored)
+ * @param path the path to which the request is being submitted
+ * @param secure <tt>true</tt> if the request is using the HTTPS protocol
+ * @param date the time at which the request is submitted
+ */
public boolean matches(String domain, int port, String path, boolean secure,
Date now) {
// FIXME: RFC2109 doesn't consider ports when filtering/matching
// cookies. Quoting from Section 2 - Terminology:
@@ -372,6 +381,13 @@
);
}
+ /**
+ * Return <tt>true</tt> if I should be submitted with a request with
+ * given attributes, <tt>false</tt> otherwise.
+ * @param domain the host to which the request is being submitted
+ * @param port the port to which the request is being submitted (currenlty
ignored)
+ * @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());
}
@@ -396,7 +412,7 @@
* <i>https</i> setting.
* <p>
* If no cookies match, returns null.
- * @deprecated
+ * @deprecated use the version which includes port number and date
*/
public static Header createCookieHeader(String domain, String path, boolean
secure, Cookie[] cookies) {
// parse port from domain, if any
@@ -412,10 +428,27 @@
return Cookie.createCookieHeader(domain,port,path,secure,cookies);
}
+ /**
+ * Create a <tt>Cookie</tt> header containing
+ * all non-expired cookies in <i>cookies</i>,
+ * associated with the given <i>domain</i>, <i>port</i>,
+ * <i>path</i> and <i>https</i> setting.
+ * <p>
+ * If no cookies match, returns null.
+ */
public static Header createCookieHeader(String domain, int port, String path,
boolean secure, Cookie[] cookies) {
return Cookie.createCookieHeader(domain,port,path,secure,new
Date(),cookies);
}
+ /**
+ * Create a <tt>Cookie</tt> header containing
+ * all cookies in <i>cookies</i>,
+ * associated with the given <i>domain</i>, <i>port</i>,
+ * <i>path</i> and <i>https</i> setting, and which are
+ * not expired according to the given <i>date</i>.
+ * <p>
+ * If no cookies match, returns null.
+ */
public static Header createCookieHeader(String domain, int port, String path,
boolean secure, Date now, Cookie[] cookies) {
boolean added = false;
StringBuffer value = new StringBuffer("$Version=1");
@@ -454,8 +487,6 @@
* @param setCookie the <tt>Set-Cookie</tt> {@link Header} received from the
server
* @return an array of <tt>Cookie</tt>s parsed from the Set-Cookie {@link
Header}
* @throws HttpException if an exception occurs during parsing
- *
- * @see
#parse(java.lang.String,java.lang.String,boolean,org.apache.commons.httpclient.Header)
*/
public static Cookie[] parse(String domain, int port, String path, Header
setCookie) throws HttpException {
return Cookie.parse(domain,port,path,false,setCookie);
@@ -471,13 +502,22 @@
* @param setCookie the <tt>Set-Cookie</tt> {@link Header} received from the
server
* @return an array of <tt>Cookie</tt>s parsed from the Set-Cookie {@link
Header}
* @throws HttpException if an exception occurs during parsing
- *
- * @see
#parse(java.lang.String,java.lang.String,boolean,org.apache.commons.httpclient.Header)
*/
public static Cookie[] parse(String domain, String path, Header setCookie)
throws HttpException {
return Cookie.parse(domain,80,path,false,setCookie);
}
+ /**
+ * Parses the Set-Cookie {@link Header} into an array of
+ * <tt>Cookie</tt>s.
+ *
+ * @param domain the domain from which the {@link Header} was received
+ * @param path the path from which the {@link Header} was received
+ * @param secure <tt>true</tt> when the header was recieved over a secure
channel
+ * @param setCookie the <tt>Set-Cookie</tt> {@link Header} received from the
server
+ * @return an array of <tt>Cookie</tt>s parsed from the Set-Cookie {@link
Header}
+ * @throws HttpException if an exception occurs during parsing
+ */
public static Cookie[] parse(String domain, String path, boolean secure, Header
setCookie) throws HttpException {
return Cookie.parse(domain,(secure ? 443 : 80),path,secure,setCookie);
}
@@ -509,7 +549,6 @@
* @return an array of <tt>Cookie</tt>s parsed from the Set-Cookie {@link
Header}
* @throws HttpException if an exception occurs during parsing
*/
-
public static Cookie[] parse(String domain, int port, String path, boolean
secure, Header setCookie) throws HttpException {
HeaderElement[] headerElements =
HeaderElement.parse(setCookie.getValue());
1.31.2.10 +7 -5
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.31.2.9
retrieving revision 1.31.2.10
diff -u -r1.31.2.9 -r1.31.2.10
--- HttpClient.java 2001/08/27 15:32:59 1.31.2.9
+++ HttpClient.java 2001/08/27 19:26:38 1.31.2.10
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
1.31.2.9 2001/08/27 15:32:59 rwaldhoff Exp $
- * $Revision: 1.31.2.9 $
- * $Date: 2001/08/27 15:32:59 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
1.31.2.10 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.31.2.10 $
+ * $Date: 2001/08/27 19:26:38 $
*
* ====================================================================
*
@@ -23,11 +23,13 @@
import org.apache.commons.httpclient.log.*;
/**
- * HTTP client main class.
+ * An HTTP "user-agent", containing an {@link HttpState} and
+ * one or more {@link HttpConnection}s, to which
+ * {@link HttpMethod}s can be applied.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
* @author Rodney Waldhoff
- * @version $Revision: 1.31.2.9 $
+ * @version $Revision: 1.31.2.10 $
*/
public class HttpClient {
1.1.2.9 +43 -20
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Attic/HttpConnection.java
Index: HttpConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Attic/HttpConnection.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- HttpConnection.java 2001/08/27 15:32:59 1.1.2.8
+++ HttpConnection.java 2001/08/27 19:26:38 1.1.2.9
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Attic/HttpConnection.java,v
1.1.2.8 2001/08/27 15:32:59 rwaldhoff Exp $
- * $Revision: 1.1.2.8 $
- * $Date: 2001/08/27 15:32:59 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Attic/HttpConnection.java,v
1.1.2.9 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.1.2.9 $
+ * $Date: 2001/08/27 19:26:38 $
* ====================================================================
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -26,7 +26,7 @@
* pair, together with the relevant attributes.
*
* @author Rod Waldhoff
- * @version $Revision: 1.1.2.8 $
+ * @version $Revision: 1.1.2.9 $
*/
public interface HttpConnection {
@@ -43,7 +43,7 @@
* @param host the host I should connect to
* @throws IllegalStateException if I am already connected
*/
- public void setHost(String host);
+ public void setHost(String host) throws IllegalStateException;
/**
* Return my port.
@@ -56,7 +56,7 @@
* @param port the port I should connect to
* @throws IllegalStateException if I am already connected
*/
- public void setPort(int port);
+ public void setPort(int port) throws IllegalStateException;
/**
* Return my proxy host.
@@ -69,7 +69,7 @@
* @param host the host I should proxy through.
* @throws IllegalStateException if I am already connected
*/
- public void setProxyHost(String host);
+ public void setProxyHost(String host) throws IllegalStateException;
/**
* Return my proxy port.
@@ -82,7 +82,7 @@
* @param port the host I should proxy through.
* @throws IllegalStateException if I am already connected
*/
- public void setProxyPort(int port);
+ public void setProxyPort(int port) throws IllegalStateException;
/**
* Return <tt>true</tt> if I will (or I am) connected over a
@@ -97,7 +97,7 @@
* @param secure whether or not I should connect over HTTPS (SSL).
* @throws IllegalStateException if I am already connected
*/
- public void setSecure(boolean secure);
+ public void setSecure(boolean secure) throws IllegalStateException;
/**
* Return <tt>true</tt> if I am connected,
@@ -119,6 +119,7 @@
/**
* Open this connection to the current host and port
* (via a proxy if so configured).
+ * @throws IOException if an I/O problem occurs
*/
public void open() throws IOException;
@@ -128,11 +129,23 @@
* {@link OutputStream}.
*
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public OutputStream getRequestOutputStream();
- public OutputStream getRequestOutputStream(boolean useChunking);
+ public OutputStream getRequestOutputStream() throws IOException,
IllegalStateException;
/**
+ * Return a {@link RequestOutputStream}
+ * suitable for writing (possibly chunked) bytes to my
+ * {@link OutputStream}.
+ *
+ * @param useChunking when <tt>true</tt> the chunked transfer-encoding will be
used
+ *
+ * @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
+ */
+ public OutputStream getRequestOutputStream(boolean useChunking) throws
IOException, IllegalStateException;
+
+ /**
* Return a {@link ResponseInputStream}
* suitable for reading (possibly chunked)
* bytes from my {@link InputStream}.
@@ -143,62 +156,72 @@
* to read chunked bytes.
*
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public InputStream getResponseInputStream(HttpMethod method);
+ public InputStream getResponseInputStream(HttpMethod method) throws
IOException, IllegalStateException;
/**
* Write the specified bytes to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void write(byte[] data) throws IOException;
+ public void write(byte[] data) throws IOException, IllegalStateException;
/**
* Write the specified bytes, followed by
* <tt>"\r\n".getBytes()</tt> to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void writeLine(byte[] data) throws IOException;
+ public void writeLine(byte[] data) throws IOException, IllegalStateException;;
/**
* Write <tt>"\r\n".getBytes()</tt> to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void writeLine() throws IOException;
+ public void writeLine() throws IOException, IllegalStateException;
/**
* Write the specified String (as bytes) to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void print(String data) throws IOException;
+ public void print(String data) throws IOException, IllegalStateException;;
/**
* Write the specified String (as bytes), followed by
* <tt>"\r\n".getBytes()</tt> to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void printLine(String data) throws IOException;
+ public void printLine(String data) throws IOException, IllegalStateException;
/**
* Write <tt>"\r\n".getBytes()</tt> to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void printLine() throws IOException;
+ public void printLine() throws IOException, IllegalStateException;
/**
* Read up to <tt>"\r\n"</tt> from my (unchunked) input stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public String readLine() throws IOException;
+ public String readLine() throws IOException, IllegalStateException;
/**
* Shutdown my {@link Socket}'s output, via
* {@link Socket#shutdownOutput}.
+ * @throws IOException if an I/O problem occurs
*/
- public void shutdownOutput();
+ public void shutdownOutput() throws IOException;
/**
* Close my socket and streams.
+ * @throws IOException if an I/O problem occurs
*/
public void close() throws IOException;
}
1.1.2.2 +42 -22
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Attic/HttpConnectionImpl.java
Index: HttpConnectionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Attic/HttpConnectionImpl.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- HttpConnectionImpl.java 2001/08/27 15:32:59 1.1.2.1
+++ HttpConnectionImpl.java 2001/08/27 19:26:38 1.1.2.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Attic/HttpConnectionImpl.java,v
1.1.2.1 2001/08/27 15:32:59 rwaldhoff Exp $
- * $Revision: 1.1.2.1 $
- * $Date: 2001/08/27 15:32:59 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Attic/HttpConnectionImpl.java,v
1.1.2.2 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.1.2.2 $
+ * $Date: 2001/08/27 19:26:38 $
* ====================================================================
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -22,11 +22,10 @@
import java.lang.reflect.Method;
/**
- * An abstraction of an HTTP {@link InputStream} and {@link OutputStream}
- * pair, together with the relevant attributes.
+ * A base implementation of {@link HttpConnection}.
*
* @author Rod Waldhoff
- * @version $Revision: 1.1.2.1 $
+ * @version $Revision: 1.1.2.2 $ $Date: 2001/08/27 19:26:38 $
*/
public class HttpConnectionImpl implements HttpConnection {
@@ -94,7 +93,7 @@
* @param host the host I should connect to
* @throws IllegalStateException if I am already connected
*/
- public void setHost(String host) {
+ public void setHost(String host) throws IllegalStateException {
assertNotOpen();
_host = host;
}
@@ -112,7 +111,7 @@
* @param port the port I should connect to
* @throws IllegalStateException if I am already connected
*/
- public void setPort(int port) {
+ public void setPort(int port) throws IllegalStateException {
assertNotOpen();
_port = port;
}
@@ -130,7 +129,7 @@
* @param host the host I should proxy through.
* @throws IllegalStateException if I am already connected
*/
- public void setProxyHost(String host) {
+ public void setProxyHost(String host) throws IllegalStateException {
assertNotOpen();
_proxyHost = host;
}
@@ -148,7 +147,7 @@
* @param port the host I should proxy through.
* @throws IllegalStateException if I am already connected
*/
- public void setProxyPort(int port) {
+ public void setProxyPort(int port) throws IllegalStateException {
assertNotOpen();
_proxyPort = port;
}
@@ -168,7 +167,7 @@
* @param secure whether or not I should connect over HTTPS (SSL).
* @throws IllegalStateException if I am already connected
*/
- public void setSecure(boolean secure) {
+ public void setSecure(boolean secure) throws IllegalStateException {
assertNotOpen();
_ssl = secure;
}
@@ -234,14 +233,25 @@
* bytes to my {@link OutputStream}.
*
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public OutputStream getRequestOutputStream() {
+ public OutputStream getRequestOutputStream() throws IOException,
IllegalStateException {
assertOpen();
RequestOutputStream out = new RequestOutputStream(_output);
return out;
}
- public OutputStream getRequestOutputStream(boolean useChunking) {
+ /**
+ * Return a {@link RequestOutputStream}
+ * suitable for writing (possibly chunked) bytes to my
+ * {@link OutputStream}.
+ *
+ * @param useChunking when <tt>true</tt> the chunked transfer-encoding will be
used
+ *
+ * @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
+ */
+ public OutputStream getRequestOutputStream(boolean useChunking) throws
IOException, IllegalStateException {
assertOpen();
RequestOutputStream out = new RequestOutputStream(_output,useChunking);
return out;
@@ -258,8 +268,9 @@
* to read chunked bytes.
*
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public InputStream getResponseInputStream(HttpMethod method) {
+ public InputStream getResponseInputStream(HttpMethod method) throws
IOException, IllegalStateException {
assertOpen();
return new ResponseInputStream(_input,method);
}
@@ -267,8 +278,9 @@
/**
* Write the specified bytes to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void write(byte[] data) throws IOException {
+ public void write(byte[] data) throws IOException, IllegalStateException {
log.debug("HttpConnectionImpl.write(byte[])");
assertOpen();
if(wireLog.isInfoEnabled() && data.length > 0) {
@@ -289,8 +301,9 @@
* Write the specified bytes, followed by
* <tt>"\r\n".getBytes()</tt> to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void writeLine(byte[] data) throws IOException {
+ public void writeLine(byte[] data) throws IOException, IllegalStateException {
log.debug("HttpConnectionImpl.writeLine(byte[])");
assertOpen();
if(wireLog.isInfoEnabled() && data.length > 0) {
@@ -303,8 +316,9 @@
/**
* Write <tt>"\r\n".getBytes()</tt> to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void writeLine() throws IOException {
+ public void writeLine() throws IOException, IllegalStateException {
log.debug("HttpConnectionImpl.writeLine()");
wireLog.info(">> \\r\\n");
_output.write(CRLF);
@@ -313,8 +327,9 @@
/**
* Write the specified String (as bytes) to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void print(String data) throws IOException {
+ public void print(String data) throws IOException, IllegalStateException {
write(data.getBytes());
}
@@ -322,24 +337,27 @@
* Write the specified String (as bytes), followed by
* <tt>"\r\n".getBytes()</tt> to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void printLine(String data) throws IOException {
+ public void printLine(String data) throws IOException, IllegalStateException {
writeLine(data.getBytes());
}
/**
* Write <tt>"\r\n".getBytes()</tt> to my output stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public void printLine() throws IOException {
+ public void printLine() throws IOException, IllegalStateException {
writeLine();
}
/**
* Read up to <tt>"\r\n"</tt> from my (unchunked) input stream.
* @throws IllegalStateException if I am not connected
+ * @throws IOException if an I/O problem occurs
*/
- public String readLine() throws IOException {
+ public String readLine() throws IOException, IllegalStateException {
log.debug("HttpConnectionImpl.readLine()");
assertOpen();
StringBuffer buf = new StringBuffer();
@@ -370,8 +388,9 @@
/**
* Shutdown my {@link Socket}'s output, via
* {@link Socket#shutdownOutput}.
+ * @throws IOException if an I/O problem occurs
*/
- public void shutdownOutput() {
+ public void shutdownOutput() throws IOException {
log.debug("HttpConnectionImpl.shutdownOutput()");
try {
// Socket.shutdownOutput is a JDK 1.3
@@ -390,6 +409,7 @@
/**
* Close my socket and streams.
+ * @throws IOException if an I/O problem occurs
*/
public void close() throws IOException {
log.debug("HttpConnectionImpl.close()");
1.5.2.12 +8 -6
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java
Index: HttpMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
retrieving revision 1.5.2.11
retrieving revision 1.5.2.12
diff -u -r1.5.2.11 -r1.5.2.12
--- HttpMethod.java 2001/08/27 15:32:59 1.5.2.11
+++ HttpMethod.java 2001/08/27 19:26:38 1.5.2.12
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
1.5.2.11 2001/08/27 15:32:59 rwaldhoff Exp $
- * $Revision: 1.5.2.11 $
- * $Date: 2001/08/27 15:32:59 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
1.5.2.12 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.5.2.12 $
+ * $Date: 2001/08/27 19:26:38 $
* ====================================================================
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -32,7 +32,7 @@
/**
* Obtain the name of this method, suitable for use in the "request line",
- * for example <tt>GET</tt> or <tt>POST</tt>.
+ * for example <tt>"GET"</tt> or <tt>"POST"</tt>.
* @return the name of this method
*/
public String getName();
@@ -52,6 +52,7 @@
/**
* Set the specified request header, overwriting any
* previous value.
+ * Note that header-name matching is case insensitive.
* @param headerName the header's name
* @param headerValue the header's value
*/
@@ -60,6 +61,7 @@
/**
* Set the specified request header, overwriting any
* previous value.
+ * Note that header-name matching is case insensitive.
* @param header the header
*/
public void setRequestHeader(Header header);
@@ -90,7 +92,7 @@
public Header getRequestHeader(String headerName);
/**
- * Remove the request header associated with the given name.
+ * Remove all request headers associated with the given name.
* Note that header-name matching is case insensitive.
* @param headerName the header name
* @return the header
@@ -206,7 +208,7 @@
/**
* Recycle this method so that it can be used again.
- * All of my instances variables will be reset
+ * Note that all of my instance variables will be reset
* once this method has been called.
*/
public void recycle();
1.10.2.25 +77 -33
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Index: HttpMethodBase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.10.2.24
retrieving revision 1.10.2.25
diff -u -r1.10.2.24 -r1.10.2.25
--- HttpMethodBase.java 2001/08/27 15:32:59 1.10.2.24
+++ HttpMethodBase.java 2001/08/27 19:26:38 1.10.2.25
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
1.10.2.24 2001/08/27 15:32:59 rwaldhoff Exp $
- * $Revision: 1.10.2.24 $
- * $Date: 2001/08/27 15:32:59 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
1.10.2.25 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.10.2.25 $
+ * $Date: 2001/08/27 19:26:38 $
* ====================================================================
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -21,10 +21,9 @@
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
-import java.util.Vector;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import java.util.Date;
import java.net.URL;
import java.net.MalformedURLException;
@@ -49,7 +48,7 @@
* When a method requires additional request headers,
* subclasses will typically want to override:
* <ul><dl>
- * <dt>{@link #generateRequestHeaders}</dt>
+ * <dt>{@link #addRequestHeaders}</dt>
* <dd>to write those headers</dd>
* </dl></ul>
* When a method expects specific response headers,
@@ -61,7 +60,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
* @author Rodney Waldhoff
- * @version $Revision: 1.10.2.24 $
+ * @version $Revision: 1.10.2.25 $ $Date: 2001/08/27 19:26:38 $
*/
public abstract class HttpMethodBase implements HttpMethod {
@@ -126,6 +125,7 @@
/**
* Set the specified request header, overwriting any
* previous value.
+ * Note that header-name matching is case-insensitive.
* @param headerName the header's name
* @param headerValue the header's value
*/
@@ -137,6 +137,7 @@
/**
* Set the specified request header, overwriting any
* previous value.
+ * Note that header-name matching is case insensitive.
* @param header the header
*/
public void setRequestHeader(Header header) {
@@ -356,7 +357,7 @@
/**
* Execute this method.
*
- * @param state state information to associate with this request
+ * @param state {@link HttpState} information to associate with this request
* @param connection the {@link HttpConnection} to write to/read from
*
* @throws IOException if an I/O error occurs
@@ -477,9 +478,6 @@
// to "https://secure.mydomain.com/"
//
- // XXX FIX ME XXX
- // Should handle query-string changes as well!
-
Header location = getResponseHeader("location");
if(location != null) {
URL url = null;
@@ -609,13 +607,13 @@
/**
* Writes the request headers to the given {@link HttpConnection}.
* <p>
- * This implementation invokes {@link #generateRequestHeaders},
+ * This implementation invokes {@link #addRequestHeaders},
* and then writes each header to the request stream.
* <p>
* Subclasses may want to override this method to
* to customize the processing.
*
- * @see #generateRequestHeaders
+ * @see #addRequestHeaders
* @see #getRequestHeaders
*
* @param state the client state
@@ -623,7 +621,7 @@
*/
protected void writeRequestHeaders(HttpState state, HttpConnection conn) throws
IOException, HttpException {
log.debug("HttpMethodBase.writeRequestHeaders(HttpState,HttpConnection)");
- generateRequestHeaders(state,conn);
+ addRequestHeaders(state,conn);
Iterator it = requestHeaders.values().iterator();
while(it.hasNext()) {
conn.print(((Header)it.next()).toExternalForm());
@@ -650,36 +648,57 @@
* @param state the client state
* @param conn the {@link HttpConnection} the headers will eventually be
written to
*/
- protected void generateRequestHeaders(HttpState state, HttpConnection conn)
throws IOException, HttpException {
+ protected void addRequestHeaders(HttpState state, HttpConnection conn) throws
IOException, HttpException {
+ addUserAgentRequestHeader(state,conn);
+ addHostRequestHeader(state,conn);
+ addCookieRequestHeader(state,conn);
+ addAuthorizationRequestHeader(state,conn);
+ addContentLengthRequestHeader(state,conn);
+ }
- // add default user agent
+ /**
+ * Adds a default <tt>User-Agent</tt> request header,
+ * as long as no <tt>User-Agent</tt> request header
+ * already exists.
+ */
+ protected void addUserAgentRequestHeader(HttpState state, HttpConnection conn)
throws IOException, HttpException {
if (!requestHeaders.containsKey("user-agent")) {
setRequestHeader(HttpMethodBase.USER_AGENT);
}
+ }
+ /**
+ * Adds a <tt>Host</tt> request header,
+ * as long as no <tt>Host</tt> request header
+ * already exists.
+ */
+ protected void addHostRequestHeader(HttpState state, HttpConnection conn)
throws IOException, HttpException {
// add host (should do this conditionally?, i.e., don't send to http/1.0?)
if (!requestHeaders.containsKey("host")) {
setRequestHeader("Host",conn.getHost());
}
+ }
- // add cookies
+ /**
+ * Adds a <tt>Cookie</tt> request containing the matching {@link Cookie}s,
+ * if any, as long as no <tt>Cookie</tt> request header
+ * already exists.
+ */
+ protected void addCookieRequestHeader(HttpState state, HttpConnection conn)
throws IOException, HttpException {
if (!requestHeaders.containsKey("cookie")) {
- Header cookieHeader = Cookie.createCookieHeader(conn.getHost(),
getPath(), conn.isSecure(), state.getCookies());
+ Header cookieHeader = Cookie.createCookieHeader(conn.getHost(),
conn.getPort(), getPath(), conn.isSecure(), new Date(), state.getCookies());
if(null != cookieHeader) {
setRequestHeader(cookieHeader);
}
- }
-
- // add content length or chunking
- int len = getRequestContentLength();
- if(!requestHeaders.containsKey("content-length")) {
- if(-1 < len) {
- setRequestHeader("Content-Length",String.valueOf(len));
- } else if(http11 && len < 0) {
- setRequestHeader("Transfer-Encoding","chunked");
- }
}
+ }
+ /**
+ * Adds an <tt>Authorization</tt> request if needed,
+ * as long as no <tt>Authorization</tt> request header
+ * already exists.
+ */
+ protected void addAuthorizationRequestHeader(HttpState state, HttpConnection
conn) throws IOException, HttpException {
// add authorization header, if needed
if(!requestHeaders.containsKey("authorization")) {
Header wwwAuthenticateHeader =
(Header)(responseHeaders.get("www-authenticate"));
@@ -694,6 +713,24 @@
}
/**
+ * Adds a <tt>Content-Length</tt> or
+ * <tt>Transer-Encoding: Chunked</tt> request header,
+ * as long as no <tt>Content-Length</tt> request header
+ * already exists.
+ */
+ protected void addContentLengthRequestHeader(HttpState state, HttpConnection
conn) throws IOException, HttpException {
+ // add content length or chunking
+ int len = getRequestContentLength();
+ if(!requestHeaders.containsKey("content-length")) {
+ if(-1 < len) {
+ setRequestHeader("Content-Length",String.valueOf(len));
+ } else if(http11 && len < 0) {
+ setRequestHeader("Transfer-Encoding","chunked");
+ }
+ }
+ }
+
+ /**
* Return the length (in bytes) of
* my request body, suitable for use in
* a <tt>Content-Length</tt> header.
@@ -1119,20 +1156,29 @@
}
// ----------------------------------------------------- Instance Variables
-
+ /** My request path. */
private String path = null;
+ /** Whether or not I should automatically follow redirects. */
private boolean followRedirects = false;
+ /** My query string, if any. */
private String queryString = null;
+ /** My request headers, if any. */
private HashMap requestHeaders = new HashMap();
+ /** My response headers, if any. */
private HashMap responseHeaders = new HashMap();
+ /** My response status code, if any. */
private int statusCode = -1;
+ /** My response status text, if any. */
private String statusText = null;
+ /** Whether or not I have been executed. */
private boolean used = false;
+ /** Whether or not I should use the HTTP/1.1 protocol. */
private boolean http11 = true;
+ /** Whether or not the request body has been sent. */
private boolean bodySent = false;
+ /** The response body, assuming it has not be intercepted by a sub-class. */
private byte[] responseBody = null;
-
// -------------------------------------------------------------- Constants
/** <tt>org.apache.commons.httpclient.HttpMethod</tt> log. */
@@ -1141,9 +1187,7 @@
/** <tt>httpclient.wire</tt> log. */
public static final Log wireLog = LogSource.getInstance("httpclient.wire");
- /**
- * User Agent header.
- */
+ /** <tt>User-Agent: Jakarta HTTP Client/1.0</tt> header. */
public static final Header USER_AGENT = new Header("User-Agent", "Jakarta HTTP
Client/1.0");
}
1.2.2.5 +5 -6
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java
Index: RequestOutputStream.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java,v
retrieving revision 1.2.2.4
retrieving revision 1.2.2.5
diff -u -r1.2.2.4 -r1.2.2.5
--- RequestOutputStream.java 2001/08/27 15:32:59 1.2.2.4
+++ RequestOutputStream.java 2001/08/27 19:26:38 1.2.2.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java,v
1.2.2.4 2001/08/27 15:32:59 rwaldhoff Exp $
- * $Revision: 1.2.2.4 $
- * $Date: 2001/08/27 15:32:59 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java,v
1.2.2.5 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.2.2.5 $
+ * $Date: 2001/08/27 19:26:38 $
*
* ====================================================================
*
@@ -72,12 +72,11 @@
/**
- * Socket output stream wrapper.
+ * Socket output stream wrapper supporting the "chunked" transfer encoding.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.2.2.4 $ $Date: 2001/08/27 15:32:59 $
+ * @version $Revision: 1.2.2.5 $ $Date: 2001/08/27 19:26:38 $
*/
-
public class RequestOutputStream
extends OutputStream {
1.6.2.4 +5 -5
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.6.2.3
retrieving revision 1.6.2.4
diff -u -r1.6.2.3 -r1.6.2.4
--- ResponseInputStream.java 2001/08/23 21:45:33 1.6.2.3
+++ ResponseInputStream.java 2001/08/27 19:26:38 1.6.2.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v
1.6.2.3 2001/08/23 21:45:33 rwaldhoff Exp $
- * $Revision: 1.6.2.3 $
- * $Date: 2001/08/23 21:45:33 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v
1.6.2.4 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.6.2.4 $
+ * $Date: 2001/08/27 19:26:38 $
*
* ====================================================================
*
@@ -68,10 +68,10 @@
import java.util.Hashtable;
/**
- * Socket input stream wrapper.
+ * Socket input stream wrapper supporting the "chunked" transfer encoding.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.6.2.3 $ $Date: 2001/08/23 21:45:33 $
+ * @version $Revision: 1.6.2.4 $ $Date: 2001/08/27 19:26:38 $
*/
public class ResponseInputStream extends InputStream {
No revision
No revision
1.3.2.10 +5 -5
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java
Index: PostMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
retrieving revision 1.3.2.9
retrieving revision 1.3.2.10
diff -u -r1.3.2.9 -r1.3.2.10
--- PostMethod.java 2001/08/27 15:33:01 1.3.2.9
+++ PostMethod.java 2001/08/27 19:26:38 1.3.2.10
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
1.3.2.9 2001/08/27 15:33:01 rwaldhoff Exp $
- * $Revision: 1.3.2.9 $
- * $Date: 2001/08/27 15:33:01 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
1.3.2.10 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.3.2.10 $
+ * $Date: 2001/08/27 19:26:38 $
* ====================================================================
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -181,8 +181,8 @@
* to also add <tt>Content-Type</tt> header
* when appropriate.
*/
- protected void generateRequestHeaders(HttpState state, HttpConnection conn)
throws IOException, HttpException {
- super.generateRequestHeaders(state,conn);
+ protected void addRequestHeaders(HttpState state, HttpConnection conn) throws
IOException, HttpException {
+ super.addRequestHeaders(state,conn);
if(!parameters.isEmpty()) {
setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
1.3.2.14 +7 -5
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java
Index: PutMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
retrieving revision 1.3.2.13
retrieving revision 1.3.2.14
diff -u -r1.3.2.13 -r1.3.2.14
--- PutMethod.java 2001/08/27 15:33:01 1.3.2.13
+++ PutMethod.java 2001/08/27 19:26:38 1.3.2.14
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
1.3.2.13 2001/08/27 15:33:01 rwaldhoff Exp $
- * $Revision: 1.3.2.13 $
- * $Date: 2001/08/27 15:33:01 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
1.3.2.14 2001/08/27 19:26:38 rwaldhoff Exp $
+ * $Revision: 1.3.2.14 $
+ * $Date: 2001/08/27 19:26:38 $
*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -151,8 +151,8 @@
* not already been set, in addition to the "standard"
* set of headers.
*/
- protected void generateRequestHeaders(HttpState state, HttpConnection conn)
throws IOException, HttpException {
- super.generateRequestHeaders(state,conn);
+ protected void addRequestHeaders(HttpState state, HttpConnection conn) throws
IOException, HttpException {
+ super.addRequestHeaders(state,conn);
// Send expectation header
if(isHttp11() && null == getRequestHeader("expect")) {
setRequestHeader("Expect","100-continue");
@@ -212,6 +212,8 @@
}
}
+ /**
+ */
public void recycle() {
super.recycle();
data = null;