summaryrefslogtreecommitdiff
path: root/gnu/java/net/protocol/http/Response.java
diff options
context:
space:
mode:
authorDavid Daney <ddaney@avtrex.com>2005-10-12 19:48:24 +0000
committerDavid Daney <ddaney@avtrex.com>2005-10-12 19:48:24 +0000
commitf66ea401a708a042dc9a1058798c58599d642941 (patch)
treef6884bf2ed3d57dd64c24e7be7dc0e1ff12b4dc6 /gnu/java/net/protocol/http/Response.java
parent39ab427324144ed0178e2b4602743dd984a27d4a (diff)
downloadclasspath-f66ea401a708a042dc9a1058798c58599d642941.tar.gz
2005-10-12 David Daney <ddaney@avtrex.com>
PR classpath/24086, PR classpath/24091, PR classpath/24104 * gnu/java/net/protocol/http/ByteArrayResponseBodyReader.java: Removed. * gnu/java/net/protocol/http/ResponseBodyReader.java: Removed. * gnu/java/net/protocol/http/event/ConnectionEvent.java: Removed. * gnu/java/net/protocol/http/event/ConnectionListener.java: Removed. * gnu/java/net/protocol/http/event/RequestEvent.java: Removed. * gnu/java/net/protocol/http/event/RequestListener.java: Removed. * gnu/java/net/protocol/http/event/package.html: Removed. * gnu/java/net/protocol/http/HTTPConnection.java: Cleaned up imports. (connectionListeners): Removed. (requestListeners): Removed. (pool): New field. (Constructor): Don't initialize connectionListeners or requestListeners. (useCount): New field. (getPoolKey): New method. (setPool): New method. (release): New method. (newRequest): Don't call fireRequestEvent. Use StringBuilder instead of StringBuffer. (close): Don't call fireConnectionEvent. (getURI):Use StringBuilder instead of StringBuffer. (addConnectionListener): Removed. (removeConnectionListener): Removed. (fireConnectionEvent): Removed. (addRequestListener): Removed. (removeRequestListener): Removed. (fireRequestEvent): Removed. * gnu/java/net/protocol/http/HTTPURLConnection.java:Cleaned up imports. (connectionPool): Changed type to LinkedHashMap. (maxConnections): Made static. (responseSink): Changed type to InputStream. (errorSink): Likewise. (connect): Eliminate reader. Get responseSink from response. (getConnection): Rewrote. (getHeaderFields): Use null as key for status line. Return unmodifiable Map. * gnu/java/net/protocol/http/Headers.java: Extend LinkedHashMap, instead of implement Map. (headers): Removed. (Constructor): Do not initialize headers. (size): Removed. (isEmpth): Removed. (containsKey): Rewrote. (containsValue): Removed. (get): Call super.get(). (getValue): Likewise. (getLongValue): New method. (put): Call super.put(). (remove): Call super.remove(). (putAll): Rewrote. (clear): Removed. (keySet): Call super.keySet(). (values): Removed. (entrySet): Call super.entrySet(). (equals): Removed. (hashCode): Removed. (parse): Use StringBuilder instead of StringBuffer. (addValue): Call super.* instead of headers.*. * gnu/java/net/protocol/http/LimitedLengthInputStream.java: New class. * gnu/java/net/protocol/http/Request.java: Cleaned up imports. (responseBodyReader): Removed. (setResponseBodyReader): Removed. (dispatch): Don't create LineInputStream. Don't call fireRequestEvent. Don't append CRLF to Request body. Handle unsolicited 100 Continue response. (readResponse): Rewrote. (readResponseBody): Renamed to ... (createResponseBodyStream): ... And rewritten. (parseAuthParams): Use StringBuilder instead of StringBuffer. (getNonceCount): Likewise. (handleSetCookie): Likewise. * gnu/java/net/protocol/http/Response.java: Cleaned up imports. (codeClass): Removed. (body): New field. (Constructor): Don't initialize codeClass. Initialize body. (getCodeClass): Rewrote. (getLongHeader): New method. (getBody): New method. * gnu/java/net/protocol/http/ChunkedInputStream.java (read): Use StringBuilder instead of StringBuffer. * gnu/java/net/protocol/http/Cookie.java (toString): Use StringBuilder instead of StringBuffer.
Diffstat (limited to 'gnu/java/net/protocol/http/Response.java')
-rw-r--r--gnu/java/net/protocol/http/Response.java55
1 files changed, 36 insertions, 19 deletions
diff --git a/gnu/java/net/protocol/http/Response.java b/gnu/java/net/protocol/http/Response.java
index 29dc28b17..58d74542c 100644
--- a/gnu/java/net/protocol/http/Response.java
+++ b/gnu/java/net/protocol/http/Response.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.net.protocol.http;
+import java.io.InputStream;
import java.util.Date;
/**
@@ -64,19 +65,6 @@ public class Response
protected final int code;
/**
- * The class of the response. This is the most significant digit of the
- * status code.
- * <dl>
- * <dt><code>1xx</code></dt> <dd>Informational response</dd>
- * <dt><code>2xx</code></dt> <dd>Success</dd>
- * <dt><code>3xx</code></dt> <dd>Redirection</dd>
- * <dt><code>4xx</code></dt> <dd>Client error</dd>
- * <dt><code>5xx</code></dt> <dd>Server error</dd>
- * </dl>
- */
- protected final int codeClass;
-
- /**
* Human-readable text of the response.
*/
protected final String message;
@@ -87,18 +75,22 @@ public class Response
protected final Headers headers;
/**
+ * An InputStream that returns the body of the response.
+ */
+ protected final InputStream body;
+
+ /**
* Constructs a new response with the specified parameters.
*/
protected Response(int majorVersion, int minorVersion, int code,
- int codeClass, String message,
- Headers headers)
+ String message, Headers headers, InputStream body)
{
this.majorVersion = majorVersion;
this.minorVersion = minorVersion;
this.code = code;
- this.codeClass = codeClass;
this.message = message;
this.headers = headers;
+ this.body = body;
}
/**
@@ -129,12 +121,19 @@ public class Response
}
/**
- * Returns the class of the response.
- * @see #codeClass
+ * Returns the class of the response. This is the most significant
+ * digit of the status code.
+ * <dl>
+ * <dt><code>1xx</code></dt> <dd>Informational response</dd>
+ * <dt><code>2xx</code></dt> <dd>Success</dd>
+ * <dt><code>3xx</code></dt> <dd>Redirection</dd>
+ * <dt><code>4xx</code></dt> <dd>Client error</dd>
+ * <dt><code>5xx</code></dt> <dd>Server error</dd>
+ * </dl>
*/
public int getCodeClass()
{
- return codeClass;
+ return code / 100;
}
/**
@@ -173,6 +172,15 @@ public class Response
}
/**
+ * Returns the header value for the specified name as a long.
+ * @param name the header name
+ */
+ public long getLongHeader(String name)
+ {
+ return headers.getLongValue(name);
+ }
+
+ /**
* Returns the header value for the specified name as a date.
* @param name the header name
*/
@@ -181,5 +189,14 @@ public class Response
return headers.getDateValue(name);
}
+ /**
+ * Returns an InputStream that returns the body of the response.
+ *
+ * @return the body of the response
+ */
+ public InputStream getBody()
+ {
+ return body;
+ }
}