hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r367047 - in /jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http: ./ impl/ io/ protocol/ util/
Date Sun, 08 Jan 2006 16:31:42 GMT
Author: olegk
Date: Sun Jan  8 08:31:24 2006
New Revision: 367047

URL: http://svn.apache.org/viewcvs?rev=367047&view=rev
Log:
Use definition of white space chars as in the HTTP spec

Modified:
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/NameValuePair.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/RequestLine.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/StatusLine.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/CharArrayBuffer.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HTTP.java
    jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java?rev=367047&r1=367046&r2=367047&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HttpVersion.java Sun Jan
 8 08:31:24 2006
@@ -30,6 +30,7 @@
 package org.apache.http;
 
 import org.apache.http.io.CharArrayBuffer;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.util.NumUtils;
 
 /**
@@ -238,7 +239,7 @@
             int major, minor;
 
             int i = indexFrom;
-            while (Character.isWhitespace(buffer.charAt(i))) {
+            while (HTTP.isWhitespace(buffer.charAt(i))) {
                 i++;
             }            
             if (buffer.charAt(i    ) != 'H' 

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/NameValuePair.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/NameValuePair.java?rev=367047&r1=367046&r2=367047&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/NameValuePair.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/NameValuePair.java Sun
Jan  8 08:31:24 2006
@@ -33,6 +33,7 @@
 import java.util.List;
 
 import org.apache.http.io.CharArrayBuffer;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.util.LangUtils;
 
 /**
@@ -216,11 +217,11 @@
         int i1 = eq + 1;
         int i2 = indexTo;
         // Trim leading white spaces
-        while (i1 < i2 && (Character.isWhitespace(buffer.charAt(i1)))) {
+        while (i1 < i2 && (HTTP.isWhitespace(buffer.charAt(i1)))) {
             i1++;
         }
         // Trim trailing white spaces
-        while ((i2 > i1) && (Character.isWhitespace(buffer.charAt(i2 - 1)))) {
+        while ((i2 > i1) && (HTTP.isWhitespace(buffer.charAt(i2 - 1)))) {
             i2--;
         }
         // Strip away quotes if necessary

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/RequestLine.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/RequestLine.java?rev=367047&r1=367046&r2=367047&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/RequestLine.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/RequestLine.java Sun Jan
 8 08:31:24 2006
@@ -30,6 +30,7 @@
 package org.apache.http;
 
 import org.apache.http.io.CharArrayBuffer;
+import org.apache.http.protocol.HTTP;
 
 /**
  * <p>
@@ -101,7 +102,7 @@
         }
         try {
             int i = indexFrom;
-            while (Character.isWhitespace(buffer.charAt(i))) {
+            while (HTTP.isWhitespace(buffer.charAt(i))) {
                 i++;
             }
             int blank = buffer.indexOf(' ', i, indexTo);
@@ -111,7 +112,7 @@
             }
             String method = buffer.substringTrimmed(i, blank);
             i = blank;
-            while (Character.isWhitespace(buffer.charAt(i))) {
+            while (HTTP.isWhitespace(buffer.charAt(i))) {
                 i++;
             }
             blank = buffer.indexOf(' ', i, indexTo);

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/StatusLine.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/StatusLine.java?rev=367047&r1=367046&r2=367047&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/StatusLine.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/StatusLine.java Sun Jan
 8 08:31:24 2006
@@ -30,6 +30,7 @@
 package org.apache.http;
 
 import org.apache.http.io.CharArrayBuffer;
+import org.apache.http.protocol.HTTP;
 
 /**
  * Represents a Status-Line as returned from a HTTP server.
@@ -117,7 +118,7 @@
         try {
             int i = indexFrom;
             //handle the HTTP-Version
-            while (Character.isWhitespace(buffer.charAt(i))) {
+            while (HTTP.isWhitespace(buffer.charAt(i))) {
                 i++;
             }            
             int blank = buffer.indexOf(' ', i, indexTo);
@@ -130,7 +131,7 @@
 
             i = blank;
             //advance through spaces
-            while (Character.isWhitespace(buffer.charAt(i))) {
+            while (HTTP.isWhitespace(buffer.charAt(i))) {
                 i++;
             }            
 

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java?rev=367047&r1=367046&r2=367047&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
Sun Jan  8 08:31:24 2006
@@ -56,6 +56,7 @@
 import org.apache.http.io.SocketFactory;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.HTTP;
 
 /**
  * <p>
@@ -286,7 +287,7 @@
     private static boolean startsWithHTTP(final CharArrayBuffer buffer) {
         try {
             int i = 0;
-            while (Character.isWhitespace(buffer.charAt(i))) {
+            while (HTTP.isWhitespace(buffer.charAt(i))) {
                 ++i;
             }
             return buffer.charAt(i) == 'H' 

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/CharArrayBuffer.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/CharArrayBuffer.java?rev=367047&r1=367046&r2=367047&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/CharArrayBuffer.java
(original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/io/CharArrayBuffer.java
Sun Jan  8 08:31:24 2006
@@ -29,6 +29,8 @@
 
 package org.apache.http.io;
 
+import org.apache.http.protocol.HTTP;
+
 /**
  * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * 
@@ -242,10 +244,10 @@
         if (beginIndex > endIndex) {
             throw new IndexOutOfBoundsException();
         }
-        while (beginIndex < endIndex && Character.isWhitespace(this.buffer[beginIndex]))
{
+        while (beginIndex < endIndex && HTTP.isWhitespace(this.buffer[beginIndex]))
{
             beginIndex++;
         }
-        while (endIndex > beginIndex && Character.isWhitespace(this.buffer[endIndex
- 1])) {
+        while (endIndex > beginIndex && HTTP.isWhitespace(this.buffer[endIndex
- 1])) {
             endIndex--;
         }
         return new String(this.buffer, beginIndex, endIndex - beginIndex);

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HTTP.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HTTP.java?rev=367047&r1=367046&r2=367047&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HTTP.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/protocol/HTTP.java Sun
Jan  8 08:31:24 2006
@@ -40,8 +40,10 @@
  */
 public class HTTP {
 
-    public static final int CR = 13;
-    public static final int LF = 10;
+    public static final int CR = 13; // <US-ASCII CR, carriage return (13)>
+    public static final int LF = 10; // <US-ASCII LF, linefeed (10)>
+    public static final int SP = 32; // <US-ASCII SP, space (32)>
+    public static final int HT = 9;  // <US-ASCII HT, horizontal-tab (9)>
     public static final byte[] CRLF = new byte[] {CR, LF};
 
     /** HTTP header definitions */ 
@@ -86,6 +88,10 @@
     /** Default content type */
     public final static String DEFAULT_CONTENT_TYPE = OCTET_STREAM_TYPE;
 
+    public static boolean isWhitespace(char ch) {
+        return ch == SP || ch == HT || ch == CR || ch == LF; 
+    }
+    
     private HTTP() {
     }
        

Modified: jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java?rev=367047&r1=367046&r2=367047&view=diff
==============================================================================
--- jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java (original)
+++ jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/util/NumUtils.java Sun
Jan  8 08:31:24 2006
@@ -1,6 +1,7 @@
 package org.apache.http.util;
 
 import org.apache.http.io.CharArrayBuffer;
+import org.apache.http.protocol.HTTP;
 
 public class NumUtils {
 
@@ -31,10 +32,10 @@
         }
         int i1 = indexFrom;
         int i2 = indexTo;
-        while (i1 < indexTo && Character.isWhitespace(buffer.charAt(i1))) {
+        while (i1 < indexTo && HTTP.isWhitespace(buffer.charAt(i1))) {
             i1++;
         }
-        while (i2 > i1 && Character.isWhitespace(buffer.charAt(i2 - 1))) {
+        while (i2 > i1 && HTTP.isWhitespace(buffer.charAt(i2 - 1))) {
             i2--;
         }
         if (i1 == i2) {



Mime
View raw message