hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1769681 - in /httpcomponents/httpcore/trunk: httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/ httpcore5/src/examples/org/apache/hc/core5/http/examples/ httpcore5/src/main/java/org/apache/hc/core5/http/ httpcore5/src/main/java...
Date Mon, 14 Nov 2016 19:11:26 GMT
Author: olegk
Date: Mon Nov 14 19:11:26 2016
New Revision: 1769681

URL: http://svn.apache.org/viewvc?rev=1769681&view=rev
Log:
Improved request URI and message transport version handling

Modified:
    httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequest.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequestFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponseFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpRequestFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpResponseFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestWriter.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseWriter.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestWriter.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseWriter.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/HttpRequestWrapper.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/RequestLine.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestRequestParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestResponseParser.java

Modified: httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java Mon Nov 14 19:11:26 2016
@@ -236,7 +236,7 @@ class BenchmarkWorker implements Runnabl
 
     private void verboseOutput(final ClassicHttpResponse response) {
         if (config.getVerbosity() >= 3) {
-            System.out.println(">> " + request.getMethod() + " " + request.getPath());
+            System.out.println(">> " + request.getMethod() + " " + request.getRequestUri());
             final Header[] headers = request.getAllHeaders();
             for (final Header header : headers) {
                 System.out.println(">> " + header.toString());

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java Mon Nov 14 19:11:26 2016
@@ -292,7 +292,7 @@ public class AsyncReverseProxyExample {
 
             synchronized (exchangeState) {
                 System.out.println("[client->proxy] " + exchangeState.id + " " +
-                        incomingRequest.getMethod() + " " + incomingRequest.getPath());
+                        incomingRequest.getMethod() + " " + incomingRequest.getRequestUri());
                 exchangeState.request = incomingRequest;
                 exchangeState.inputEnd = entityDetails == null;
                 exchangeState.responseMessageChannel = responseChannel;
@@ -496,7 +496,7 @@ public class AsyncReverseProxyExample {
                 }
 
                 System.out.println("[proxy->origin] " + exchangeState.id + " " +
-                        outgoingRequest.getMethod() + " " + outgoingRequest.getPath());
+                        outgoingRequest.getMethod() + " " + outgoingRequest.getRequestUri());
 
                 channel.sendRequest(
                         outgoingRequest,

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequest.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequest.java Mon Nov 14 19:11:26 2016
@@ -93,6 +93,16 @@ public interface HttpRequest extends Htt
     void setAuthority(String authority);
 
     /**
+     * Returns request URI of this request message. It may be an absolute or relative URI.
+     * Applicable to HTTP/1.1 version or earlier.
+     *
+     * @return  the request URI.
+     *
+     * @since 5.0
+     */
+    String getRequestUri();
+
+    /**
      * Returns full request URI of this request message.
      *
      * @return  the request URI.

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequestFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequestFactory.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequestFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequestFactory.java Mon Nov 14 19:11:26 2016
@@ -27,6 +27,8 @@
 
 package org.apache.hc.core5.http;
 
+import java.net.URI;
+
 /**
  * A factory for {@link HttpRequest} objects.
  *
@@ -37,7 +39,6 @@ public interface HttpRequestFactory<T ex
     /**
      * Creates request message with the given request method and request URI.
      *
-     * @param transportVersion protocol version this message was transmitted with.
      * @param method  the request method
      * @param uri the request URI
      *
@@ -45,7 +46,7 @@ public interface HttpRequestFactory<T ex
      *
      * @since 5.0
      */
-    T newHttpRequest(ProtocolVersion transportVersion, String method, String uri) throws MethodNotSupportedException;
+    T newHttpRequest(String method, String uri) throws MethodNotSupportedException;
 
     /**
      * Creates request message with the given request method and request URI.
@@ -55,6 +56,6 @@ public interface HttpRequestFactory<T ex
      *
      * @return  request message
      */
-    T newHttpRequest(String method, String uri) throws MethodNotSupportedException;
+    T newHttpRequest(String method, URI uri) throws MethodNotSupportedException;
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponseFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponseFactory.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponseFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponseFactory.java Mon Nov 14 19:11:26 2016
@@ -37,7 +37,6 @@ public interface HttpResponseFactory<T e
     /**
      * Creates response message with the given code and reason phrase.
      *
-     * @param transportVersion protocol version this message was transmitted with.
      * @param status    the status code
      * @param reasonPhrase the reason phrase
      *
@@ -45,7 +44,7 @@ public interface HttpResponseFactory<T e
      *
      * @since 5.0
      */
-    T newHttpResponse(ProtocolVersion transportVersion, int status, String reasonPhrase);
+    T newHttpResponse(int status, String reasonPhrase);
 
     /**
      * Creates a new response with the given code.

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpClientConnection.java Mon Nov 14 19:11:26 2016
@@ -39,7 +39,10 @@ import org.apache.hc.core5.http.ContentL
 import org.apache.hc.core5.http.HttpEntity;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.LengthRequiredException;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
 import org.apache.hc.core5.http.io.HttpClientConnection;
@@ -185,7 +188,11 @@ public class DefaultBHttpClientConnectio
     public ClassicHttpResponse receiveResponseHeader() throws HttpException, IOException {
         final SocketHolder socketHolder = ensureOpen();
         final ClassicHttpResponse response = this.responseParser.parse(this.inbuffer, socketHolder.getInputStream());
-        this.version = response.getVersion();
+        final ProtocolVersion transportVersion = response.getVersion();
+        if (transportVersion != null && transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
+        }
+        this.version = transportVersion;
         onResponseReceived(response);
         if (response.getCode() >= HttpStatus.SC_SUCCESS) {
             incrementResponseCount();

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultBHttpServerConnection.java Mon Nov 14 19:11:26 2016
@@ -39,6 +39,9 @@ import org.apache.hc.core5.http.ContentL
 import org.apache.hc.core5.http.HttpEntity;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy;
 import org.apache.hc.core5.http.io.HttpMessageParser;
@@ -128,7 +131,11 @@ public class DefaultBHttpServerConnectio
     public ClassicHttpRequest receiveRequestHeader() throws HttpException, IOException {
         final SocketHolder socketHolder = ensureOpen();
         final ClassicHttpRequest request = this.requestParser.parse(this.inbuffer, socketHolder.getInputStream());
-        this.version = request.getVersion();
+        final ProtocolVersion transportVersion = request.getVersion();
+        if (transportVersion != null && transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
+        }
+        this.version = transportVersion;
         onRequestReceived(request);
         incrementRequestCount();
         return request;

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpRequestFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpRequestFactory.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpRequestFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpRequestFactory.java Mon Nov 14 19:11:26 2016
@@ -27,12 +27,12 @@
 
 package org.apache.hc.core5.http.impl.io;
 
+import java.net.URI;
+
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.HttpRequestFactory;
-import org.apache.hc.core5.http.MethodNotSupportedException;
-import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
 
 /**
@@ -45,39 +45,13 @@ public class DefaultClassicHttpRequestFa
 
     public static final DefaultClassicHttpRequestFactory INSTANCE = new DefaultClassicHttpRequestFactory();
 
-    private static final String[] SUPPORTED_METHODS = {
-            "GET",
-            "POST",
-            "PUT",
-            "HEAD",
-            "OPTIONS",
-            "DELETE",
-            "TRACE",
-            "PATCH",
-            "CONNECT"
-    };
-
-    private static boolean isOneOf(final String[] methods, final String method) {
-        for (final String method2 : methods) {
-            if (method2.equalsIgnoreCase(method)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     @Override
-    public ClassicHttpRequest newHttpRequest(final ProtocolVersion transportVersion, final String method, final String uri) throws MethodNotSupportedException {
-        if (isOneOf(SUPPORTED_METHODS, method)) {
-            final ClassicHttpRequest request = new BasicClassicHttpRequest(method, uri);
-            request.setVersion(transportVersion);
-            return request;
-        }
-        throw new MethodNotSupportedException(method + " method not supported");
+    public ClassicHttpRequest newHttpRequest(final String method, final URI uri) {
+        return new BasicClassicHttpRequest(method, uri);
     }
 
     @Override
-    public ClassicHttpRequest newHttpRequest(final String method, final String uri) throws MethodNotSupportedException {
+    public ClassicHttpRequest newHttpRequest(final String method, final String uri) {
         return new BasicClassicHttpRequest(method, uri);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpResponseFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpResponseFactory.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpResponseFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultClassicHttpResponseFactory.java Mon Nov 14 19:11:26 2016
@@ -31,7 +31,6 @@ import org.apache.hc.core5.annotation.Co
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpResponseFactory;
-import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.ReasonPhraseCatalog;
 import org.apache.hc.core5.http.impl.EnglishReasonPhraseCatalog;
 import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
@@ -67,13 +66,8 @@ public class DefaultClassicHttpResponseF
     }
 
     @Override
-    public ClassicHttpResponse newHttpResponse(final ProtocolVersion transportVersion, final int status, final String reasonPhrase) {
-        final ClassicHttpResponse response = new BasicClassicHttpResponse(status, reasonPhrase);
-        response.setVersion(transportVersion);
-        if (reasonPhrase != null) {
-            response.setReasonPhrase(reasonPhrase);
-        }
-        return response;
+    public ClassicHttpResponse newHttpResponse(final int status, final String reasonPhrase) {
+        return new BasicClassicHttpResponse(status, reasonPhrase);
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestParser.java Mon Nov 14 19:11:26 2016
@@ -33,9 +33,6 @@ import org.apache.hc.core5.http.ClassicH
 import org.apache.hc.core5.http.ConnectionClosedException;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpRequestFactory;
-import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.message.LineParser;
 import org.apache.hc.core5.http.message.RequestLine;
@@ -93,11 +90,9 @@ public class DefaultHttpRequestParser ex
     @Override
     protected ClassicHttpRequest createMessage(final CharArrayBuffer buffer) throws IOException, HttpException {
         final RequestLine requestLine = getLineParser().parseRequestLine(buffer);
-        final ProtocolVersion transportVersion = requestLine.getProtocolVersion();
-        if (transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
-            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
-        }
-        return this.requestFactory.newHttpRequest(requestLine.getProtocolVersion(), requestLine.getMethod(), requestLine.getUri());
+        final ClassicHttpRequest request = this.requestFactory.newHttpRequest(requestLine.getMethod(), requestLine.getUri());
+        request.setVersion(requestLine.getProtocolVersion());
+        return request;
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestWriter.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpRequestWriter.java Mon Nov 14 19:11:26 2016
@@ -62,12 +62,11 @@ public class DefaultHttpRequestWriter ex
     @Override
     protected void writeHeadLine(
             final ClassicHttpRequest message, final CharArrayBuffer lineBuf) throws IOException {
-        ProtocolVersion transportVersion = message.getVersion();
-        if (transportVersion == null || transportVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
-            transportVersion = HttpVersion.HTTP_1_1;
-        }
-        getLineFormatter().formatRequestLine(lineBuf,
-                new RequestLine(message.getMethod(), message.getPath(), transportVersion));
+        final ProtocolVersion transportVersion = message.getVersion();
+        getLineFormatter().formatRequestLine(lineBuf, new RequestLine(
+                message.getMethod(),
+                message.getRequestUri(),
+                transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseParser.java Mon Nov 14 19:11:26 2016
@@ -32,10 +32,7 @@ import java.io.IOException;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpResponseFactory;
-import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.NoHttpResponseException;
-import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.message.LineParser;
 import org.apache.hc.core5.http.message.StatusLine;
@@ -93,11 +90,9 @@ public class DefaultHttpResponseParser e
     @Override
     protected ClassicHttpResponse createMessage(final CharArrayBuffer buffer) throws IOException, HttpException {
         final StatusLine statusline = getLineParser().parseStatusLine(buffer);
-        final ProtocolVersion transportVersion = statusline.getProtocolVersion();
-        if (transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
-            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
-        }
-        return this.responseFactory.newHttpResponse(transportVersion, statusline.getStatusCode(), statusline.getReasonPhrase());
+        final ClassicHttpResponse response = this.responseFactory.newHttpResponse(statusline.getStatusCode(), statusline.getReasonPhrase());
+        response.setVersion(statusline.getProtocolVersion());
+        return response;
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseWriter.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/DefaultHttpResponseWriter.java Mon Nov 14 19:11:26 2016
@@ -62,12 +62,11 @@ public class DefaultHttpResponseWriter e
     @Override
     protected void writeHeadLine(
             final ClassicHttpResponse message, final CharArrayBuffer lineBuf) throws IOException {
-        ProtocolVersion transportVersion = message.getVersion();
-        if (transportVersion == null || transportVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
-            transportVersion = HttpVersion.HTTP_1_1;
-        }
-        getLineFormatter().formatStatusLine(lineBuf,
-                new StatusLine(transportVersion, message.getCode(), message.getReasonPhrase()));
+        final ProtocolVersion transportVersion = message.getVersion();
+        getLineFormatter().formatStatusLine(lineBuf, new StatusLine(
+                transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1,
+                message.getCode(),
+                message.getReasonPhrase()));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java Mon Nov 14 19:11:26 2016
@@ -41,8 +41,10 @@ import org.apache.hc.core5.http.HttpHead
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.ProtocolException;
 import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.impl.LazyEntityDetails;
 import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
@@ -154,9 +156,10 @@ class ClientHttp1StreamHandler implement
     private void commitRequest(final HttpRequest request, final EntityDetails entityDetails) throws IOException, HttpException {
         if (requestCommitted.compareAndSet(false, true)) {
             final ProtocolVersion transportVersion = request.getVersion();
-            if (transportVersion != null) {
-                context.setProtocolVersion(transportVersion);
+            if (transportVersion != null && transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+                throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
             }
+            context.setProtocolVersion(transportVersion);
             context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
             context.setAttribute(HttpCoreContext.HTTP_CONNECTION, connection);
             httpProcessor.process(request, entityDetails, context);
@@ -209,6 +212,10 @@ class ClientHttp1StreamHandler implement
         if (done.get() || responseState != MessageState.HEADERS) {
             throw new ProtocolException("Unexpected message head");
         }
+        final ProtocolVersion transportVersion = response.getVersion();
+        if (transportVersion != null && transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
+        }
 
         final int status = response.getCode();
         if (status < HttpStatus.SC_INFORMATIONAL) {

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestFactory.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestFactory.java Mon Nov 14 19:11:26 2016
@@ -27,12 +27,12 @@
 
 package org.apache.hc.core5.http.impl.nio;
 
+import java.net.URI;
+
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpRequestFactory;
-import org.apache.hc.core5.http.MethodNotSupportedException;
-import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
 
 /**
@@ -45,39 +45,13 @@ public class DefaultHttpRequestFactory i
 
     public static final DefaultHttpRequestFactory INSTANCE = new DefaultHttpRequestFactory();
 
-    private static final String[] SUPPORTED_METHODS = {
-            "GET",
-            "POST",
-            "PUT",
-            "HEAD",
-            "OPTIONS",
-            "DELETE",
-            "TRACE",
-            "PATCH",
-            "CONNECT"
-    };
-
-    private static boolean isOneOf(final String[] methods, final String method) {
-        for (final String method2 : methods) {
-            if (method2.equalsIgnoreCase(method)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     @Override
-    public HttpRequest newHttpRequest(final ProtocolVersion transportVersion, final String method, final String uri) throws MethodNotSupportedException {
-        if (isOneOf(SUPPORTED_METHODS, method)) {
-            final HttpRequest request = new BasicHttpRequest(method, uri);
-            request.setVersion(transportVersion);
-            return request;
-        }
-        throw new MethodNotSupportedException(method + " method not supported");
+    public HttpRequest newHttpRequest(final String method, final URI uri) {
+        return new BasicHttpRequest(method, uri);
     }
 
     @Override
-    public HttpRequest newHttpRequest(final String method, final String uri) throws MethodNotSupportedException {
+    public HttpRequest newHttpRequest(final String method, final String uri) {
         return new BasicHttpRequest(method, uri);
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestParser.java Mon Nov 14 19:11:26 2016
@@ -30,9 +30,6 @@ package org.apache.hc.core5.http.impl.ni
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpRequestFactory;
-import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.message.LineParser;
 import org.apache.hc.core5.http.message.RequestLine;
@@ -84,11 +81,9 @@ public class DefaultHttpRequestParser<T
     @Override
     protected T createMessage(final CharArrayBuffer buffer) throws HttpException {
         final RequestLine requestLine = getLineParser().parseRequestLine(buffer);
-        final ProtocolVersion transportVersion = requestLine.getProtocolVersion();
-        if (transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
-            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
-        }
-        return this.requestFactory.newHttpRequest(transportVersion, requestLine.getMethod(), requestLine.getUri());
+        final T request = this.requestFactory.newHttpRequest(requestLine.getMethod(), requestLine.getUri());
+        request.setVersion(requestLine.getProtocolVersion());
+        return request;
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestWriter.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpRequestWriter.java Mon Nov 14 19:11:26 2016
@@ -65,12 +65,11 @@ public class DefaultHttpRequestWriter<T
     @Override
     protected void writeHeadLine(final T message, final CharArrayBuffer lineBuf) throws IOException {
         lineBuf.clear();
-        ProtocolVersion transportVersion = message.getVersion();
-        if (transportVersion == null || transportVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
-            transportVersion = HttpVersion.HTTP_1_1;
-        }
-        getLineFormatter().formatRequestLine(lineBuf,
-                new RequestLine(message.getMethod(), message.getPath(), transportVersion));
+        final ProtocolVersion transportVersion = message.getVersion();
+        getLineFormatter().formatRequestLine(lineBuf, new RequestLine(
+                message.getMethod(),
+                message.getRequestUri(),
+                transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseFactory.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseFactory.java Mon Nov 14 19:11:26 2016
@@ -31,7 +31,6 @@ import org.apache.hc.core5.annotation.Co
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpResponseFactory;
-import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.ReasonPhraseCatalog;
 import org.apache.hc.core5.http.impl.EnglishReasonPhraseCatalog;
 import org.apache.hc.core5.http.message.BasicHttpResponse;
@@ -67,13 +66,8 @@ public class DefaultHttpResponseFactory
     }
 
     @Override
-    public HttpResponse newHttpResponse(final ProtocolVersion transportVersion, final int status, final String reasonPhrase) {
-        final HttpResponse response = new BasicHttpResponse(status, reasonPhrase);
-        response.setVersion(transportVersion);
-        if (reasonPhrase != null) {
-            response.setReasonPhrase(reasonPhrase);
-        }
-        return response;
+    public HttpResponse newHttpResponse(final int status, final String reasonPhrase) {
+        return new BasicHttpResponse(status, reasonPhrase);
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseParser.java Mon Nov 14 19:11:26 2016
@@ -30,9 +30,6 @@ package org.apache.hc.core5.http.impl.ni
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpResponseFactory;
-import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http.ProtocolVersion;
-import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.message.LineParser;
 import org.apache.hc.core5.http.message.StatusLine;
@@ -84,11 +81,9 @@ public class DefaultHttpResponseParser<T
     @Override
     protected T createMessage(final CharArrayBuffer buffer) throws HttpException {
         final StatusLine statusLine = getLineParser().parseStatusLine(buffer);
-        final ProtocolVersion transportVersion = statusLine.getProtocolVersion();
-        if (transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
-            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
-        }
-        return this.responseFactory.newHttpResponse(transportVersion, statusLine.getStatusCode(), statusLine.getReasonPhrase());
+        final T response = this.responseFactory.newHttpResponse(statusLine.getStatusCode(), statusLine.getReasonPhrase());
+        response.setVersion(statusLine.getProtocolVersion());
+        return response;
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseWriter.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseWriter.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseWriter.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultHttpResponseWriter.java Mon Nov 14 19:11:26 2016
@@ -65,12 +65,11 @@ public class DefaultHttpResponseWriter<T
     @Override
     protected void writeHeadLine(final T message, final CharArrayBuffer lineBuf) throws IOException {
         lineBuf.clear();
-        ProtocolVersion transportVersion = message.getVersion();
-        if (transportVersion == null || transportVersion.greaterEquals(HttpVersion.HTTP_2_0)) {
-            transportVersion = HttpVersion.HTTP_1_1;
-        }
-        getLineFormatter().formatStatusLine(lineBuf,
-                new StatusLine(transportVersion, message.getCode(), message.getReasonPhrase()));
+        final ProtocolVersion transportVersion = message.getVersion();
+        getLineFormatter().formatStatusLine(lineBuf, new StatusLine(
+                transportVersion != null ? transportVersion : HttpVersion.HTTP_1_1,
+                message.getCode(),
+                message.getReasonPhrase()));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamHandler.java Mon Nov 14 19:11:26 2016
@@ -39,6 +39,7 @@ import org.apache.hc.core5.http.HttpExce
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.MethodNotSupportedException;
 import org.apache.hc.core5.http.MisdirectedRequestException;
 import org.apache.hc.core5.http.NotImplementedException;
@@ -142,6 +143,11 @@ class ServerHttp1StreamHandler implement
             final EntityDetails responseEntityDetails) throws HttpException, IOException {
         if (responseCommitted.compareAndSet(false, true)) {
 
+            final ProtocolVersion transportVersion = response.getVersion();
+            if (transportVersion != null && transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+                throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
+            }
+
             final int status = response.getCode();
             if (status < HttpStatus.SC_SUCCESS) {
                 throw new HttpException("Invalid response: " + status);
@@ -240,6 +246,9 @@ class ServerHttp1StreamHandler implement
         exchangeHandler = handler;
 
         final ProtocolVersion transportVersion = request.getVersion();
+        if (transportVersion != null && transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
+        }
         context.setProtocolVersion(transportVersion);
         context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
         context.setAttribute(HttpCoreContext.HTTP_CONNECTION, connection);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicHttpRequest.java Mon Nov 14 19:11:26 2016
@@ -168,6 +168,11 @@ public class BasicHttpRequest extends He
     }
 
     @Override
+    public String getRequestUri() {
+        return getPath();
+    }
+
+    @Override
     public URI getUri() throws URISyntaxException {
         if (this.requestUri == null) {
             final StringBuilder buf = new StringBuilder();

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/HttpRequestWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/HttpRequestWrapper.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/HttpRequestWrapper.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/HttpRequestWrapper.java Mon Nov 14 19:11:26 2016
@@ -80,6 +80,11 @@ public class HttpRequestWrapper extends
     }
 
     @Override
+    public String getRequestUri() {
+        return message.getRequestUri();
+    }
+
+    @Override
     public URI getUri() throws URISyntaxException {
         return message.getUri();
     }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/RequestLine.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/RequestLine.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/RequestLine.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/RequestLine.java Mon Nov 14 19:11:26 2016
@@ -54,7 +54,7 @@ public final class RequestLine implement
         super();
         Args.notNull(request, "Request");
         this.method = request.getMethod();
-        this.uri = request.getPath();
+        this.uri = request.getRequestUri();
         this.protoversion = request.getVersion() != null ? request.getVersion() : HttpVersion.HTTP_1_1;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestRequestParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestRequestParser.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestRequestParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestRequestParser.java Mon Nov 14 19:11:26 2016
@@ -30,11 +30,10 @@ import java.io.ByteArrayInputStream;
 import java.io.InterruptedIOException;
 import java.nio.charset.StandardCharsets;
 
+import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ConnectionClosedException;
 import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.MessageConstraintException;
-import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.io.SessionInputBuffer;
 import org.junit.Assert;
@@ -146,14 +145,5 @@ public class TestRequestParser {
         Assert.assertEquals(3, headers.length);
     }
 
-    @Test(expected = UnsupportedHttpVersionException.class)
-    public void testParsingUnsupportedVersion() throws Exception {
-        final String s = "GET / HTTP/2.0\r\n\r\n";
-        final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
-        final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16, StandardCharsets.US_ASCII.newDecoder());
-        final DefaultHttpRequestParser parser = new DefaultHttpRequestParser();
-        parser.parse(inbuffer, inputStream);
-    }
-
 }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestResponseParser.java?rev=1769681&r1=1769680&r2=1769681&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestResponseParser.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestResponseParser.java Mon Nov 14 19:11:26 2016
@@ -31,11 +31,10 @@ import java.io.ByteArrayInputStream;
 import java.io.InterruptedIOException;
 import java.nio.charset.StandardCharsets;
 
-import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.MessageConstraintException;
 import org.apache.hc.core5.http.NoHttpResponseException;
-import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.H1Config;
 import org.apache.hc.core5.http.io.SessionInputBuffer;
 import org.junit.Assert;
@@ -146,14 +145,5 @@ public class TestResponseParser {
         Assert.assertEquals(3, headers.length);
     }
 
-    @Test(expected = UnsupportedHttpVersionException.class)
-    public void testParsingUnsupportedVersion() throws Exception {
-        final String s = "HTTP/2.0 200 OK\r\n\r\n";
-        final ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes(StandardCharsets.US_ASCII));
-        final SessionInputBuffer inbuffer = new SessionInputBufferImpl(16, StandardCharsets.US_ASCII.newDecoder());
-        final DefaultHttpResponseParser parser = new DefaultHttpResponseParser();
-        parser.parse(inbuffer, inputStream);
-    }
-
 }
 



Mime
View raw message