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 2006/07/02 14:18:09 UTC

svn commit: r418582 [1/2] - in /jakarta/httpcomponents/httpcore/trunk/src: java/org/apache/http/ java/org/apache/http/impl/ java/org/apache/http/message/ java/org/apache/http/protocol/ test/org/apache/http/ test/org/apache/http/impl/ test/org/apache/ht...

Author: olegk
Date: Sun Jul  2 05:18:08 2006
New Revision: 418582

URL: http://svn.apache.org/viewvc?rev=418582&view=rev
Log:
[HTTPCORE-5] Made NameValuePair, StatusLine, RequestLine interfaces

Added:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpVersion.java
      - copied, changed from r418580, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicNameValuePair.java
      - copied, changed from r418580, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicRequestLine.java
      - copied, changed from r418580, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicStatusLine.java
      - copied, changed from r418580, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java
Modified:
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpResponse.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpResponseFactory.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpServerConnection.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpRequest.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpResponse.java
    jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpVersion.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestNameValuePair.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestRequestLine.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestStatusLine.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/impl/TestBasicRequest.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java
    jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/protocol/TestStandardInterceptors.java

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpResponse.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpResponse.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpResponse.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpResponse.java Sun Jul  2 05:18:08 2006
@@ -53,6 +53,13 @@
     void setStatusLine(StatusLine statusline);
     
     /**
+     * Sets the status line that belongs to this response.
+     * @param ver the HTTP version.
+     * @param code the HTTP status code.
+     */
+    void setStatusLine(HttpVersion ver, int code);
+    
+    /**
      * Convenience method that creates and sets a new status line of this
      * response that is initialized with the specified status code.
      * 

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java Sun Jul  2 05:18:08 2006
@@ -30,7 +30,6 @@
 package org.apache.http;
 
 import org.apache.http.io.CharArrayBuffer;
-import org.apache.http.protocol.HTTP;
 
 /**
  *  <p>HTTP version, as specified in RFC 2616.</p>
@@ -212,96 +211,4 @@
         return buffer.toString();
     }
 
-    /**
-     * Parses the textual representation of the given HTTP protocol version.
-     * 
-     * @return HTTP protocol version.
-     * 
-     * @throws ProtocolException if the string is not a valid HTTP protocol version. 
-     */
-    public static HttpVersion parse(
-            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) 
-            throws ProtocolException {
-        if (buffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
-        if (indexFrom < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexTo > buffer.length()) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexFrom > indexTo) {
-            throw new IndexOutOfBoundsException();
-        }
-        try {
-            int major, minor;
-
-            int i = indexFrom;
-            while (HTTP.isWhitespace(buffer.charAt(i))) {
-                i++;
-            }            
-            if (buffer.charAt(i    ) != 'H' 
-             || buffer.charAt(i + 1) != 'T'
-             || buffer.charAt(i + 2) != 'T'
-             || buffer.charAt(i + 3) != 'P'
-             || buffer.charAt(i + 4) != '/') {
-                throw new ProtocolException("Not a valid HTTP version string: " + 
-                        buffer.substring(indexFrom, indexTo));
-            }
-            i += 5;
-            int period = buffer.indexOf('.', i, indexTo);
-            if (period == -1) {
-                throw new ProtocolException("Invalid HTTP version number: " + 
-                        buffer.substring(indexFrom, indexTo));
-            }
-            try {
-                major = Integer.parseInt(buffer.substringTrimmed(i, period)); 
-            } catch (NumberFormatException e) {
-                throw new ProtocolException("Invalid HTTP major version number: " + 
-                        buffer.substring(indexFrom, indexTo));
-            }
-            try {
-                minor = Integer.parseInt(buffer.substringTrimmed(period + 1, indexTo)); 
-            } catch (NumberFormatException e) {
-                throw new ProtocolException("Invalid HTTP minor version number: " + 
-                        buffer.substring(indexFrom, indexTo));
-            }
-            return new HttpVersion(major, minor);
-            
-        } catch (IndexOutOfBoundsException e) {
-            throw new ProtocolException("Invalid HTTP version string: " + 
-                    buffer.substring(indexFrom, indexTo)); 
-        }
-    }
-
-    public static final HttpVersion parse(final String s)
-            throws ProtocolException {
-        if (s == null) {
-            throw new IllegalArgumentException("String may not be null");
-        }
-        CharArrayBuffer buffer = new CharArrayBuffer(s.length()); 
-        buffer.append(s);
-        return parse(buffer, 0, buffer.length());
-    }
-
-    public static void format(final CharArrayBuffer buffer, final HttpVersion ver) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("String buffer may not be null");
-        }
-        if (ver == null) {
-            throw new IllegalArgumentException("Version may not be null");
-        }
-        buffer.append("HTTP/"); 
-        buffer.append(Integer.toString(ver.getMajor())); 
-        buffer.append('.'); 
-        buffer.append(Integer.toString(ver.getMinor())); 
-    }
- 
-    public static String format(final HttpVersion ver) {
-        CharArrayBuffer buffer = new CharArrayBuffer(16);
-        format(buffer, ver);
-        return buffer.toString();
-    }
-        
 }

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java Sun Jul  2 05:18:08 2006
@@ -29,13 +29,6 @@
 
 package org.apache.http;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.http.io.CharArrayBuffer;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.LangUtils;
-
 /**
  * A simple class encapsulating an attribute/value pair.
  * <p>
@@ -104,329 +97,10 @@
  * @author <a href="mailto:oleg at ural.com">Oleg Kalnichevski</a>
  * 
  */
-public class NameValuePair {
-
-    private final String name;
-    private final String value;
-
-    /**
-     * Default Constructor taking a name and a value. The value may be null.
-     * 
-     * @param name The name.
-     * @param value The value.
-     */
-    public NameValuePair(final String name, final String value) {
-        super();
-        if (name == null) {
-            throw new IllegalArgumentException("Name may not be null");
-        }
-        this.name = name;
-        this.value = value;
-    }
-
-    /**
-     * Returns the name.
-     *
-     * @return String name The name
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    /**
-     * Returns the value.
-     *
-     * @return String value The current value.
-     */
-    public String getValue() {
-        return this.value;
-    }
-
-    public static final NameValuePair[] parseAll(
-            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
-        if (indexFrom < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexTo > buffer.length()) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexFrom > indexTo) {
-            throw new IndexOutOfBoundsException();
-        }
-        List params = new ArrayList(); 
-        int cur = indexFrom;
-        int from = indexFrom;
-        boolean qouted = false;
-        boolean escaped = false;
-        while (cur < indexTo) {
-            char ch = buffer.charAt(cur);
-            if (ch == '"' && !escaped) {
-                qouted = !qouted;
-            }
-            NameValuePair param = null;
-            if (!qouted && ch == ';') {
-                param = parse(buffer, from, cur);
-                from = cur + 1;
-            } else if (cur == indexTo - 1) {
-                param = parse(buffer, from, indexTo);
-            }
-            if (param != null && !(param.getName().equals("") && param.getValue() == null)) {
-                params.add(param);
-            }
-            if (escaped) {
-                escaped = false;
-            } else {
-                escaped = qouted && ch == '\\';
-            }
-            cur++;
-        }
-        return (NameValuePair[]) params.toArray(new NameValuePair[params.size()]);
-    }
-    
-    public static final NameValuePair[] parseAll(final String s) {
-        if (s == null) {
-            throw new IllegalArgumentException("String may not be null");
-        }
-        CharArrayBuffer buffer = new CharArrayBuffer(s.length());
-        buffer.append(s);
-        return parseAll(buffer, 0, buffer.length());
-    }
-
-    public static NameValuePair parse(
-            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
-        if (indexFrom < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexTo > buffer.length()) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexFrom > indexTo) {
-            throw new IndexOutOfBoundsException();
-        }
-        int eq = buffer.indexOf('=', indexFrom, indexTo);
-        if (eq < 0) {
-            return new NameValuePair(buffer.substringTrimmed(indexFrom, indexTo), null);
-        }
-        String name = buffer.substringTrimmed(indexFrom, eq);
-        int i1 = eq + 1;
-        int i2 = indexTo;
-        // Trim leading white spaces
-        while (i1 < i2 && (HTTP.isWhitespace(buffer.charAt(i1)))) {
-            i1++;
-        }
-        // Trim trailing white spaces
-        while ((i2 > i1) && (HTTP.isWhitespace(buffer.charAt(i2 - 1)))) {
-            i2--;
-        }
-        // Strip away quotes if necessary
-        if (((i2 - i1) >= 2) 
-            && (buffer.charAt(i1) == '"') 
-            && (buffer.charAt(i2 - 1) == '"')) {
-            i1++;
-            i2--;
-        }
-        String value = buffer.substring(i1, i2);
-        return new NameValuePair(name, value);
-    }
-
-    public static final NameValuePair parse(final String s) {
-        if (s == null) {
-            throw new IllegalArgumentException("String may not be null");
-        }
-        CharArrayBuffer buffer = new CharArrayBuffer(s.length());
-        buffer.append(s);
-        return parse(buffer, 0, buffer.length());
-    }
-
-    /**
-     * Special characters that can be used as separators in HTTP parameters.
-     * These special characters MUST be in a quoted string to be used within
-     * a parameter value 
-     */
-    private static final char[] SEPARATORS   = {
-            '(', ')', '<', '>', '@', 
-            ',', ';', ':', '\\', '"', 
-            '/', '[', ']', '?', '=',
-            '{', '}', ' ', '\t'
-            };
-    
-    /**
-     * Unsafe special characters that must be escaped using the backslash
-     * character
-     */
-    private static final char[] UNSAFE_CHARS = {
-            '"', '\\'
-            };
-    
-    private static boolean isOneOf(char[] chars, char ch) {
-        for (int i = 0; i < chars.length; i++) {
-            if (ch == chars[i]) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    private static boolean isUnsafeChar(char ch) {
-        return isOneOf(UNSAFE_CHARS, ch);
-    }
-    
-    private static boolean isSeparator(char ch) {
-        return isOneOf(SEPARATORS, ch);
-    }
-
-    private static void format(
-            final CharArrayBuffer buffer, 
-            final String value, 
-            boolean alwaysUseQuotes) {
-        boolean unsafe = false;
-        if (alwaysUseQuotes) {
-            unsafe = true;
-        } else {
-            for (int i = 0; i < value.length(); i++) {
-                if (isSeparator(value.charAt(i))) {
-                    unsafe = true;
-                    break;
-                }
-            }
-        }
-        if (unsafe) buffer.append('"');
-        for (int i = 0; i < value.length(); i++) {
-            char ch = value.charAt(i);
-            if (isUnsafeChar(ch)) {
-                buffer.append('\\');
-            }
-            buffer.append(ch);
-        }
-        if (unsafe) buffer.append('"');
-    }
-    
-    /**
-     * Produces textual representaion of the attribute/value pair using 
-     * formatting rules defined in RFC 2616
-     *  
-     * @param buffer output buffer 
-     * @param param the parameter to be formatted
-     * @param alwaysUseQuotes <tt>true</tt> if the parameter values must 
-     * always be enclosed in quotation marks, <tt>false</tt> otherwise
-     */
-    public static void format(
-            final CharArrayBuffer buffer, 
-            final NameValuePair param, 
-            boolean alwaysUseQuotes) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("String buffer may not be null");
-        }
-        if (param == null) {
-            throw new IllegalArgumentException("Parameter may not be null");
-        }
-        buffer.append(param.getName());
-        String value = param.getValue();
-        if (value != null) {
-            buffer.append("=");
-            format(buffer, value, alwaysUseQuotes);
-        }
-    }
-    
-    /**
-     * Produces textual representaion of the attribute/value pairs using 
-     * formatting rules defined in RFC 2616
-     *  
-     * @param buffer output buffer 
-     * @param params the parameters to be formatted
-     * @param alwaysUseQuotes <tt>true</tt> if the parameter values must 
-     * always be enclosed in quotation marks, <tt>false</tt> otherwise
-     */
-    public static void formatAll(
-            final CharArrayBuffer buffer, 
-            final NameValuePair[] params, 
-            boolean alwaysUseQuotes) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("String buffer may not be null");
-        }
-        if (params == null) {
-            throw new IllegalArgumentException("Array of parameter may not be null");
-        }
-        for (int i = 0; i < params.length; i++) {
-            if (i > 0) {
-                buffer.append("; ");
-            }
-            format(buffer, params[i], alwaysUseQuotes);
-        }
-    }
-    
-    /**
-     * Produces textual representaion of the attribute/value pair using 
-     * formatting rules defined in RFC 2616
-     *  
-     * @param param the parameter to be formatted
-     * @param alwaysUseQuotes <tt>true</tt> if the parameter values must 
-     * always be enclosed in quotation marks, <tt>false</tt> otherwise
-     * 
-     * @return RFC 2616 conformant textual representaion of the 
-     * attribute/value pair
-     */
-    public static String format(final NameValuePair param, boolean alwaysUseQuotes) {
-        CharArrayBuffer buffer = new CharArrayBuffer(16);
-        format(buffer, param, alwaysUseQuotes);
-        return buffer.toString();
-    }
-    
-    /**
-     * Produces textual representaion of the attribute/value pair using 
-     * formatting rules defined in RFC 2616
-     *  
-     * @param params the parameters to be formatted
-     * @param alwaysUseQuotes <tt>true</tt> if the parameter values must 
-     * always be enclosed in quotation marks, <tt>false</tt> otherwise
-     * 
-     * @return RFC 2616 conformant textual representaion of the 
-     * attribute/value pair
-     */
-    public static String formatAll(final NameValuePair[] params, boolean alwaysUseQuotes) {
-        CharArrayBuffer buffer = new CharArrayBuffer(16);
-        formatAll(buffer, params, alwaysUseQuotes);
-        return buffer.toString();
-    }
-    
-    /**
-     * Get a string representation of this pair.
-     * 
-     * @return A string representation.
-     */
-    public String toString() {
-        CharArrayBuffer buffer = new CharArrayBuffer(16);
-        buffer.append(this.name);
-        if (this.value != null) {
-            buffer.append("=");
-            format(buffer, this.value, false);
-        }
-        return buffer.toString();
-    }
+public interface NameValuePair {
 
-    public boolean equals(final Object object) {
-        if (object == null) return false;
-        if (this == object) return true;
-        if (object instanceof NameValuePair) {
-            NameValuePair that = (NameValuePair) object;
-            return this.name.equals(that.name)
-                  && LangUtils.equals(this.value, that.value);
-        } else {
-            return false;
-        }
-    }
+    String getName();
 
-    public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.name);
-        hash = LangUtils.hashCode(hash, this.value);
-        return hash;
-    }
-    
+    String getValue();
+      
 }

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java Sun Jul  2 05:18:08 2006
@@ -29,9 +29,6 @@
 
 package org.apache.http;
 
-import org.apache.http.io.CharArrayBuffer;
-import org.apache.http.protocol.HTTP;
-
 /**
  * The first line of an {@link HttpRequest HttpRequest}.
  * It contains the method, URI, and HTTP version of the request.
@@ -43,122 +40,12 @@
  * 
  * @since 4.0
  */
-public class RequestLine {
-
-    private final HttpVersion httpversion;
-    private final String method;
-    private final String uri;
-
-    public RequestLine(final String method, final String uri, final HttpVersion httpversion) {
-        	super();
-        	if (method == null) {
-        	    throw new IllegalArgumentException("Method may not be null");
-        	}
-        	if (uri == null) {
-        		throw new IllegalArgumentException("URI may not be null");
-        	}
-        	if (httpversion == null) {
-        		throw new IllegalArgumentException("HTTP version may not be null");
-        	}
-        	this.method = method;
-        this.uri = uri;
-        this.httpversion = httpversion;
-    }
-
-    public String getMethod() {
-        return this.method;
-    }
-
-    public HttpVersion getHttpVersion() {
-        return this.httpversion;
-    }
+public interface RequestLine {
 
-    public String getUri() {
-        return this.uri;
-    }
+    String getMethod();
 
-    public String toString() {
-        CharArrayBuffer buffer = new CharArrayBuffer(64);
-        buffer.append(this.method);
-        buffer.append(' ');
-        buffer.append(this.uri);
-        buffer.append(' ');
-        buffer.append(this.httpversion);
-        return buffer.toString();
-    }
-    
-    public static RequestLine parse(
-            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) 
-            throws ProtocolException {
-        if (buffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
-        if (indexFrom < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexTo > buffer.length()) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexFrom > indexTo) {
-            throw new IndexOutOfBoundsException();
-        }
-        try {
-            int i = indexFrom;
-            while (HTTP.isWhitespace(buffer.charAt(i))) {
-                i++;
-            }
-            int blank = buffer.indexOf(' ', i, indexTo);
-            if (blank < 0) {
-                throw new ProtocolException("Invalid request line: " + 
-                        buffer.substring(indexFrom, indexTo));
-            }
-            String method = buffer.substringTrimmed(i, blank);
-            i = blank;
-            while (HTTP.isWhitespace(buffer.charAt(i))) {
-                i++;
-            }
-            blank = buffer.indexOf(' ', i, indexTo);
-            if (blank < 0) {
-                throw new ProtocolException("Invalid request line: " + 
-                        buffer.substring(indexFrom, indexTo));
-            }
-            String uri = buffer.substringTrimmed(i, blank);
-            HttpVersion ver = HttpVersion.parse(buffer, blank, indexTo);
-            return new RequestLine(method, uri, ver);
-        } catch (IndexOutOfBoundsException e) {
-            throw new ProtocolException("Invalid request line: " + 
-                    buffer.substring(indexFrom, indexTo)); 
-        }
-    }
+    HttpVersion getHttpVersion();
 
-    public static final RequestLine parse(final String s)
-            throws ProtocolException {
-        if (s == null) {
-            throw new IllegalArgumentException("String may not be null");
-        }
-        CharArrayBuffer buffer = new CharArrayBuffer(s.length()); 
-        buffer.append(s);
-        return parse(buffer, 0, buffer.length());
-    }
-    
-    public static void format(final CharArrayBuffer buffer, final RequestLine requestline) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("String buffer may not be null");
-        }
-        if (requestline == null) {
-            throw new IllegalArgumentException("Request line may not be null");
-        }
-        buffer.append(requestline.getMethod());
-        buffer.append(' ');
-        buffer.append(requestline.getUri());
-        buffer.append(' ');
-        HttpVersion.format(buffer, requestline.getHttpVersion());
-    }
- 
-    public static String format(final RequestLine requestline) {
-        CharArrayBuffer buffer = new CharArrayBuffer(64);
-        format(buffer, requestline);
-        return buffer.toString();
-    }
+    String getUri();
     
 }

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java Sun Jul  2 05:18:08 2006
@@ -29,9 +29,6 @@
 
 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.
  *
@@ -57,179 +54,12 @@
  * 
  * @since 2.0
  */
-public class StatusLine {
-
-    // ----------------------------------------------------- Instance Variables
-
-    /** The HTTP-Version. */
-    private final HttpVersion httpVersion;
-
-    /** The Status-Code. */
-    private final int statusCode;
-
-    /** The Reason-Phrase. */
-    private final String reasonPhrase;
-
-    // ----------------------------------------------------------- Constructors
-    /**
-     * Default constructor
-     */
-    public StatusLine(final HttpVersion httpVersion, int statusCode, final String reasonPhrase) {
-        super();
-        if (httpVersion == null) {
-            throw new IllegalArgumentException("HTTP version may not be null");
-        }
-        if (statusCode < 0) {
-            throw new IllegalArgumentException("Status code may not be negative");
-        }
-        this.httpVersion = httpVersion;
-        this.statusCode = statusCode;
-        this.reasonPhrase = reasonPhrase;
-    }
-
-    public StatusLine(final HttpVersion httpVersion, int statusCode) {
-        this(httpVersion, statusCode, HttpStatus.getStatusText(statusCode));
-    }
-
-    /**
-     * Parses the status line returned from the HTTP server.
-     *
-     * @param buffer    the buffer from which to parse
-     * @param indexFrom where to start parsing in the buffer
-     * @param indexTo   where to stop parsing in the buffer
-     * 
-     * @throws HttpException if the status line is invalid
-     * 
-     * @since 4.0 
-     */
-    public static StatusLine parse(
-            final CharArrayBuffer buffer, final int indexFrom, final int indexTo) 
-            throws ProtocolException {
-        if (buffer == null) {
-            throw new IllegalArgumentException("Char array buffer may not be null");
-        }
-        if (indexFrom < 0) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexTo > buffer.length()) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (indexFrom > indexTo) {
-            throw new IndexOutOfBoundsException();
-        }
-        try {
-            int i = indexFrom;
-            //handle the HTTP-Version
-            while (HTTP.isWhitespace(buffer.charAt(i))) {
-                i++;
-            }            
-            int blank = buffer.indexOf(' ', i, indexTo);
-            if (blank <= 0) {
-                throw new ProtocolException(
-                        "Unable to parse HTTP-Version from the status line: "
-                        + buffer.substring(indexFrom, indexTo));
-            }
-            HttpVersion ver = HttpVersion.parse(buffer, i, blank);
-
-            i = blank;
-            //advance through spaces
-            while (HTTP.isWhitespace(buffer.charAt(i))) {
-                i++;
-            }            
-
-            //handle the Status-Code
-            blank = buffer.indexOf(' ', i, indexTo);
-            if (blank < 0) {
-                blank = indexTo;
-            }
-            int statusCode = 0;
-            try {
-                statusCode = Integer.parseInt(buffer.substringTrimmed(i, blank));
-            } catch (NumberFormatException e) {
-                throw new ProtocolException(
-                    "Unable to parse status code from status line: " 
-                    + buffer.substring(indexFrom, indexTo));
-            }
-            //handle the Reason-Phrase
-            i = blank;
-            String reasonPhrase = null;
-            if (i < indexTo) {
-                reasonPhrase = buffer.substringTrimmed(i, indexTo);
-            } else {
-                reasonPhrase = "";
-            }
-            return new StatusLine(ver, statusCode, reasonPhrase);
-        } catch (IndexOutOfBoundsException e) {
-            throw new ProtocolException("Invalid status line: " + 
-                    buffer.substring(indexFrom, indexTo)); 
-        }
-    }
-
-    public static final StatusLine parse(final String s)
-            throws ProtocolException {
-        if (s == null) {
-            throw new IllegalArgumentException("String may not be null");
-        }
-        CharArrayBuffer buffer = new CharArrayBuffer(s.length()); 
-        buffer.append(s);
-        return parse(buffer, 0, buffer.length());
-    }
-
-    // --------------------------------------------------------- Public Methods
-
-    /**
-     * @return the Status-Code
-     */
-    public final int getStatusCode() {
-        return this.statusCode;
-    }
+public interface StatusLine {
 
-    /**
-     * @return the HTTP-Version
-     */
-    public final HttpVersion getHttpVersion() {
-        return this.httpVersion;
-    }
+    HttpVersion getHttpVersion();
 
-    /**
-     * @return the Reason-Phrase
-     */
-    public final String getReasonPhrase() {
-        return this.reasonPhrase;
-    }
+    int getStatusCode();
 
-    public final String toString() {
-    	CharArrayBuffer buffer = new CharArrayBuffer(64);        
-        buffer.append(this.httpVersion);
-        buffer.append(' ');
-        buffer.append(Integer.toString(this.statusCode));
-        if (this.reasonPhrase != null && !this.reasonPhrase.equals("")) {
-            buffer.append(' ');
-            buffer.append(this.reasonPhrase);
-        }
-        return buffer.toString();
-    }
-    
-    public static void format(final CharArrayBuffer buffer, final StatusLine statusline) {
-        if (buffer == null) {
-            throw new IllegalArgumentException("String buffer may not be null");
-        }
-        if (statusline == null) {
-            throw new IllegalArgumentException("Status line may not be null");
-        }
-        HttpVersion.format(buffer, statusline.getHttpVersion());
-        buffer.append(' ');
-        buffer.append(Integer.toString(statusline.getStatusCode()));
-        if (statusline.getReasonPhrase() != null) {
-            buffer.append(' ');
-            buffer.append(statusline.getReasonPhrase());
-        }
-    }
- 
-    public static String format(final StatusLine statusline) {
-        CharArrayBuffer buffer = new CharArrayBuffer(32);
-        format(buffer, statusline);
-        return buffer.toString();
-    }
+    String getReasonPhrase();
     
 }

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpClientConnection.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpClientConnection.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpClientConnection.java Sun Jul  2 05:18:08 2006
@@ -45,7 +45,6 @@
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.NoHttpResponseException;
 import org.apache.http.ProtocolException;
-import org.apache.http.RequestLine;
 import org.apache.http.StatusLine;
 import org.apache.http.entity.EntityDeserializer;
 import org.apache.http.entity.EntitySerializer;
@@ -54,6 +53,8 @@
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.io.SocketFactory;
 import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicRequestLine;
+import org.apache.http.message.BasicStatusLine;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
@@ -199,7 +200,7 @@
     protected void sendRequestLine(final HttpRequest request) 
             throws HttpException, IOException {
         this.buffer.clear();
-        RequestLine.format(this.buffer, request.getRequestLine());
+        BasicRequestLine.format(this.buffer, request.getRequestLine());
         this.datatransmitter.writeLine(this.buffer);
     }
 
@@ -282,7 +283,7 @@
             count++;
         } while(true);
         //create the status line from the status string
-        StatusLine statusline = StatusLine.parse(this.buffer, 0, this.buffer.length());
+        StatusLine statusline = BasicStatusLine.parse(this.buffer, 0, this.buffer.length());
         HttpResponse response = this.responsefactory.newHttpResponse(statusline);
         response.getParams().setDefaults(params);
         return response;

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpResponseFactory.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpResponseFactory.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpResponseFactory.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpResponseFactory.java Sun Jul  2 05:18:08 2006
@@ -35,6 +35,7 @@
 import org.apache.http.HttpVersion;
 import org.apache.http.StatusLine;
 import org.apache.http.message.BasicHttpResponse;
+import org.apache.http.message.BasicStatusLine;
 
 /**
  * Default implementation of a factory for creating response objects.
@@ -55,7 +56,7 @@
         if (ver == null) {
             throw new IllegalArgumentException("HTTP version may not be null");
         }
-        StatusLine statusline = new StatusLine(ver, status, HttpStatus.getStatusText(status)); 
+        StatusLine statusline = new BasicStatusLine(ver, status, HttpStatus.getStatusText(status)); 
         return new BasicHttpResponse(statusline); 
     }
     

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpServerConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpServerConnection.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpServerConnection.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/impl/DefaultHttpServerConnection.java Sun Jul  2 05:18:08 2006
@@ -43,13 +43,14 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpServerConnection;
 import org.apache.http.RequestLine;
-import org.apache.http.StatusLine;
 import org.apache.http.entity.EntityDeserializer;
 import org.apache.http.entity.EntitySerializer;
 import org.apache.http.impl.entity.DefaultEntityDeserializer;
 import org.apache.http.impl.entity.DefaultEntitySerializer;
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicRequestLine;
+import org.apache.http.message.BasicStatusLine;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.util.HeaderUtils;
@@ -139,7 +140,7 @@
         if (i == -1) {
             throw new ConnectionClosedException("Client closed connection"); 
         }
-        RequestLine requestline = RequestLine.parse(this.buffer, 0, this.buffer.length());
+        RequestLine requestline = BasicRequestLine.parse(this.buffer, 0, this.buffer.length());
         HttpRequest request = this.requestfactory.newHttpRequest(requestline);
         request.getParams().setDefaults(params);
         return request;
@@ -180,7 +181,7 @@
     protected void sendResponseStatusLine(final HttpResponse response) 
             throws HttpException, IOException {
         this.buffer.clear();
-        StatusLine.format(this.buffer, response.getStatusLine());
+        BasicStatusLine.format(this.buffer, response.getStatusLine());
         this.datatransmitter.writeLine(this.buffer);
     }
 

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHeaderElement.java Sun Jul  2 05:18:08 2006
@@ -264,7 +264,7 @@
         if (indexFrom > indexTo) {
             throw new IndexOutOfBoundsException();
         }
-        NameValuePair[] nvps = NameValuePair.parseAll(buffer, indexFrom, indexTo);
+        NameValuePair[] nvps = BasicNameValuePair.parseAll(buffer, indexFrom, indexTo);
         return new BasicHeaderElement(nvps);
     }
 
@@ -294,7 +294,7 @@
         NameValuePair[] params = element.getParameters();
         for (int i = 0; i < params.length; i++) {
             buffer.append("; ");
-            NameValuePair.format(buffer, params[i], false);
+            BasicNameValuePair.format(buffer, params[i], false);
         }
     }
     

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpEntityEnclosingRequest.java Sun Jul  2 05:18:08 2006
@@ -32,6 +32,7 @@
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpVersion;
 import org.apache.http.RequestLine;
 import org.apache.http.protocol.HTTP;
 
@@ -51,6 +52,11 @@
     
     public BasicHttpEntityEnclosingRequest(final String method, final String uri) {
         super(method, uri);
+    }
+
+    public BasicHttpEntityEnclosingRequest(final String method, final String uri, 
+            final HttpVersion ver) {
+        this(new BasicRequestLine(method, uri, ver));
     }
 
     public BasicHttpEntityEnclosingRequest(final RequestLine requestline) {

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpRequest.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpRequest.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpRequest.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpRequest.java Sun Jul  2 05:18:08 2006
@@ -62,6 +62,10 @@
         this.requestline = null;
     }
 
+    public BasicHttpRequest(final String method, final String uri, final HttpVersion ver) {
+        this(new BasicRequestLine(method, uri, ver));
+    }
+
     public BasicHttpRequest(final RequestLine requestline) {
         super();
         if (requestline == null) {
@@ -85,7 +89,7 @@
             return this.requestline;
         } else {
             HttpVersion ver = HttpProtocolParams.getVersion(getParams());
-            return new RequestLine(this.method, this.uri, ver);
+            return new BasicRequestLine(this.method, this.uri, ver);
         }
     }
     

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpResponse.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpResponse.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpResponse.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpResponse.java Sun Jul  2 05:18:08 2006
@@ -60,6 +60,11 @@
         setStatusLine(statusline);
     }
 
+    public BasicHttpResponse(final HttpVersion ver, final int code) {
+        super();
+        setStatusLine(ver, code);
+    }
+
     public HttpVersion getHttpVersion() {
         return this.statusline.getHttpVersion();
     }
@@ -79,11 +84,18 @@
         this.statusline = statusline;
     }
     
+    public void setStatusLine(final HttpVersion ver, final int code) {
+        if (ver == null) {
+            throw new IllegalArgumentException("HTTP version may not be null");
+        }
+        this.statusline = new BasicStatusLine(ver, code);
+    }
+    
     public void setStatusCode(int code) {
         if (code < 0) {
             throw new IllegalArgumentException("Status line may not be null");
         }
-        this.statusline = new StatusLine(
+        this.statusline = new BasicStatusLine(
                 HttpProtocolParams.getVersion(getParams()), 
                 code, HttpStatus.getStatusText(code));
     }

Copied: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpVersion.java (from r418580, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpVersion.java?p2=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpVersion.java&p1=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java&r1=418580&r2=418582&rev=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/HttpVersion.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicHttpVersion.java Sun Jul  2 05:18:08 2006
@@ -27,66 +27,15 @@
  *
  */
 
-package org.apache.http;
+package org.apache.http.message;
 
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolException;
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.protocol.HTTP;
 
-/**
- *  <p>HTTP version, as specified in RFC 2616.</p>
- *  <p>
- *  HTTP uses a "&lt;major&gt;.&lt;minor&gt;" numbering scheme to indicate
- *  versions of the protocol. The protocol versioning policy is intended to
- *  allow the sender to indicate the format of a message and its capacity for
- *  understanding further HTTP communication, rather than the features
- *  obtained via that communication. No change is made to the version
- *  number for the addition of message components which do not affect
- *  communication behavior or which only add to extensible field values.
- *  The &lt;minor&gt; number is incremented when the changes made to the
- *  protocol add features which do not change the general message parsing
- *  algorithm, but which may add to the message semantics and imply
- *  additional capabilities of the sender. The &lt;major&gt; number is
- *  incremented when the format of a message within the protocol is
- *  changed. See RFC 2145 [36] for a fuller explanation.
- *  </p>
- *  <p>
- *  The version of an HTTP message is indicated by an HTTP-Version field
- *  in the first line of the message.
- *  </p>
- *  <pre>
- *     HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
- *  </pre>
- *  <p>
- *   Note that the major and minor numbers MUST be treated as separate
- *   integers and that each MAY be incremented higher than a single digit.
- *   Thus, HTTP/2.4 is a lower version than HTTP/2.13, which in turn is
- *   lower than HTTP/12.3. Leading zeros MUST be ignored by recipients and
- *   MUST NOT be sent.
- *  </p>
- * 
- * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
- * 
- * @version $Revision$ $Date$
- *
- * @since 3.0
- */
-public class HttpVersion implements Comparable {
+public class BasicHttpVersion extends HttpVersion {
 
-    /** Major version number of the HTTP protocol */
-    private int major = 0;
-
-    /** Minor version number of the HTTP protocol */
-    private int minor = 0;
-
-    /** HTTP protocol version 0.9 */
-    public static final HttpVersion HTTP_0_9 = new HttpVersion(0, 9);  
-
-    /** HTTP protocol version 1.0 */
-    public static final HttpVersion HTTP_1_0 = new HttpVersion(1, 0);  
-
-    /** HTTP protocol version 1.1 */
-    public static final HttpVersion HTTP_1_1 = new HttpVersion(1, 1);  
-    
     /**
      * Create an HTTP protocol version designator.
      *
@@ -95,123 +44,10 @@
      * 
      * @throws IllegalArgumentException if either major or minor version number is negative
      */
-    public HttpVersion(int major, int minor) {
-        if (major < 0) {
-            throw new IllegalArgumentException("HTTP major version number may not be negative");
-        }
-        this.major = major;
-        if (minor < 0) {
-            throw new IllegalArgumentException("HTTP minor version number may not be negative");
-        }
-        this.minor = minor;
+    public BasicHttpVersion(int major, int minor) {
+        super(major, minor);
     }
     
-    /**
-     * Returns the major version number of the HTTP protocol.
-     * 
-     * @return the major version number.
-     */
-    public int getMajor() {
-        return major;
-    }
-
-    /**
-     * Returns the minor version number of the HTTP protocol.
-     * 
-     * @return the minor version number.
-     */
-    public int getMinor() {
-        return minor;
-    }
-
-    /**
-     * @see java.lang.Object#hashCode()
-     */
-    public int hashCode() {
-        return this.major * 100000 + this.minor;
-    }
-        
-    /**
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof HttpVersion)) {
-            return false;
-        }
-        return equals((HttpVersion)obj);  
-    }
-
-    /**
-     * Compares this HTTP protocol version with another one.
-     * 
-     * @param anotherVer the version to be compared with.
-     *  
-     * @return a negative integer, zero, or a positive integer as this version is less than, 
-     *    equal to, or greater than the specified version.     
-     */
-    public int compareTo(HttpVersion anotherVer) {
-        if (anotherVer == null) {
-            throw new IllegalArgumentException("Version parameter may not be null"); 
-        }
-        int delta = getMajor() - anotherVer.getMajor();
-        if (delta == 0) {
-            delta = getMinor() - anotherVer.getMinor();
-        }
-        return delta;
-    }
-
-    /**
-     * @see java.lang.Comparable#compareTo(java.lang.Object)
-     */
-    public int compareTo(Object o) {
-        return compareTo((HttpVersion)o);
-    }
-
-    /**
-     * Test if the HTTP protocol version is equal to the given number.
-     * 
-     * @return <tt>true</tt> if HTTP protocol version is given to the given number, 
-     *         <tt>false</tt> otherwise.
-     */
-    public boolean equals(HttpVersion version) {
-        return compareTo(version) == 0;  
-    }
-
-    /**
-     * Test if the HTTP protocol version is greater or equal to the given number.
-     * 
-     * @return <tt>true</tt> if HTTP protocol version is greater or equal given to the 
-     *         given number, <tt>false</tt> otherwise.
-     */
-    public boolean greaterEquals(HttpVersion version) {
-        return compareTo(version) >= 0;
-    }
-
-    /**
-     * Test if the HTTP protocol version is less or equal to the given number.
-     * 
-     * @return <tt>true</tt> if HTTP protocol version is less or equal to given to the 
-     *         given number, <tt>false</tt> otherwise.
-     */
-    public boolean lessEquals(HttpVersion version) {
-        return compareTo(version) <= 0;
-    }
-
-    /**
-     * @see java.lang.Object#toString()
-     */
-    public String toString() {
-        CharArrayBuffer buffer = new CharArrayBuffer(16);
-        buffer.append("HTTP/"); 
-        buffer.append(Integer.toString(this.major)); 
-        buffer.append('.'); 
-        buffer.append(Integer.toString(this.minor)); 
-        return buffer.toString();
-    }
-
     /**
      * Parses the textual representation of the given HTTP protocol version.
      * 

Copied: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicNameValuePair.java (from r418580, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicNameValuePair.java?p2=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicNameValuePair.java&p1=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java&r1=418580&r2=418582&rev=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/NameValuePair.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicNameValuePair.java Sun Jul  2 05:18:08 2006
@@ -27,11 +27,12 @@
  *
  */
 
-package org.apache.http;
+package org.apache.http.message;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.http.NameValuePair;
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.protocol.HTTP;
 import org.apache.http.util.LangUtils;
@@ -104,7 +105,7 @@
  * @author <a href="mailto:oleg at ural.com">Oleg Kalnichevski</a>
  * 
  */
-public class NameValuePair {
+public class BasicNameValuePair implements NameValuePair {
 
     private final String name;
     private final String value;
@@ -115,7 +116,7 @@
      * @param name The name.
      * @param value The value.
      */
-    public NameValuePair(final String name, final String value) {
+    public BasicNameValuePair(final String name, final String value) {
         super();
         if (name == null) {
             throw new IllegalArgumentException("Name may not be null");
@@ -211,7 +212,7 @@
         }
         int eq = buffer.indexOf('=', indexFrom, indexTo);
         if (eq < 0) {
-            return new NameValuePair(buffer.substringTrimmed(indexFrom, indexTo), null);
+            return new BasicNameValuePair(buffer.substringTrimmed(indexFrom, indexTo), null);
         }
         String name = buffer.substringTrimmed(indexFrom, eq);
         int i1 = eq + 1;
@@ -232,7 +233,7 @@
             i2--;
         }
         String value = buffer.substring(i1, i2);
-        return new NameValuePair(name, value);
+        return new BasicNameValuePair(name, value);
     }
 
     public static final NameValuePair parse(final String s) {
@@ -414,7 +415,7 @@
         if (object == null) return false;
         if (this == object) return true;
         if (object instanceof NameValuePair) {
-            NameValuePair that = (NameValuePair) object;
+            BasicNameValuePair that = (BasicNameValuePair) object;
             return this.name.equals(that.name)
                   && LangUtils.equals(this.value, that.value);
         } else {

Copied: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicRequestLine.java (from r418580, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicRequestLine.java?p2=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicRequestLine.java&p1=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java&r1=418580&r2=418582&rev=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/RequestLine.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicRequestLine.java Sun Jul  2 05:18:08 2006
@@ -27,8 +27,11 @@
  *
  */
 
-package org.apache.http;
+package org.apache.http.message;
 
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolException;
+import org.apache.http.RequestLine;
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.protocol.HTTP;
 
@@ -43,13 +46,13 @@
  * 
  * @since 4.0
  */
-public class RequestLine {
+public class BasicRequestLine implements RequestLine {
 
     private final HttpVersion httpversion;
     private final String method;
     private final String uri;
 
-    public RequestLine(final String method, final String uri, final HttpVersion httpversion) {
+    public BasicRequestLine(final String method, final String uri, final HttpVersion httpversion) {
         	super();
         	if (method == null) {
         	    throw new IllegalArgumentException("Method may not be null");
@@ -123,8 +126,8 @@
                         buffer.substring(indexFrom, indexTo));
             }
             String uri = buffer.substringTrimmed(i, blank);
-            HttpVersion ver = HttpVersion.parse(buffer, blank, indexTo);
-            return new RequestLine(method, uri, ver);
+            HttpVersion ver = BasicHttpVersion.parse(buffer, blank, indexTo);
+            return new BasicRequestLine(method, uri, ver);
         } catch (IndexOutOfBoundsException e) {
             throw new ProtocolException("Invalid request line: " + 
                     buffer.substring(indexFrom, indexTo)); 
@@ -152,7 +155,7 @@
         buffer.append(' ');
         buffer.append(requestline.getUri());
         buffer.append(' ');
-        HttpVersion.format(buffer, requestline.getHttpVersion());
+        BasicHttpVersion.format(buffer, requestline.getHttpVersion());
     }
  
     public static String format(final RequestLine requestline) {

Copied: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicStatusLine.java (from r418580, jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicStatusLine.java?p2=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicStatusLine.java&p1=jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java&r1=418580&r2=418582&rev=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/StatusLine.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/message/BasicStatusLine.java Sun Jul  2 05:18:08 2006
@@ -27,8 +27,12 @@
  *
  */
 
-package org.apache.http;
+package org.apache.http.message;
 
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolException;
+import org.apache.http.StatusLine;
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.protocol.HTTP;
 
@@ -57,7 +61,7 @@
  * 
  * @since 2.0
  */
-public class StatusLine {
+public class BasicStatusLine implements StatusLine {
 
     // ----------------------------------------------------- Instance Variables
 
@@ -74,7 +78,7 @@
     /**
      * Default constructor
      */
-    public StatusLine(final HttpVersion httpVersion, int statusCode, final String reasonPhrase) {
+    public BasicStatusLine(final HttpVersion httpVersion, int statusCode, final String reasonPhrase) {
         super();
         if (httpVersion == null) {
             throw new IllegalArgumentException("HTTP version may not be null");
@@ -87,7 +91,7 @@
         this.reasonPhrase = reasonPhrase;
     }
 
-    public StatusLine(final HttpVersion httpVersion, int statusCode) {
+    public BasicStatusLine(final HttpVersion httpVersion, int statusCode) {
         this(httpVersion, statusCode, HttpStatus.getStatusText(statusCode));
     }
 
@@ -129,7 +133,7 @@
                         "Unable to parse HTTP-Version from the status line: "
                         + buffer.substring(indexFrom, indexTo));
             }
-            HttpVersion ver = HttpVersion.parse(buffer, i, blank);
+            HttpVersion ver = BasicHttpVersion.parse(buffer, i, blank);
 
             i = blank;
             //advance through spaces
@@ -158,7 +162,7 @@
             } else {
                 reasonPhrase = "";
             }
-            return new StatusLine(ver, statusCode, reasonPhrase);
+            return new BasicStatusLine(ver, statusCode, reasonPhrase);
         } catch (IndexOutOfBoundsException e) {
             throw new ProtocolException("Invalid status line: " + 
                     buffer.substring(indexFrom, indexTo)); 
@@ -180,25 +184,25 @@
     /**
      * @return the Status-Code
      */
-    public final int getStatusCode() {
+    public int getStatusCode() {
         return this.statusCode;
     }
 
     /**
      * @return the HTTP-Version
      */
-    public final HttpVersion getHttpVersion() {
+    public HttpVersion getHttpVersion() {
         return this.httpVersion;
     }
 
     /**
      * @return the Reason-Phrase
      */
-    public final String getReasonPhrase() {
+    public String getReasonPhrase() {
         return this.reasonPhrase;
     }
 
-    public final String toString() {
+    public String toString() {
     	CharArrayBuffer buffer = new CharArrayBuffer(64);        
         buffer.append(this.httpVersion);
         buffer.append(' ');
@@ -217,7 +221,7 @@
         if (statusline == null) {
             throw new IllegalArgumentException("Status line may not be null");
         }
-        HttpVersion.format(buffer, statusline.getHttpVersion());
+        BasicHttpVersion.format(buffer, statusline.getHttpVersion());
         buffer.append(' ');
         buffer.append(Integer.toString(statusline.getStatusCode()));
         if (statusline.getReasonPhrase() != null) {

Modified: jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/java/org/apache/http/protocol/HttpService.java Sun Jul  2 05:18:08 2006
@@ -43,7 +43,6 @@
 import org.apache.http.HttpVersion;
 import org.apache.http.MethodNotSupportedException;
 import org.apache.http.ProtocolException;
-import org.apache.http.StatusLine;
 import org.apache.http.UnsupportedHttpVersionException;
 import org.apache.http.impl.DefaultConnectionReuseStrategy;
 import org.apache.http.message.BasicHttpResponse;
@@ -188,7 +187,7 @@
         if (ver.lessEquals(HttpVersion.HTTP_1_1)) {
             response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
         } else {
-            response.setStatusLine(new StatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_IMPLEMENTED));
+            response.setStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_IMPLEMENTED);
         }
     }
     

Modified: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHeaderElement.java Sun Jul  2 05:18:08 2006
@@ -32,6 +32,7 @@
 
 import org.apache.http.io.CharArrayBuffer;
 import org.apache.http.message.BasicHeaderElement;
+import org.apache.http.message.BasicNameValuePair;
 
 import junit.framework.*;
 
@@ -66,8 +67,8 @@
     public void testConstructor() throws Exception {
         HeaderElement element = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
-                    new NameValuePair("param1", "value1"),
-                    new NameValuePair("param2", "value2")
+                    new BasicNameValuePair("param1", "value1"),
+                    new BasicNameValuePair("param2", "value2")
                 } );
         assertEquals("name", element.getName());
         assertEquals("value", element.getValue());
@@ -247,20 +248,20 @@
     public void testHashCode() {
         HeaderElement element1 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
-                    new NameValuePair("param1", "value1"),
-                    new NameValuePair("param2", "value2")
+                    new BasicNameValuePair("param1", "value1"),
+                    new BasicNameValuePair("param2", "value2")
                 } );
         HeaderElement element2 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
-                    new NameValuePair("param2", "value2"),
-                    new NameValuePair("param1", "value1")
+                    new BasicNameValuePair("param2", "value2"),
+                    new BasicNameValuePair("param1", "value1")
                 } );
         HeaderElement element3 = new BasicHeaderElement("name", "value"); 
         HeaderElement element4 = new BasicHeaderElement("name", "value"); 
         HeaderElement element5 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
-                    new NameValuePair("param1", "value1"),
-                    new NameValuePair("param2", "value2")
+                    new BasicNameValuePair("param1", "value1"),
+                    new BasicNameValuePair("param2", "value2")
                 } );
         assertTrue(element1.hashCode() != element2.hashCode());
         assertTrue(element1.hashCode() != element3.hashCode());
@@ -272,20 +273,20 @@
     public void testEquals() {
         HeaderElement element1 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
-                    new NameValuePair("param1", "value1"),
-                    new NameValuePair("param2", "value2")
+                    new BasicNameValuePair("param1", "value1"),
+                    new BasicNameValuePair("param2", "value2")
                 } );
         HeaderElement element2 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
-                    new NameValuePair("param2", "value2"),
-                    new NameValuePair("param1", "value1")
+                    new BasicNameValuePair("param2", "value2"),
+                    new BasicNameValuePair("param1", "value1")
                 } );
         HeaderElement element3 = new BasicHeaderElement("name", "value"); 
         HeaderElement element4 = new BasicHeaderElement("name", "value"); 
         HeaderElement element5 = new BasicHeaderElement("name", "value", 
                 new NameValuePair[] {
-                    new NameValuePair("param1", "value1"),
-                    new NameValuePair("param2", "value2")
+                    new BasicNameValuePair("param1", "value1"),
+                    new BasicNameValuePair("param2", "value2")
                 } );
         assertTrue(element1.equals(element1));
         assertTrue(!element1.equals(element2));
@@ -307,10 +308,10 @@
     }
     
     public void testElementFormatting() throws Exception {
-        NameValuePair param1 = new NameValuePair("param", "regular_stuff"); 
-        NameValuePair param2 = new NameValuePair("param", "this\\that"); 
-        NameValuePair param3 = new NameValuePair("param", "this,that");
-        NameValuePair param4 = new NameValuePair("param", null);
+        NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff"); 
+        NameValuePair param2 = new BasicNameValuePair("param", "this\\that"); 
+        NameValuePair param3 = new BasicNameValuePair("param", "this,that");
+        NameValuePair param4 = new BasicNameValuePair("param", null);
         NameValuePair[] params = new NameValuePair[] {param1, param2, param3, param4};
         HeaderElement element = new BasicHeaderElement("name", "value", params); 
         
@@ -319,10 +320,10 @@
     }
     
     public void testElementArrayFormatting() throws Exception {
-        NameValuePair param1 = new NameValuePair("param", "regular_stuff"); 
-        NameValuePair param2 = new NameValuePair("param", "this\\that"); 
-        NameValuePair param3 = new NameValuePair("param", "this,that");
-        NameValuePair param4 = new NameValuePair("param", null);
+        NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff"); 
+        NameValuePair param2 = new BasicNameValuePair("param", "this\\that"); 
+        NameValuePair param3 = new BasicNameValuePair("param", "this,that");
+        NameValuePair param4 = new BasicNameValuePair("param", null);
         HeaderElement element1 = new BasicHeaderElement("name1", "value1", new NameValuePair[] {param1}); 
         HeaderElement element2 = new BasicHeaderElement("name2", "value2", new NameValuePair[] {param2}); 
         HeaderElement element3 = new BasicHeaderElement("name3", "value3", new NameValuePair[] {param3}); 

Modified: jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpVersion.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpVersion.java?rev=418582&r1=418581&r2=418582&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpVersion.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/test/org/apache/http/TestHttpVersion.java Sun Jul  2 05:18:08 2006
@@ -30,6 +30,7 @@
 package org.apache.http;
 
 import org.apache.http.io.CharArrayBuffer;
+import org.apache.http.message.BasicHttpVersion;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -73,13 +74,13 @@
 
     public void testHttpVersionParsing() throws Exception {
         String s = "HTTP/1.1";
-        HttpVersion version = HttpVersion.parse(s);
+        HttpVersion version = BasicHttpVersion.parse(s);
         assertEquals("HTTP major version number", 1, version.getMajor());
         assertEquals("HTTP minor version number", 1, version.getMinor());
         assertEquals("HTTP version number", s, version.toString());
 
         s = "HTTP/123.4567";
-        version = HttpVersion.parse(s);
+        version = BasicHttpVersion.parse(s);
         assertEquals("HTTP major version number", 123, version.getMajor());
         assertEquals("HTTP minor version number", 4567, version.getMinor());
         assertEquals("HTTP version number", s, version.toString());
@@ -87,67 +88,67 @@
 
     public void testInvalidHttpVersionParsing() throws Exception {
         try {
-            HttpVersion.parse(null);
+            BasicHttpVersion.parse(null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException e) {
             //expected
         }
         try {
-            HttpVersion.parse("    ");
+            BasicHttpVersion.parse("    ");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("HTT");
+            BasicHttpVersion.parse("HTT");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("crap");
+            BasicHttpVersion.parse("crap");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("HTTP/crap");
+            BasicHttpVersion.parse("HTTP/crap");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("HTTP/1");
+            BasicHttpVersion.parse("HTTP/1");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("HTTP/1234   ");
+            BasicHttpVersion.parse("HTTP/1234   ");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("HTTP/1.");
+            BasicHttpVersion.parse("HTTP/1.");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("HTTP/1.1 crap");
+            BasicHttpVersion.parse("HTTP/1.1 crap");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("HTTP/whatever.whatever whatever");
+            BasicHttpVersion.parse("HTTP/whatever.whatever whatever");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
         }
         try {
-            HttpVersion.parse("HTTP/1.whatever whatever");
+            BasicHttpVersion.parse("HTTP/1.whatever whatever");
             fail("ProtocolException should have been thrown");
         } catch (ProtocolException e) {
             //expected
@@ -158,31 +159,31 @@
         CharArrayBuffer buffer = new CharArrayBuffer(32);
         buffer.append("HTTP/1.1");
         try {
-            HttpVersion.parse(null, 0, 0);
+            BasicHttpVersion.parse(null, 0, 0);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HttpVersion.parse(null);
+            BasicHttpVersion.parse(null);
             fail("IllegalArgumentException should have been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HttpVersion.parse(buffer, -1, 0);
+            BasicHttpVersion.parse(buffer, -1, 0);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
-            HttpVersion.parse(buffer, 0, 1000);
+            BasicHttpVersion.parse(buffer, 0, 1000);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
         }
         try {
-            HttpVersion.parse(buffer, 2, 1);
+            BasicHttpVersion.parse(buffer, 2, 1);
             fail("IllegalArgumentException should have been thrown");
         } catch (IndexOutOfBoundsException ex) {
             // expected
@@ -224,19 +225,19 @@
    }
     
     public void testHttpVersionFormatting() throws Exception {
-        String s = HttpVersion.format(HttpVersion.HTTP_1_1);
+        String s = BasicHttpVersion.format(HttpVersion.HTTP_1_1);
         assertEquals("HTTP/1.1", s);
     }
     
     public void testHttpVersionFormattingInvalidInput() throws Exception {
         try {
-            HttpVersion.format(null, HttpVersion.HTTP_1_1);
+            BasicHttpVersion.format(null, HttpVersion.HTTP_1_1);
             fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected
         }
         try {
-            HttpVersion.format(new CharArrayBuffer(10), (HttpVersion) null);
+            BasicHttpVersion.format(new CharArrayBuffer(10), (HttpVersion) null);
             fail("IllegalArgumentException should habe been thrown");
         } catch (IllegalArgumentException ex) {
             // expected