hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rola...@apache.org
Subject svn commit: r569636 - in /jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http: Header.java impl/entity/LaxContentLengthStrategy.java message/BasicHeader.java message/BufferedHeader.java util/EntityUtils.java
Date Sat, 25 Aug 2007 07:34:48 GMT
Author: rolandw
Date: Sat Aug 25 00:34:47 2007
New Revision: 569636

URL: http://svn.apache.org/viewvc?rev=569636&view=rev
Log:
added declarations and handling of ParseException for header values

Modified:
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/Header.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHeader.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BufferedHeader.java
    jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/util/EntityUtils.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/Header.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/Header.java?rev=569636&r1=569635&r2=569636&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/Header.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/Header.java
Sat Aug 25 00:34:47 2007
@@ -59,6 +59,6 @@
     
     String getValue();
 
-    HeaderElement[] getElements();
+    HeaderElement[] getElements() throws ParseException;
     
 }

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java?rev=569636&r1=569635&r2=569636&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
Sat Aug 25 00:34:47 2007
@@ -35,6 +35,7 @@
 import org.apache.http.HeaderElement;
 import org.apache.http.HttpException;
 import org.apache.http.HttpMessage;
+import org.apache.http.ParseException;
 import org.apache.http.ProtocolException;
 import org.apache.http.entity.ContentLengthStrategy;
 import org.apache.http.params.HttpParams;
@@ -196,7 +197,14 @@
         // We use Transfer-Encoding if present and ignore Content-Length.
         // RFC2616, 4.4 item number 3
         if (transferEncodingHeader != null) {
-            HeaderElement[] encodings = transferEncodingHeader.getElements();
+            HeaderElement[] encodings = null;
+            try {
+                encodings = transferEncodingHeader.getElements();
+            } catch (ParseException px) {
+                throw new ProtocolException
+                    ("Invalid Transfer-Encoding header value: " +
+                     transferEncodingHeader, px);
+            }
             if (strict) {
                 // Currently only chunk and identity are supported
                 for (int i = 0; i < encodings.length; i++) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHeader.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHeader.java?rev=569636&r1=569635&r2=569636&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHeader.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicHeader.java
Sat Aug 25 00:34:47 2007
@@ -33,6 +33,7 @@
 
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.ParseException;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -129,8 +130,10 @@
      * @see BasicHeaderValueParser#parseElements
      * 
      * @return an array of header elements
+     *
+     * @throws ParseException   in case of a parse error
      */
-    public HeaderElement[] getElements() {
+    public HeaderElement[] getElements() throws ParseException {
         if (this.value != null) {
             // result intentionally not cached, it's probably not used again
             return BasicHeaderValueParser.parseElements(this.value, null);

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BufferedHeader.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BufferedHeader.java?rev=569636&r1=569635&r2=569636&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BufferedHeader.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BufferedHeader.java
Sat Aug 25 00:34:47 2007
@@ -126,7 +126,7 @@
         this.parser = parser;
     }
 
-    public HeaderElement[] getElements() {
+    public HeaderElement[] getElements() throws ParseException {
         HeaderValueParser hvp = this.parser;
         if (hvp == null)
             hvp = BasicHeaderValueParser.DEFAULT;

Modified: jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/util/EntityUtils.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/util/EntityUtils.java?rev=569636&r1=569635&r2=569636&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/util/EntityUtils.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/util/EntityUtils.java
Sat Aug 25 00:34:47 2007
@@ -39,6 +39,7 @@
 import org.apache.http.HeaderElement;
 import org.apache.http.HttpEntity;
 import org.apache.http.NameValuePair;
+import org.apache.http.ParseException;
 import org.apache.http.protocol.HTTP;
 
 /**
@@ -84,7 +85,9 @@
         return buffer.toByteArray();
     }
         
-    public static String getContentCharSet(final HttpEntity entity) {
+    public static String getContentCharSet(final HttpEntity entity)
+        throws ParseException {
+
         if (entity == null) {
             throw new IllegalArgumentException("HTTP entity may not be null");
         }
@@ -102,7 +105,7 @@
     }
 
     public static String toString(
-            final HttpEntity entity, final String defaultCharset) throws IOException {
+            final HttpEntity entity, final String defaultCharset) throws IOException, ParseException
{
         if (entity == null) {
             throw new IllegalArgumentException("HTTP entity may not be null");
         }



Mime
View raw message