You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2005/04/02 00:03:06 UTC
svn commit: r159740 - in jakarta/httpclient/trunk/http-common/src:
java/org/apache/http/ConnectTimeoutException.java
java/org/apache/http/io/ChunkedInputStream.java
java/org/apache/http/io/MalformedChunkCodingException.java
test/org/apache/http/io/TestChunkCoding.java
Author: olegk
Date: Fri Apr 1 14:03:05 2005
New Revision: 159740
URL: http://svn.apache.org/viewcvs?view=rev&rev=159740
Log:
Added MalformedChunkCodingException
Added:
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/MalformedChunkCodingException.java (with props)
Modified:
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java
jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/ChunkedInputStream.java
jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestChunkCoding.java
Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java?view=diff&r1=159739&r2=159740
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/ConnectTimeoutException.java Fri Apr 1 14:03:05 2005
@@ -1,5 +1,5 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/ConnectTimeoutException.java,v 1.5 2004/07/05 22:46:58 olegk Exp $
+ * $HeadURL$
* $Revision$
* $Date$
*
Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/ChunkedInputStream.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/ChunkedInputStream.java?view=diff&r1=159739&r2=159740
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/ChunkedInputStream.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/ChunkedInputStream.java Fri Apr 1 14:03:05 2005
@@ -182,7 +182,7 @@
int cr = in.read();
int lf = in.read();
if ((cr != '\r') || (lf != '\n')) {
- throw new IOException(
+ throw new MalformedChunkCodingException(
"CRLF expected at end of chunk: " + cr + "/" + lf);
}
}
@@ -227,7 +227,7 @@
while (state != -1) {
int b = in.read();
if (b == -1) {
- throw new IOException("Chunked stream ended unexpectedly");
+ throw new MalformedChunkCodingException("Chunked stream ended unexpectedly");
}
switch (state) {
case 0:
@@ -248,7 +248,7 @@
state = -1;
} else {
// this was not CRLF
- throw new IOException("Unexpected"
+ throw new MalformedChunkCodingException("Unexpected"
+ " single newline character in chunk size");
}
break;
@@ -281,7 +281,7 @@
try {
result = Integer.parseInt(dataString.trim(), 16);
} catch (NumberFormatException e) {
- throw new IOException ("Bad chunk size: " + dataString);
+ throw new MalformedChunkCodingException("Bad chunk size: " + dataString);
}
return result;
}
@@ -294,7 +294,8 @@
try {
this.footers = HeadersParser.processHeaders(in);
} catch (HttpException e) {
- IOException ioe = new IOException("Invalid footer: " + e.getMessage());
+ IOException ioe = new MalformedChunkCodingException("Invalid footer: "
+ + e.getMessage());
ExceptionUtil.initCause(ioe, e);
throw ioe;
}
Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/MalformedChunkCodingException.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/MalformedChunkCodingException.java?view=auto&rev=159740
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/MalformedChunkCodingException.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/MalformedChunkCodingException.java Fri Apr 1 14:03:05 2005
@@ -0,0 +1,55 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.io;
+
+import java.io.IOException;
+
+/**
+ * Signals a malformed chunked stream
+ */
+public class MalformedChunkCodingException extends IOException {
+
+ /**
+ * Creates a MalformedChunkCodingException with a <tt>null</tt> detail message.
+ */
+ public MalformedChunkCodingException() {
+ super();
+ }
+
+ /**
+ * Creates a MalformedChunkCodingException with the specified detail message.
+ *
+ * @param message The exception detail message
+ */
+ public MalformedChunkCodingException(final String message) {
+ super(message);
+ }
+
+}
Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/MalformedChunkCodingException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/MalformedChunkCodingException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/MalformedChunkCodingException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestChunkCoding.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestChunkCoding.java?view=diff&r1=159739&r2=159740
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestChunkCoding.java (original)
+++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestChunkCoding.java Fri Apr 1 14:03:05 2005
@@ -75,6 +75,8 @@
} catch (IllegalArgumentException ex) {
// expected
}
+ new MalformedChunkCodingException();
+ new MalformedChunkCodingException("");
}
private final static String CHUNKED_INPUT
@@ -197,8 +199,8 @@
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
- fail("IOException should have been thrown");
- } catch(IOException e) {
+ fail("MalformedChunkCodingException should have been thrown");
+ } catch(MalformedChunkCodingException e) {
/* expected exception */
}
}
@@ -211,8 +213,8 @@
EncodingUtil.getBytes(s, CONTENT_CHARSET)));
try {
in.read();
- fail("IOException should have been thrown");
- } catch(IOException e) {
+ fail("MalformedChunkCodingException should have been thrown");
+ } catch(MalformedChunkCodingException e) {
/* expected exception */
}
}
@@ -223,8 +225,8 @@
new ByteArrayInputStream(new byte[] {}));
try {
in.read();
- fail("IOException should have been thrown");
- } catch(IOException e) {
+ fail("MalformedChunkCodingException should have been thrown");
+ } catch(MalformedChunkCodingException e) {
/* expected exception */
}
}
@@ -237,8 +239,8 @@
EncodingUtil.getBytes(s, CONTENT_CHARSET)));
try {
in.read();
- fail("IOException should have been thrown");
- } catch(IOException e) {
+ fail("MalformedChunkCodingException should have been thrown");
+ } catch(MalformedChunkCodingException e) {
/* expected exception */
}
}
@@ -252,8 +254,8 @@
try {
in.read();
in.read();
- fail("IOException should have been thrown");
- } catch(IOException e) {
+ fail("MalformedChunkCodingException should have been thrown");
+ } catch(MalformedChunkCodingException e) {
/* expected exception */
}
}