hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1735164 [1/4] - in /httpcomponents/httpcore/trunk: httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/ httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/ httpcore5/src/examples/org/apache/hc/core5/http/examples/ http...
Date Tue, 15 Mar 2016 20:35:36 GMT
Author: olegk
Date: Tue Mar 15 20:35:34 2016
New Revision: 1735164

URL: http://svn.apache.org/viewvc?rev=1735164&view=rev
Log:
RFC 7540: Removed RequestLine and StatusLine from HTTP message API; HTTP messages may include version attribute to represent protocol version used to transmit them; HTTP connections to keep protocol version of the last incoming message

Added:
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/RequestLine.java   (contents, props changed)
      - copied, changed from r1734704, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicRequestLine.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/StatusLine.java   (contents, props changed)
      - copied, changed from r1734704, httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicStatusLine.java
Removed:
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/RequestLine.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/StatusLine.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicRequestLine.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicStatusLine.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestRequestLine.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestStatusLine.java
Modified:
    httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/BenchmarkWorker.java
    httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/HttpBenchmark.java
    httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/SmokeTest.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpGet.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPost.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPostTrailers.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalPoolingHttpGet.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalReverseProxy.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/HttpFileServer.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpClient.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpFileServer.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpReverseProxy.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/PipeliningHttpClient.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpMessage.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/HttpResponse.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/HttpVersion.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpRequestFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpResponseFactory.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.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/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/io/HttpRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/BasicAsyncClientExchangeHandler.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/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/DefaultNHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/DefaultNHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/HttpAsyncService.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/NHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/NullRequestHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/PipeliningClientExchangeHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/SessionHttpContext.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/UriHttpAsyncRequestHandlerMapper.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/UriHttpRequestHandlerMapper.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/BasicHttpResponse.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicLineFormatter.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicLineParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/LineFormatter.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/LineParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/BasicHttpContext.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpContext.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/HttpCoreContext.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestConnControl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestContent.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestExpectContinue.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestTargetHost.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestValidateHost.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/ResponseConnControl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/ResponseContent.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestBasicRequest.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultContentLengthStrategy.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.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
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestBasicAsyncClientExchangeHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestBasicAsyncRequestHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestDefaultNHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestDefaultNHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestErrorResponseProducer.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestHttpAsyncRequestExecutor.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestHttpAsyncService.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestHttpMessageParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestNHttpConnectionBase.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/integration/SimpleRequestHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/integration/TestClientOutOfSequenceResponse.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/integration/TestHttpAsyncHandlerCancellable.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/integration/TestHttpAsyncHandlers.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/integration/TestHttpAsyncHandlersPipelining.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/integration/TestSyncHttp.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestAbstractMessage.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHttpResponse.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineFormatter.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineParser.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicMessages.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestStandardInterceptors.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/testserver/io/HttpServer.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/testserver/io/LoggingBHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/testserver/io/LoggingBHttpServerConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/testserver/nio/LoggingNHttpClientConnection.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/http/testserver/nio/LoggingNHttpServerConnection.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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -44,12 +44,13 @@ import org.apache.hc.core5.http.HttpHost
 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.entity.ContentType;
 import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
 import org.apache.hc.core5.http.protocol.HttpCoreContext;
 import org.apache.hc.core5.http.protocol.HttpProcessor;
 import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
-import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
 import org.apache.hc.core5.http.protocol.RequestConnControl;
 import org.apache.hc.core5.http.protocol.RequestContent;
 import org.apache.hc.core5.http.protocol.RequestExpectContinue;
@@ -104,6 +105,7 @@ class BenchmarkWorker implements Runnabl
     @Override
     public void run() {
         HttpResponse response = null;
+        final HttpVersion version = config.isUseHttp1_0() ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
         final BenchmarkConnection conn = new BenchmarkConnection(8 * 1024, stats);
 
         final String scheme = targetHost.getSchemeName();
@@ -118,7 +120,8 @@ class BenchmarkWorker implements Runnabl
         }
 
         // Populate the execution context
-        this.context.setTargetHost(this.targetHost);
+        context.setTargetHost(this.targetHost);
+        context.setProtocolVersion(version);
 
         stats.start();
         final int count = config.getRequests();
@@ -161,7 +164,7 @@ class BenchmarkWorker implements Runnabl
 
                 verboseOutput(response);
 
-                if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                if (response.getCode() == HttpStatus.SC_OK) {
                     stats.incSuccessCount();
                 } else {
                     stats.incFailureCount();
@@ -233,7 +236,7 @@ class BenchmarkWorker implements Runnabl
 
     private void verboseOutput(final HttpResponse response) {
         if (config.getVerbosity() >= 3) {
-            System.out.println(">> " + request.getRequestLine().toString());
+            System.out.println(">> " + request.getMethod() + " " + request.getUri());
             final Header[] headers = request.getAllHeaders();
             for (final Header header : headers) {
                 System.out.println(">> " + header.toString());
@@ -241,10 +244,10 @@ class BenchmarkWorker implements Runnabl
             System.out.println();
         }
         if (config.getVerbosity() >= 2) {
-            System.out.println(response.getStatusLine().getStatusCode());
+            System.out.println(response.getCode());
         }
         if (config.getVerbosity() >= 3) {
-            System.out.println("<< " + response.getStatusLine().toString());
+            System.out.println("<< " + response.getCode() + " " + response.getReasonPhrase());
             final Header[] headers = response.getAllHeaders();
             for (final Header header : headers) {
                 System.out.println("<< " + header.toString());

Modified: httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/HttpBenchmark.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/HttpBenchmark.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/HttpBenchmark.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-ab/src/main/java/org/apache/hc/core5/http/benchmark/HttpBenchmark.java Tue Mar 15 20:35:34 2016
@@ -110,16 +110,13 @@ public class HttpBenchmark {
             se.setChunked(config.isUseChunking());
             entity = se;
         }
-        final HttpVersion ver = config.isUseHttp1_0() ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
         final HttpRequest request;
         if ("POST".equals(config.getMethod())) {
-            final BasicHttpRequest httppost =
-                    new BasicHttpRequest("POST", url.getPath(), ver);
+            final HttpRequest httppost = new BasicHttpRequest("POST", url.getPath());
             httppost.setEntity(entity);
             request = httppost;
         } else if ("PUT".equals(config.getMethod())) {
-            final BasicHttpRequest httpput =
-                    new BasicHttpRequest("PUT", url.getPath(), ver);
+            final HttpRequest httpput = new BasicHttpRequest("PUT", url.getPath());
             httpput.setEntity(entity);
             request = httpput;
         } else {
@@ -129,8 +126,9 @@ public class HttpBenchmark {
             } else if (path.trim().length() == 0) {
                 path = "/";
             }
-            request = new BasicHttpRequest(config.getMethod(), path, ver);
+            request = new BasicHttpRequest(config.getMethod(), path);
         }
+        request.setVersion(config.isUseHttp1_0() ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1);
 
         if (!config.isKeepAlive()) {
             request.addHeader(new DefaultHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE));

Modified: httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/SmokeTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/SmokeTest.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/SmokeTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-ab/src/test/java/org/apache/hc/core5/http/benchmark/SmokeTest.java Tue Mar 15 20:35:34 2016
@@ -35,8 +35,8 @@ import org.apache.hc.core5.http.HttpResp
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.entity.ContentType;
 import org.apache.hc.core5.http.entity.StringEntity;
-import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -55,7 +55,7 @@ public class SmokeTest {
                     final HttpRequest request,
                     final HttpResponse response,
                     final HttpContext context) throws HttpException, IOException {
-                response.setStatusCode(HttpStatus.SC_OK);
+                response.setCode(HttpStatus.SC_OK);
                 response.setEntity(new StringEntity("0123456789ABCDEF", ContentType.TEXT_PLAIN));
             }
         });

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpGet.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpGet.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpGet.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpGet.java Tue Mar 15 20:35:34 2016
@@ -81,13 +81,13 @@ public class ElementalHttpGet {
                     conn.bind(socket);
                 }
                 BasicHttpRequest request = new BasicHttpRequest("GET", targets[i]);
-                System.out.println(">> Request URI: " + request.getRequestLine().getUri());
+                System.out.println(">> Request URI: " + request.getUri());
 
                 httpexecutor.preProcess(request, httpproc, coreContext);
                 HttpResponse response = httpexecutor.execute(request, conn, coreContext);
                 httpexecutor.postProcess(response, httpproc, coreContext);
 
-                System.out.println("<< Response: " + response.getStatusLine());
+                System.out.println("<< Response: " + response.getCode());
                 System.out.println(EntityUtils.toString(response.getEntity()));
                 System.out.println("==============");
                 if (!connStrategy.keepAlive(request, response, coreContext)) {

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPost.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPost.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPost.java Tue Mar 15 20:35:34 2016
@@ -100,13 +100,13 @@ public class ElementalHttpPost {
                 HttpRequest request = new BasicHttpRequest("POST",
                         "/servlets-examples/servlet/RequestInfoExample");
                 request.setEntity(requestBodies[i]);
-                System.out.println(">> Request URI: " + request.getRequestLine().getUri());
+                System.out.println(">> Request URI: " + request.getUri());
 
                 httpexecutor.preProcess(request, httpproc, coreContext);
                 HttpResponse response = httpexecutor.execute(request, conn, coreContext);
                 httpexecutor.postProcess(response, httpproc, coreContext);
 
-                System.out.println("<< Response: " + response.getStatusLine());
+                System.out.println("<< Response: " + response.getCode());
                 System.out.println(EntityUtils.toString(response.getEntity()));
                 System.out.println("==============");
                 if (!connStrategy.keepAlive(request, response, coreContext)) {

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPostTrailers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPostTrailers.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPostTrailers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalHttpPostTrailers.java Tue Mar 15 20:35:34 2016
@@ -75,7 +75,7 @@ public class ElementalHttpPostTrailers {
         HttpResponse response = httpexecutor.execute(request, conn, coreContext);
         httpexecutor.postProcess(response, httpproc, coreContext);
 
-        System.out.println("<< Response: " + response.getStatusLine());
+        System.out.println("<< Response: " + response.getCode());
         System.out.println(EntityUtils.toString(response.getEntity()));
         System.out.println("==============");
         conn.close();

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalPoolingHttpGet.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalPoolingHttpGet.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalPoolingHttpGet.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalPoolingHttpGet.java Tue Mar 15 20:35:34 2016
@@ -100,13 +100,13 @@ public class ElementalPoolingHttpGet {
                         coreContext.setTargetHost(this.target);
 
                         BasicHttpRequest request = new BasicHttpRequest("GET", "/");
-                        System.out.println(">> Request URI: " + request.getRequestLine().getUri());
+                        System.out.println(">> Request URI: " + request.getUri());
 
                         httpexecutor.preProcess(request, httpproc, coreContext);
                         HttpResponse response = httpexecutor.execute(request, conn, coreContext);
                         httpexecutor.postProcess(response, httpproc, coreContext);
 
-                        System.out.println("<< Response: " + response.getStatusLine());
+                        System.out.println("<< Response: " + response.getCode());
                         System.out.println(EntityUtils.toString(response.getEntity()));
 
                         reusable = connStrategy.keepAlive(request, response, coreContext);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalReverseProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalReverseProxy.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalReverseProxy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ElementalReverseProxy.java Tue Mar 15 20:35:34 2016
@@ -121,7 +121,7 @@ public class ElementalReverseProxy {
             context.setAttribute(HttpCoreContext.HTTP_CONNECTION, conn);
             context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
 
-            System.out.println(">> Request URI: " + request.getRequestLine().getUri());
+            System.out.println(">> Request URI: " + request.getUri());
 
             // Remove hop-by-hop headers
             request.removeHeaders(HttpHeaders.CONTENT_LENGTH);
@@ -146,11 +146,11 @@ public class ElementalReverseProxy {
             targetResponse.removeHeaders("Trailers");
             targetResponse.removeHeaders("Upgrade");
 
-            response.setStatusLine(targetResponse.getStatusLine());
+            response.setCode(targetResponse.getCode());
             response.setHeaders(targetResponse.getAllHeaders());
             response.setEntity(targetResponse.getEntity());
 
-            System.out.println("<< Response: " + response.getStatusLine());
+            System.out.println("<< Response: " + response.getCode());
 
             final boolean keepalive = this.connStrategy.keepAlive(request, response, context);
             context.setAttribute(HTTP_CONN_KEEPALIVE, new Boolean(keepalive));

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/HttpFileServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/HttpFileServer.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/HttpFileServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/HttpFileServer.java Tue Mar 15 20:35:34 2016
@@ -144,11 +144,11 @@ public class HttpFileServer {
                 final HttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
 
-            String method = request.getRequestLine().getMethod().toUpperCase(Locale.ROOT);
+            String method = request.getMethod().toUpperCase(Locale.ROOT);
             if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) {
                 throw new MethodNotSupportedException(method + " method not supported");
             }
-            String target = request.getRequestLine().getUri();
+            String target = request.getUri();
 
             HttpEntity incomingEntity = request.getEntity();
             if (incomingEntity != null) {
@@ -159,7 +159,7 @@ public class HttpFileServer {
             final File file = new File(this.docRoot, URLDecoder.decode(target, "UTF-8"));
             if (!file.exists()) {
 
-                response.setStatusCode(HttpStatus.SC_NOT_FOUND);
+                response.setCode(HttpStatus.SC_NOT_FOUND);
                 StringEntity outgoingEntity = new StringEntity(
                         "<html><body><h1>File" + file.getPath() +
                         " not found</h1></body></html>",
@@ -169,7 +169,7 @@ public class HttpFileServer {
 
             } else if (!file.canRead() || file.isDirectory()) {
 
-                response.setStatusCode(HttpStatus.SC_FORBIDDEN);
+                response.setCode(HttpStatus.SC_FORBIDDEN);
                 StringEntity outgoingEntity = new StringEntity(
                         "<html><body><h1>Access denied</h1></body></html>",
                         ContentType.create("text/html", "UTF-8"));
@@ -179,7 +179,7 @@ public class HttpFileServer {
             } else {
                 HttpCoreContext coreContext = HttpCoreContext.adapt(context);
                 HttpConnection conn = coreContext.getConnection(HttpConnection.class);
-                response.setStatusCode(HttpStatus.SC_OK);
+                response.setCode(HttpStatus.SC_OK);
                 FileEntity body = new FileEntity(file, ContentType.create("text/html", (Charset) null));
                 response.setEntity(body);
                 System.out.println(conn + ": serving file " + file.getPath());

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpClient.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpClient.java Tue Mar 15 20:35:34 2016
@@ -126,7 +126,7 @@ public class NHttpClient {
                 @Override
                 public void completed(final HttpResponse response) {
                     latch.countDown();
-                    System.out.println(target + "->" + response.getStatusLine());
+                    System.out.println(target + "->" + response.getCode());
                 }
 
                 @Override

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpFileServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpFileServer.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpFileServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpFileServer.java Tue Mar 15 20:35:34 2016
@@ -146,16 +146,16 @@ public class NHttpFileServer {
                 final HttpResponse response,
                 final HttpContext context) throws HttpException, IOException {
 
-            String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
+            String method = request.getMethod().toUpperCase(Locale.ENGLISH);
             if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) {
                 throw new MethodNotSupportedException(method + " method not supported");
             }
 
-            String target = request.getRequestLine().getUri();
+            String target = request.getUri();
             final File file = new File(this.docRoot, URLDecoder.decode(target, "UTF-8"));
             if (!file.exists()) {
 
-                response.setStatusCode(HttpStatus.SC_NOT_FOUND);
+                response.setCode(HttpStatus.SC_NOT_FOUND);
                 NStringEntity entity = new NStringEntity(
                         "<html><body><h1>File" + file.getPath() +
                         " not found</h1></body></html>",
@@ -165,7 +165,7 @@ public class NHttpFileServer {
 
             } else if (!file.canRead() || file.isDirectory()) {
 
-                response.setStatusCode(HttpStatus.SC_FORBIDDEN);
+                response.setCode(HttpStatus.SC_FORBIDDEN);
                 NStringEntity entity = new NStringEntity(
                         "<html><body><h1>Access denied</h1></body></html>",
                         ContentType.create("text/html", "UTF-8"));
@@ -176,7 +176,7 @@ public class NHttpFileServer {
 
                 HttpCoreContext coreContext = HttpCoreContext.adapt(context);
                 HttpConnection conn = coreContext.getConnection(HttpConnection.class);
-                response.setStatusCode(HttpStatus.SC_OK);
+                response.setCode(HttpStatus.SC_OK);
                 NFileEntity body = new NFileEntity(file, ContentType.create("text/html"));
                 response.setEntity(body);
                 System.out.println(conn + ": serving file " + file.getPath());

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpReverseProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpReverseProxy.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpReverseProxy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/NHttpReverseProxy.java Tue Mar 15 20:35:34 2016
@@ -31,7 +31,6 @@ import java.io.InterruptedIOException;
 import java.net.InetSocketAddress;
 import java.net.URI;
 import java.nio.ByteBuffer;
-import java.util.Locale;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.hc.core5.http.ConnectionReuseStrategy;
@@ -41,11 +40,9 @@ import org.apache.hc.core5.http.HttpRequ
 import org.apache.hc.core5.http.HttpRequestInterceptor;
 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.config.ConnectionConfig;
 import org.apache.hc.core5.http.entity.ContentType;
 import org.apache.hc.core5.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.hc.core5.http.impl.EnglishReasonPhraseCatalog;
 import org.apache.hc.core5.http.impl.nio.BasicAsyncResponseProducer;
 import org.apache.hc.core5.http.impl.nio.DefaultHttpClientIODispatch;
 import org.apache.hc.core5.http.impl.nio.DefaultHttpServerIODispatch;
@@ -374,8 +371,7 @@ public class NHttpReverseProxy {
                 if (ex != null) {
                     System.out.println("[client<-proxy] " + httpExchange.getId() + " " + ex);
                     int status = HttpStatus.SC_INTERNAL_SERVER_ERROR;
-                    HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, status,
-                            EnglishReasonPhraseCatalog.INSTANCE.getReason(status, Locale.US));
+                    HttpResponse response = new BasicHttpResponse(status);
                     String message = ex.getMessage();
                     if (message == null) {
                         message = "Unexpected error";
@@ -421,7 +417,7 @@ public class NHttpReverseProxy {
         @Override
         public void requestReceived(final HttpRequest request) {
             synchronized (this.httpExchange) {
-                System.out.println("[client->proxy] " + this.httpExchange.getId() + " " + request.getRequestLine());
+                System.out.println("[client->proxy] " + this.httpExchange.getId() + " " + request.getMethod() + " " + request.getUri());
                 this.httpExchange.setRequest(request);
                 this.executor.execute(
                         new ProxyRequestProducer(this.httpExchange),
@@ -518,9 +514,9 @@ public class NHttpReverseProxy {
         public HttpRequest generateRequest() {
             synchronized (this.httpExchange) {
                 HttpRequest request = this.httpExchange.getRequest();
-                System.out.println("[proxy->origin] " + this.httpExchange.getId() + " " + request.getRequestLine());
+                System.out.println("[proxy->origin] " + this.httpExchange.getId() + " " + request.getMethod() + " " + request.getUri());
                 // Rewrite request!!!!
-                BasicHttpRequest newREquest = new BasicHttpRequest(request.getRequestLine());
+                BasicHttpRequest newREquest = new BasicHttpRequest(request.getMethod(), request.getUri());
                 newREquest.setEntity(request.getEntity());
                 return newREquest;
             }
@@ -600,7 +596,7 @@ public class NHttpReverseProxy {
         @Override
         public void responseReceived(final HttpResponse response) {
             synchronized (this.httpExchange) {
-                System.out.println("[proxy<-origin] " + this.httpExchange.getId() + " " + response.getStatusLine());
+                System.out.println("[proxy<-origin] " + this.httpExchange.getId() + " " + response.getCode());
                 this.httpExchange.setResponse(response);
                 HttpAsyncExchange responseTrigger = this.httpExchange.getResponseTrigger();
                 if (responseTrigger != null && !responseTrigger.isCompleted()) {
@@ -667,8 +663,7 @@ public class NHttpReverseProxy {
                 if (responseTrigger != null && !responseTrigger.isCompleted()) {
                     System.out.println("[client<-proxy] " + this.httpExchange.getId() + " " + ex);
                     int status = HttpStatus.SC_INTERNAL_SERVER_ERROR;
-                    HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, status,
-                            EnglishReasonPhraseCatalog.INSTANCE.getReason(status, Locale.US));
+                    HttpResponse response = new BasicHttpResponse(status);
                     String message = ex.getMessage();
                     if (message == null) {
                         message = "Unexpected error";
@@ -725,9 +720,9 @@ public class NHttpReverseProxy {
         public HttpResponse generateResponse() {
             synchronized (this.httpExchange) {
                 HttpResponse response = this.httpExchange.getResponse();
-                System.out.println("[client<-proxy] " + this.httpExchange.getId() + " " + response.getStatusLine());
+                System.out.println("[client<-proxy] " + this.httpExchange.getId() + " " + response.getCode());
                 // Rewrite response!!!!
-                BasicHttpResponse r = new BasicHttpResponse(response.getStatusLine());
+                BasicHttpResponse r = new BasicHttpResponse(response.getCode());
                 r.setEntity(response.getEntity());
                 return r;
             }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/PipeliningHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/PipeliningHttpClient.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/PipeliningHttpClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/PipeliningHttpClient.java Tue Mar 15 20:35:34 2016
@@ -132,7 +132,7 @@ public class PipeliningHttpClient {
                     public void completed(final List<HttpResponse> result) {
                         latch.countDown();
                         for (HttpResponse response: result) {
-                            System.out.println(target + "->" + response.getStatusLine());
+                            System.out.println(target + "->" + response.getCode());
                         }
                     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java Tue Mar 15 20:35:34 2016
@@ -80,6 +80,13 @@ public interface HttpConnection extends
     void shutdown() throws IOException;
 
     /**
+     * Returns protocol version used by this connection or {@code null} if unknown.
+     *
+     * @since 5.0
+     */
+    ProtocolVersion getProtocolVersion();
+
+    /**
      * Returns a collection of connection metrics.
      *
      * @return HttpConnectionMetrics

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpMessage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpMessage.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpMessage.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpMessage.java Tue Mar 15 20:35:34 2016
@@ -36,9 +36,26 @@ package org.apache.hc.core5.http;
 public interface HttpMessage<T> extends MessageHead {
 
     /**
-     * Returns the protocol version this message is compatible with.
+     * Sets protocol version.
+     * <p>
+     * For incoming messages it represents protocol version this message was transmitted with.
+     * For outgoing messages it represents a hint what protocol version should be used to transmit
+     * the message.
+     *
+     * @since 5.0
      */
-    ProtocolVersion getProtocolVersion();
+    void setVersion(ProtocolVersion version);
+
+    /**
+     * Returns protocol version or {@code null} when not available.
+     * <p>
+     * For incoming messages it represents protocol version this message was transmitted with.
+     * For outgoing messages it represents a hint what protocol version should be used to transmit
+     * the message.
+     *
+     * @since 5.0
+     */
+    ProtocolVersion getVersion();
 
     /**
      * Adds a header to this message. The header will be appended to the end of

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -37,9 +37,17 @@ package org.apache.hc.core5.http;
 public interface HttpRequest extends HttpMessage<HttpEntity> {
 
     /**
-     * Returns the request line of this request.
-     * @return the request line.
+     * Obtains the method of this request message.
+     *
+     * @return  the request method.
      */
-    RequestLine getRequestLine();
+    String getMethod();
+
+    /**
+     * Obtains the URI of this request message.
+     *
+     * @return  the request URI.
+     */
+    String getUri();
 
 }

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -34,10 +34,27 @@ package org.apache.hc.core5.http;
  */
 public interface HttpRequestFactory {
 
-    HttpRequest newHttpRequest(RequestLine requestline)
-        throws MethodNotSupportedException;
+    /**
+     * 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
+     *
+     * @return  request message
+     *
+     * @since 5.0
+     */
+    HttpRequest newHttpRequest(ProtocolVersion transportVersion, String method, String uri) throws MethodNotSupportedException;
 
-    HttpRequest newHttpRequest(String method, String uri)
-            throws MethodNotSupportedException;
+    /**
+     * Creates request message with the given request method and request URI.
+     *
+     * @param method  the request method
+     * @param uri the request URI
+     *
+     * @return  request message
+     */
+    HttpRequest newHttpRequest(String method, String uri) throws MethodNotSupportedException;
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponse.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponse.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponse.java Tue Mar 15 20:35:34 2016
@@ -38,76 +38,40 @@ import java.util.Locale;
 public interface HttpResponse extends HttpMessage<HttpEntity> {
 
     /**
-     * Obtains the code in the status line of this response.
-     * The status line can be set using one of the
-     * {@link #setStatusLine setStatusLine} methods,
-     * or it can be initialized in a constructor.
+     * Obtains the code of this response message.
      *
-     * @return  the status code, or {@code 0} if not yet set
+     * @return  the status code.
      */
     int getCode();
 
     /**
-     * Obtains the status line of this response.
-     * The status line can be set using one of the
-     * {@link #setStatusLine setStatusLine} methods,
-     * or it can be initialized in a constructor.
+     * Updates status code of this response message.
      *
-     * @return  the status line, or {@code null} if not yet set
-     */
-    StatusLine getStatusLine();
-
-    /**
-     * Sets the status line of this response.
-     *
-     * @param statusline the status line of this response
-     */
-    void setStatusLine(StatusLine statusline);
-
-    /**
-     * Sets the status line of this response.
-     * The reason phrase will be determined based on the current
-     * {@link #getLocale locale}.
-     *
-     * @param ver       the HTTP version
-     * @param code      the status code
-     */
-    void setStatusLine(ProtocolVersion ver, int code);
-
-    /**
-     * Sets the status line of this response with a reason phrase.
+     * @param code the HTTP status code.
      *
-     * @param ver       the HTTP version
-     * @param code      the status code
-     * @param reason    the reason phrase, or {@code null} to omit
+     * @see HttpStatus
      */
-    void setStatusLine(ProtocolVersion ver, int code, String reason);
+    void setCode(int code);
 
     /**
-     * Updates the status line of this response with a new status code.
-     *
-     * @param code the HTTP status code.
+     * Obtains the reason phrase of this response if available.
      *
-     * @see HttpStatus
-     * @see #setStatusLine(StatusLine)
-     * @see #setStatusLine(ProtocolVersion,int)
+     * @return  the reason phrase.
      */
-    void setStatusCode(int code);
+    String getReasonPhrase();
 
     /**
      * Updates the status line of this response with a new reason phrase.
      *
      * @param reason    the new reason phrase as a single-line string, or
      *                  {@code null} to unset the reason phrase
-     * @see #setStatusLine(StatusLine)
-     * @see #setStatusLine(ProtocolVersion,int)
      */
     void setReasonPhrase(String reason);
 
     /**
      * Obtains the locale of this response.
      * The locale is used to determine the reason phrase
-     * for the {@link #setStatusCode status code}.
+     * for the {@link #setCode status code}.
      * It can be changed using {@link #setLocale setLocale}.
      *
      * @return  the locale of this response, never {@code null}

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -27,8 +27,6 @@
 
 package org.apache.hc.core5.http;
 
-import org.apache.hc.core5.http.protocol.HttpContext;
-
 /**
  * A factory for {@link HttpResponse HttpResponse} objects.
  *
@@ -37,28 +35,25 @@ import org.apache.hc.core5.http.protocol
 public interface HttpResponseFactory {
 
     /**
-     * Creates a new response from status line elements.
+     * 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 context   the context from which to determine the locale
-     *                  for looking up a reason phrase to the status code, or
-     *                  {@code null} to use the default locale
+     * @param reasonPhrase the reason phrase
+     *
+     * @return  response message
      *
-     * @return  the new response with an initialized status line
+     * @since 5.0
      */
-    HttpResponse newHttpResponse(int status, HttpContext context);
+    HttpResponse newHttpResponse(ProtocolVersion transportVersion, int status, String reasonPhrase);
 
     /**
-     * Creates a new response from a status line.
+     * Creates a new response with the given code.
      *
-     * @param statusline the status line
-     * @param context    the context from which to determine the locale
-     *                   for looking up a reason phrase if the status code
-     *                   is updated, or
-     *                   {@code null} to use the default locale
+     * @param status    the status code
      *
-     * @return  the new response with the argument status line
+     * @return  response message
      */
-    HttpResponse newHttpResponse(StatusLine statusline, HttpContext context);
+    HttpResponse newHttpResponse(int status);
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpVersion.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpVersion.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpVersion.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpVersion.java Tue Mar 15 20:35:34 2016
@@ -60,6 +60,9 @@ public final class HttpVersion extends P
     public static final HttpVersion HTTP_2_0 = new HttpVersion(2, 0);
     public static final HttpVersion HTTP_2   = HTTP_2_0;
 
+    /** HTTP/1.1 is default */
+    public static final HttpVersion DEFAULT  = HTTP_1_1;
+
     /**
      * Create an HTTP protocol version designator.
      *

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultConnectionReuseStrategy.java Tue Mar 15 20:35:34 2016
@@ -94,7 +94,6 @@ public class DefaultConnectionReuseStrat
 
         // Check for a self-terminating entity. If the end of the entity will
         // be indicated by closing the connection, there is no keep-alive.
-        final ProtocolVersion ver = response.getStatusLine().getProtocolVersion();
         final Header teh = response.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
         if (teh != null) {
             if (!HeaderElements.CHUNKED_ENCODING.equalsIgnoreCase(teh.getValue())) {
@@ -114,6 +113,7 @@ public class DefaultConnectionReuseStrat
             connHeaders = response.getHeaders("Proxy-Connection");
         }
 
+        final ProtocolVersion ver = context.getProtocolVersion();
         if (connHeaders.length != 0) {
             if (ver.greaterEquals(HttpVersion.HTTP_1_1)) {
                 final Iterator<String> it = new BasicTokenIterator(new BasicHeaderIterator(connHeaders, null));

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpRequestFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpRequestFactory.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpRequestFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpRequestFactory.java Tue Mar 15 20:35:34 2016
@@ -31,9 +31,8 @@ import org.apache.hc.core5.annotation.Im
 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.RequestLine;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
-import org.apache.hc.core5.util.Args;
 
 /**
  * Default factory for creating {@link HttpRequest} objects.
@@ -57,10 +56,6 @@ public class DefaultHttpRequestFactory i
             "CONNECT"
     };
 
-    public DefaultHttpRequestFactory() {
-        super();
-    }
-
     private static boolean isOneOf(final String[] methods, final String method) {
         for (final String method2 : methods) {
             if (method2.equalsIgnoreCase(method)) {
@@ -71,24 +66,18 @@ public class DefaultHttpRequestFactory i
     }
 
     @Override
-    public HttpRequest newHttpRequest(final RequestLine requestline)
-            throws MethodNotSupportedException {
-        Args.notNull(requestline, "Request line");
-        final String method = requestline.getMethod();
+    public HttpRequest newHttpRequest(final ProtocolVersion transportVersion, final String method, final String uri) throws MethodNotSupportedException {
         if (isOneOf(SUPPORTED_METHODS, method)) {
-            return new BasicHttpRequest(requestline);
+            final HttpRequest request = new BasicHttpRequest(method, uri);
+            request.setVersion(transportVersion);
+            return request;
         }
-        throw new MethodNotSupportedException(method +  " method not supported");
+        throw new MethodNotSupportedException(method + " method not supported");
     }
 
     @Override
-    public HttpRequest newHttpRequest(final String method, final String uri)
-            throws MethodNotSupportedException {
-        if (isOneOf(SUPPORTED_METHODS, method)) {
-            return new BasicHttpRequest(method, uri);
-        }
-        throw new MethodNotSupportedException(method
-                + " method not supported");
+    public HttpRequest newHttpRequest(final String method, final String uri) throws MethodNotSupportedException {
+        return new BasicHttpRequest(method, uri);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpResponseFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpResponseFactory.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpResponseFactory.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/DefaultHttpResponseFactory.java Tue Mar 15 20:35:34 2016
@@ -27,17 +27,12 @@
 
 package org.apache.hc.core5.http.impl;
 
-import java.util.Locale;
-
 import org.apache.hc.core5.annotation.Immutable;
 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.ReasonPhraseCatalog;
-import org.apache.hc.core5.http.StatusLine;
 import org.apache.hc.core5.http.message.BasicHttpResponse;
-import org.apache.hc.core5.http.message.BasicStatusLine;
-import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.util.Args;
 
 /**
@@ -50,9 +45,7 @@ public class DefaultHttpResponseFactory
 
     public static final DefaultHttpResponseFactory INSTANCE = new DefaultHttpResponseFactory();
 
-    /** The catalog for looking up reason phrases. */
-    protected final ReasonPhraseCatalog reasonCatalog;
-
+    private final ReasonPhraseCatalog reasonCatalog;
 
     /**
      * Creates a new response factory with the given catalog.
@@ -71,37 +64,19 @@ public class DefaultHttpResponseFactory
         this(EnglishReasonPhraseCatalog.INSTANCE);
     }
 
-
-    // non-javadoc, see interface HttpResponseFactory
     @Override
-    public HttpResponse newHttpResponse(final int status, final HttpContext context) {
-        final Locale loc = determineLocale(context);
-        final String reason   = this.reasonCatalog.getReason(status, loc);
-        final StatusLine statusline = new BasicStatusLine(HttpVersion.HTTP_1_1, status, reason);
-        return new BasicHttpResponse(statusline, this.reasonCatalog, loc);
+    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;
     }
 
-
-    // non-javadoc, see interface HttpResponseFactory
     @Override
-    public HttpResponse newHttpResponse(
-            final StatusLine statusline,
-            final HttpContext context) {
-        Args.notNull(statusline, "Status line");
-        return new BasicHttpResponse(statusline, this.reasonCatalog, determineLocale(context));
-    }
-
-    /**
-     * Determines the locale of the response.
-     * The implementation in this class always returns the default locale.
-     *
-     * @param context   the context from which to determine the locale, or
-     *                  {@code null} to use the default locale
-     *
-     * @return  the locale for the response, never {@code null}
-     */
-    protected Locale determineLocale(final HttpContext context) {
-        return Locale.getDefault();
+    public HttpResponse newHttpResponse(final int status) {
+        return new BasicHttpResponse(status, this.reasonCatalog, null);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java Tue Mar 15 20:35:34 2016
@@ -44,6 +44,7 @@ import org.apache.hc.core5.http.HttpConn
 import org.apache.hc.core5.http.HttpEntity;
 import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpMessage;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.TrailerSupplier;
 import org.apache.hc.core5.http.config.MessageConstraints;
 import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
@@ -63,6 +64,8 @@ class BHttpConnectionBase implements BHt
     final HttpConnectionMetricsImpl connMetrics;
     final AtomicReference<Socket> socketHolder;
 
+    volatile ProtocolVersion version;
+
     BHttpConnectionBase(
             final int buffersize,
             final int fragmentSizeHint,
@@ -118,6 +121,14 @@ class BHttpConnectionBase implements BHt
         return this.socketHolder.get() != null;
     }
 
+    /**
+     * @since 5.0
+     */
+    @Override
+    public ProtocolVersion getProtocolVersion() {
+        return this.version;
+    }
+
     Socket getSocket() {
         return this.socketHolder.get();
     }

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -187,6 +187,7 @@ public class DefaultBHttpClientConnectio
     public HttpResponse receiveResponseHeader() throws HttpException, IOException {
         final Socket socket = ensureOpen();
         final HttpResponse response = this.responseParser.parse(this.inbuffer, socket.getInputStream());
+        this.version = response.getVersion();
         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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -131,6 +131,7 @@ public class DefaultBHttpServerConnectio
     public HttpRequest receiveRequestHeader() throws HttpException, IOException {
         final Socket socket = ensureOpen();
         final HttpRequest request = this.requestParser.parse(this.inbuffer, socket.getInputStream());
+        this.version = request.getVersion();
         onRequestReceived(request);
         incrementRequestCount();
         return request;

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -36,11 +36,11 @@ import org.apache.hc.core5.http.HttpRequ
 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.RequestLine;
 import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.MessageConstraints;
 import org.apache.hc.core5.http.impl.DefaultHttpRequestFactory;
 import org.apache.hc.core5.http.message.LineParser;
+import org.apache.hc.core5.http.message.RequestLine;
 import org.apache.hc.core5.util.CharArrayBuffer;
 
 /**
@@ -96,11 +96,11 @@ public class DefaultHttpRequestParser ex
     @Override
     protected HttpRequest createMessage(final CharArrayBuffer buffer) throws IOException, HttpException {
         final RequestLine requestLine = getLineParser().parseRequestLine(buffer);
-        final ProtocolVersion version = requestLine.getProtocolVersion();
-        if (version.greaterEquals(HttpVersion.HTTP_2)) {
-            throw new UnsupportedHttpVersionException("Unsupported version: " + version);
+        final ProtocolVersion transportVersion = requestLine.getProtocolVersion();
+        if (transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
         }
-        return this.requestFactory.newHttpRequest(requestLine);
+        return this.requestFactory.newHttpRequest(requestLine.getProtocolVersion(), requestLine.getMethod(), requestLine.getUri());
     }
 
 }

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -31,7 +31,10 @@ import java.io.IOException;
 
 import org.apache.hc.core5.annotation.NotThreadSafe;
 import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.LineFormatter;
+import org.apache.hc.core5.http.message.RequestLine;
 import org.apache.hc.core5.util.CharArrayBuffer;
 
 /**
@@ -61,7 +64,12 @@ public class DefaultHttpRequestWriter ex
     @Override
     protected void writeHeadLine(
             final HttpRequest message, final CharArrayBuffer lineBuf) throws IOException {
-        getLineFormatter().formatRequestLine(lineBuf, message.getRequestLine());
+        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.getUri(), transportVersion));
     }
 
 }

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -36,11 +36,11 @@ import org.apache.hc.core5.http.HttpResp
 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.StatusLine;
 import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.MessageConstraints;
 import org.apache.hc.core5.http.impl.DefaultHttpResponseFactory;
 import org.apache.hc.core5.http.message.LineParser;
+import org.apache.hc.core5.http.message.StatusLine;
 import org.apache.hc.core5.util.CharArrayBuffer;
 
 /**
@@ -96,11 +96,11 @@ public class DefaultHttpResponseParser e
     @Override
     protected HttpResponse createMessage(final CharArrayBuffer buffer) throws IOException, HttpException {
         final StatusLine statusline = getLineParser().parseStatusLine(buffer);
-        final ProtocolVersion version = statusline.getProtocolVersion();
-        if (version.greaterEquals(HttpVersion.HTTP_2)) {
-            throw new UnsupportedHttpVersionException("Unsupported version: " + version);
+        final ProtocolVersion transportVersion = statusline.getProtocolVersion();
+        if (transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
         }
-        return this.responseFactory.newHttpResponse(statusline, null);
+        return this.responseFactory.newHttpResponse(transportVersion, statusline.getStatusCode(), statusline.getReasonPhrase());
     }
 
 }

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -31,7 +31,10 @@ import java.io.IOException;
 
 import org.apache.hc.core5.annotation.NotThreadSafe;
 import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.LineFormatter;
+import org.apache.hc.core5.http.message.StatusLine;
 import org.apache.hc.core5.util.CharArrayBuffer;
 
 /**
@@ -61,7 +64,12 @@ public class DefaultHttpResponseWriter e
     @Override
     protected void writeHeadLine(
             final HttpResponse message, final CharArrayBuffer lineBuf) throws IOException {
-        getLineFormatter().formatStatusLine(lineBuf, message.getStatusLine());
+        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()));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java Tue Mar 15 20:35:34 2016
@@ -38,6 +38,7 @@ import org.apache.hc.core5.http.HttpRequ
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.io.HttpClientConnection;
 import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http.protocol.HttpCoreContext;
@@ -92,7 +93,7 @@ public class HttpRequestExecutor {
     protected boolean canResponseHaveBody(final HttpRequest request,
                                           final HttpResponse response) {
 
-        if ("HEAD".equalsIgnoreCase(request.getRequestLine().getMethod())) {
+        if ("HEAD".equalsIgnoreCase(request.getMethod())) {
             return false;
         }
         final int status = response.getCode();
@@ -145,7 +146,7 @@ public class HttpRequestExecutor {
                         final int status = response.getCode();
                         if (status < HttpStatus.SC_SUCCESS) {
                             if (status != HttpStatus.SC_CONTINUE) {
-                                throw new ProtocolException("Unexpected response: " + response.getStatusLine());
+                                throw new ProtocolException("Unexpected response: " + response.getCode());
                             }
                             // discard 100-continue
                             response = null;
@@ -233,6 +234,10 @@ public class HttpRequestExecutor {
         Args.notNull(response, "HTTP response");
         Args.notNull(processor, "HTTP processor");
         Args.notNull(context, "HTTP context");
+        final ProtocolVersion transportVersion = response.getVersion();
+        if (transportVersion != null) {
+            context.setProtocolVersion(transportVersion);
+        }
         context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
         processor.process(response, context);
     }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java Tue Mar 15 20:35:34 2016
@@ -42,6 +42,7 @@ import org.apache.hc.core5.http.HttpStat
 import org.apache.hc.core5.http.MethodNotSupportedException;
 import org.apache.hc.core5.http.NotImplementedException;
 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.entity.ContentType;
 import org.apache.hc.core5.http.entity.EntityUtils;
@@ -164,19 +165,22 @@ public class HttpService {
         context.setAttribute(HttpCoreContext.HTTP_CONNECTION, conn);
 
         final HttpRequest request = conn.receiveRequestHeader();
+        final ProtocolVersion transportVersion = request.getVersion();
+        if (transportVersion != null) {
+            context.setProtocolVersion(transportVersion);
+        }
 
         final Header expect = request.getFirstHeader(HttpHeaders.EXPECT);
         final boolean expectContinue = expect != null && "100-continue".equalsIgnoreCase(expect.getValue());
 
-        HttpResponse response = null;
-
+        HttpResponse response;
         if (expectContinue) {
-            response = this.responseFactory.newHttpResponse(HttpStatus.SC_CONTINUE, context);
+            response = this.responseFactory.newHttpResponse(HttpStatus.SC_CONTINUE);
             if (this.expectationVerifier != null) {
                 try {
                     this.expectationVerifier.verify(request, response, context);
                 } catch (final HttpException ex) {
-                    response = this.responseFactory.newHttpResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
+                    response = this.responseFactory.newHttpResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR);
                     handleException(ex, response);
                 }
             }
@@ -185,7 +189,6 @@ public class HttpService {
                 // have been met
                 conn.sendResponseHeader(response);
                 conn.flush();
-                response = null;
             } else {
                 context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
                 context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
@@ -206,14 +209,14 @@ public class HttpService {
             context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
             this.processor.process(request, context);
 
-            response = this.responseFactory.newHttpResponse(HttpStatus.SC_OK, context);
+            response = this.responseFactory.newHttpResponse(HttpStatus.SC_OK);
             doService(request, response, context);
 
             context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
             this.processor.process(response, context);
 
         } catch (final HttpException ex) {
-            response = this.responseFactory.newHttpResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
+            response = this.responseFactory.newHttpResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR);
             handleException(ex, response);
             context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
             this.processor.process(response, context);
@@ -235,7 +238,7 @@ public class HttpService {
     }
 
     private boolean canResponseHaveBody(final HttpRequest request, final HttpResponse response) {
-        if (request != null && "HEAD".equalsIgnoreCase(request.getRequestLine().getMethod())) {
+        if (request != null && "HEAD".equalsIgnoreCase(request.getMethod())) {
             return false;
         }
         final int status = response.getCode();
@@ -255,15 +258,15 @@ public class HttpService {
      */
     protected void handleException(final HttpException ex, final HttpResponse response) {
         if (ex instanceof MethodNotSupportedException) {
-            response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
+            response.setCode(HttpStatus.SC_NOT_IMPLEMENTED);
         } else if (ex instanceof UnsupportedHttpVersionException) {
-            response.setStatusCode(HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED);
+            response.setCode(HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED);
         } else if (ex instanceof NotImplementedException) {
-            response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
+            response.setCode(HttpStatus.SC_NOT_IMPLEMENTED);
         } else if (ex instanceof ProtocolException) {
-            response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
+            response.setCode(HttpStatus.SC_BAD_REQUEST);
         } else {
-            response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+            response.setCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
         }
         String message = ex.getMessage();
         if (message == null) {
@@ -301,7 +304,7 @@ public class HttpService {
         if (handler != null) {
             handler.handle(request, response, context);
         } else {
-            response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
+            response.setCode(HttpStatus.SC_NOT_IMPLEMENTED);
         }
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/BasicAsyncClientExchangeHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/BasicAsyncClientExchangeHandler.java?rev=1735164&r1=1735163&r2=1735164&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/BasicAsyncClientExchangeHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/BasicAsyncClientExchangeHandler.java Tue Mar 15 20:35:34 2016
@@ -37,6 +37,7 @@ import org.apache.hc.core5.http.Connecti
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.nio.ContentDecoder;
 import org.apache.hc.core5.http.nio.ContentEncoder;
 import org.apache.hc.core5.http.nio.HttpAsyncClientExchangeHandler;
@@ -170,6 +171,10 @@ public class BasicAsyncClientExchangeHan
     @Override
     public void responseReceived(final HttpResponse response) throws IOException, HttpException {
         this.localContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
+        final ProtocolVersion transportVersion = response.getVersion();
+        if (transportVersion != null) {
+            this.localContext.setProtocolVersion(transportVersion);
+        }
         this.httppocessor.process(response, this.localContext);
         this.responseConsumer.responseReceived(response);
     }

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -33,11 +33,11 @@ import org.apache.hc.core5.http.HttpRequ
 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.RequestLine;
 import org.apache.hc.core5.http.UnsupportedHttpVersionException;
 import org.apache.hc.core5.http.config.MessageConstraints;
 import org.apache.hc.core5.http.impl.DefaultHttpRequestFactory;
 import org.apache.hc.core5.http.message.LineParser;
+import org.apache.hc.core5.http.message.RequestLine;
 import org.apache.hc.core5.util.CharArrayBuffer;
 
 /**
@@ -88,11 +88,11 @@ public class DefaultHttpRequestParser ex
     @Override
     protected HttpRequest createMessage(final CharArrayBuffer buffer) throws HttpException {
         final RequestLine requestLine = getLineParser().parseRequestLine(buffer);
-        final ProtocolVersion version = requestLine.getProtocolVersion();
-        if (version.greaterEquals(HttpVersion.HTTP_2)) {
-            throw new UnsupportedHttpVersionException("Unsupported version: " + version);
+        final ProtocolVersion transportVersion = requestLine.getProtocolVersion();
+        if (transportVersion.greaterEquals(HttpVersion.HTTP_2)) {
+            throw new UnsupportedHttpVersionException("Unsupported version: " + transportVersion);
         }
-        return this.requestFactory.newHttpRequest(requestLine);
+        return this.requestFactory.newHttpRequest(transportVersion, requestLine.getMethod(), requestLine.getUri());
     }
 
 }

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=1735164&r1=1735163&r2=1735164&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 Tue Mar 15 20:35:34 2016
@@ -31,7 +31,10 @@ import java.io.IOException;
 
 import org.apache.hc.core5.annotation.NotThreadSafe;
 import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.ProtocolVersion;
 import org.apache.hc.core5.http.message.LineFormatter;
+import org.apache.hc.core5.http.message.RequestLine;
 import org.apache.hc.core5.util.CharArrayBuffer;
 
 /**
@@ -65,7 +68,12 @@ public class DefaultHttpRequestWriter ex
     @Override
     protected void writeHeadLine(final HttpRequest message, final CharArrayBuffer lineBuf) throws IOException {
         lineBuf.clear();
-        getLineFormatter().formatRequestLine(lineBuf, message.getRequestLine());
+        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.getUri(), transportVersion));
     }
 
 }




Mime
View raw message