You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by su...@apache.org on 2002/09/03 00:04:13 UTC
cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient ChunkedInputStream.java
sullis 2002/09/02 15:04:13
Modified: httpclient/src/java/org/apache/commons/httpclient
ChunkedInputStream.java
Log:
added javadocs, renamed getChunkSize method, added parameter validation to the constructor
Revision Changes Path
1.2 +33 -7 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedInputStream.java
Index: ChunkedInputStream.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ChunkedInputStream.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ChunkedInputStream.java 2 Sep 2002 14:52:47 -0000 1.1
+++ ChunkedInputStream.java 2 Sep 2002 22:04:13 -0000 1.2
@@ -68,8 +68,14 @@
/**
* <p>Transparently coalesces chunks of a HTTP stream that uses Transfer-Encoding
* chunked.</p>
+ *
+ * @see ResponseInputStream
+ *
* @author Ortwin Gl�ck
+ * @author Sean C. Sullivan
+ *
* @since 2.0
+ *
*/
public class ChunkedInputStream extends InputStream {
@@ -79,10 +85,26 @@
private static final String HTTP_ENC = "US-ASCII";
private HttpMethod method;
- public ChunkedInputStream(InputStream in, HttpMethod method) throws IOException {
+ /**
+ *
+ *
+ * @param in must be non-null
+ * @param method must be non-null
+ *
+ * @throws java.io.IOException
+ * @throws java.lang.NullPointerException
+ *
+ */
+ public ChunkedInputStream(final InputStream in, final HttpMethod method) throws IOException {
+ if (null == in) {
+ throw new NullPointerException("InputStream parameter");
+ }
+ if (null == method) {
+ throw new NullPointerException("HttpMethod parameter");
+ }
this.in = in;
this.method = method;
- this.chunkSize = getChunkSize();
+ this.chunkSize = getChunkSizeFromInputStream(in);
this.pos = 0;
}
@@ -127,7 +149,7 @@
int lf = in.read();
if ((cr != '\r') &&
(lf != '\n')) throw new IOException("CRLF expected at end of chunk: "+cr+"/"+lf);
- chunkSize = getChunkSize();
+ chunkSize = getChunkSizeFromInputStream(in);
pos = 0;
if (chunkSize == 0) {
eof = true;
@@ -142,9 +164,13 @@
* Positions the stream at the start of the next line.
*
* @return the chunk size as integer
+ *
* @throws IOException when the chunk size could not be parsed
+ * @throws java.lang.RuntimeException
+ *
+ *
*/
- private int getChunkSize() throws IOException {
+ private static int getChunkSizeFromInputStream(final InputStream in) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b = in.read();
int state = 0;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>