[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpcomponents-commits
Subject:    svn commit: r1762527 [2/3] - in /httpcomponents/httpcore/trunk: httpcore5-h2/src/main/java/org/apach
From:       olegk () apache ! org
Date:       2016-09-27 17:49:46
Message-ID: 20160927174947.6EF8C3A0EF6 () svn01-us-west ! apache ! org
[Download RAW message or body]

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicRequestConsumer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/BasicRequestConsumer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicRequestConsumer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicRequestConsumer.java \
Tue Sep 27 17:49:46 2016 @@ -31,9 +31,9 @@ import java.nio.ByteBuffer;
 import java.util.List;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.Message;
 import org.apache.hc.core5.util.Args;
@@ -52,13 +52,12 @@ public class BasicRequestConsumer<T> imp
     @Override
     public void consumeRequest(
             final HttpRequest request,
-            final boolean enclosedBody,
+            final EntityDetails entityDetails,
             final FutureCallback<Message<HttpRequest, T>> resultCallback) throws \
HttpException, IOException {  Args.notNull(request, "Request");
         Args.notNull(resultCallback, "Result callback");
-        if (enclosedBody) {
-            final Header header = request.getFirstHeader(HttpHeaders.CONTENT_TYPE);
-            dataConsumer.streamStart(header != null ? header.getValue() : null, new \
FutureCallback<T>() { +        if (entityDetails != null) {
+            dataConsumer.streamStart(entityDetails, new FutureCallback<T>() {
 
                 @Override
                 public void completed(final T result) {

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicRequestProducer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/BasicRequestProducer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicRequestProducer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicRequestProducer.java \
Tue Sep 27 17:49:46 2016 @@ -29,7 +29,7 @@ package org.apache.hc.core5.http2.nio;
 import java.io.IOException;
 import java.net.URI;
 
-import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
 
@@ -53,20 +53,12 @@ public class BasicRequestProducer implem
 
     @Override
     public HttpRequest produceRequest() {
-        if (!request.containsHeader(HttpHeaders.CONTENT_TYPE)) {
-            if (dataProducer != null) {
-                final String contentType = dataProducer.getContentType();
-                if (contentType != null) {
-                    request.addHeader(HttpHeaders.CONTENT_TYPE, contentType);
-                }
-            }
-        }
         return request;
     }
 
     @Override
-    public boolean isEnclosingEntity() {
-        return dataProducer != null;
+    public EntityDetails getEntityDetails() {
+        return dataProducer;
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicResponseConsumer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/BasicResponseConsumer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicResponseConsumer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicResponseConsumer.java \
Tue Sep 27 17:49:46 2016 @@ -31,9 +31,9 @@ import java.nio.ByteBuffer;
 import java.util.List;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
-import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.Message;
 import org.apache.hc.core5.util.Args;
@@ -52,11 +52,11 @@ public class BasicResponseConsumer<T> im
     @Override
     public void consumeResponse(
             final HttpResponse response,
+            final EntityDetails entityDetails,
             final FutureCallback<Message<HttpResponse, T>> resultCallback) throws \
HttpException, IOException {  Args.notNull(response, "Response");
         Args.notNull(resultCallback, "Result callback");
-        final Header header = response.getFirstHeader(HttpHeaders.CONTENT_TYPE);
-        dataConsumer.streamStart(header != null ? header.getValue() : null, new \
FutureCallback<T>() { +        dataConsumer.streamStart(entityDetails, new \
FutureCallback<T>() {  
             @Override
             public void completed(final T result) {

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicResponseProducer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/BasicResponseProducer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicResponseProducer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/BasicResponseProducer.java \
Tue Sep 27 17:49:46 2016 @@ -28,7 +28,7 @@ package org.apache.hc.core5.http2.nio;
 
 import java.io.IOException;
 
-import org.apache.hc.core5.http.HttpHeaders;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.message.BasicHttpResponse;
@@ -57,20 +57,12 @@ public class BasicResponseProducer imple
 
     @Override
     public HttpResponse produceResponse() {
-        if (!response.containsHeader(HttpHeaders.CONTENT_TYPE)) {
-            if (dataProducer != null) {
-                final String contentType = dataProducer.getContentType();
-                if (contentType != null) {
-                    response.addHeader(HttpHeaders.CONTENT_TYPE, contentType);
-                }
-            }
-        }
         return response;
     }
 
     @Override
-    public boolean isEnclosingEntity() {
-        return dataProducer != null;
+    public EntityDetails getEntityDetails() {
+        return dataProducer;
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/ResponseChannel.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java \
Tue Sep 27 17:49:46 2016 @@ -31,6 +31,7 @@ import java.io.IOException;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
@@ -45,7 +46,7 @@ import org.apache.hc.core5.http.HttpResp
 @Contract(threading = ThreadingBehavior.SAFE)
 public interface ResponseChannel {
 
-    void sendResponse(HttpResponse response, boolean endStream) throws \
HttpException, IOException; +    void sendResponse(HttpResponse response, \
EntityDetails entityDetails) throws HttpException, IOException;  
     void pushPromise(HttpRequest promise, AsyncPushProducer pushProducer) throws \
HttpException, IOException;  

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/command/ClientCommandEndpoint.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/command/ClientCommandEndpoint.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/command/ClientCommandEndpoint.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/command/ClientCommandEndpoint.java \
Tue Sep 27 17:49:46 2016 @@ -34,6 +34,8 @@ import org.apache.hc.core5.annotation.Co
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.concurrent.BasicFuture;
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpCoreContext;
 import org.apache.hc.core5.http2.nio.AsyncRequestProducer;
 import org.apache.hc.core5.http2.nio.AsyncResponseConsumer;
 import org.apache.hc.core5.reactor.Command;
@@ -57,9 +59,14 @@ public final class ClientCommandEndpoint
     public <T> Future<T> execute(
             final AsyncRequestProducer requestProducer,
             final AsyncResponseConsumer<T> responseConsumer,
+            final HttpContext context,
             final FutureCallback<T> callback) {
         final BasicFuture<T> future = new BasicFuture<>(callback);
-        final Command executionCommand = new ExecutionCommand<>(requestProducer, \
responseConsumer, new FutureCallback<T>() { +        final Command executionCommand = \
new ExecutionCommand<>( +                requestProducer,
+                responseConsumer,
+                context != null ? context : HttpCoreContext.create(),
+                new FutureCallback<T>() {
 
             @Override
             public void completed(final T result) {
@@ -82,6 +89,13 @@ public final class ClientCommandEndpoint
         return future;
     }
 
+    public <T> Future<T> execute(
+            final AsyncRequestProducer requestProducer,
+            final AsyncResponseConsumer<T> responseConsumer,
+            final FutureCallback<T> callback) {
+        return execute(requestProducer, responseConsumer, HttpCoreContext.create(), \
callback); +    }
+
     public void requestGracefulShutdown() {
         ioSession.getCommandQueue().addFirst(ShutdownCommand.GRACEFUL);
         ioSession.setEvent(SelectionKey.OP_WRITE);

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/command/ExecutionCommand.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/command/ExecutionCommand.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/command/ExecutionCommand.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/command/ExecutionCommand.java \
Tue Sep 27 17:49:46 2016 @@ -28,9 +28,11 @@
 package org.apache.hc.core5.http2.nio.command;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http2.nio.AsyncRequestProducer;
 import org.apache.hc.core5.http2.nio.AsyncResponseConsumer;
 import org.apache.hc.core5.reactor.Command;
+import org.apache.hc.core5.util.Args;
 
 /**
  * Request execution command.
@@ -43,14 +45,17 @@ public final class ExecutionCommand<T> i
 
     private final AsyncRequestProducer requestProducer;
     private final AsyncResponseConsumer<T> responseConsumer;
+    private final HttpContext context;
     private final FutureCallback<T> callback;
 
     public ExecutionCommand(
             final AsyncRequestProducer requestProducer,
             final AsyncResponseConsumer<T> responseConsumer,
+            final HttpContext context,
             final FutureCallback<T> callback) {
-        this.requestProducer = requestProducer;
-        this.responseConsumer = responseConsumer;
+        this.requestProducer = Args.notNull(requestProducer, "Request producer");
+        this.responseConsumer = Args.notNull(responseConsumer, "Response consumer");
+        this.context = Args.notNull(context, "Context");
         this.callback = callback;
     }
 
@@ -62,6 +67,10 @@ public final class ExecutionCommand<T> i
         return responseConsumer;
     }
 
+    public HttpContext getContext() {
+        return context;
+    }
+
     public FutureCallback<T> getCallback() {
         return callback;
     }

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractBinAsyncEntityConsumer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/AbstractBinAsyncEntityConsumer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractBinAsyncEntityConsumer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractBinAsyncEntityConsumer.java \
Tue Sep 27 17:49:46 2016 @@ -33,6 +33,7 @@ import java.nio.charset.UnsupportedChars
 import java.util.List;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.entity.ContentType;
@@ -49,10 +50,11 @@ public abstract class AbstractBinAsyncEn
 
     @Override
     public final void streamStart(
-            final String contentType,
+            final EntityDetails entityDetails,
             final FutureCallback<T> resultCallback) throws IOException, \
HttpException {  Args.notNull(resultCallback, "Result callback");
         try {
+            final String contentType = entityDetails.getContentType();
             dataStart(contentType != null ? ContentType.parse(contentType) : null, \
resultCallback);  } catch (UnsupportedCharsetException ex) {
             throw new UnsupportedEncodingException(ex.getMessage());

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractBinAsyncEntityProducer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/AbstractBinAsyncEntityProducer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractBinAsyncEntityProducer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractBinAsyncEntityProducer.java \
Tue Sep 27 17:49:46 2016 @@ -28,6 +28,7 @@ package org.apache.hc.core5.http2.nio.en
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.util.Set;
 
 import org.apache.hc.core5.http.entity.ContentType;
 import org.apache.hc.core5.http2.nio.AsyncEntityProducer;
@@ -61,6 +62,21 @@ public abstract class AbstractBinAsyncEn
     }
 
     @Override
+    public String getContentEncoding() {
+        return null;
+    }
+
+    @Override
+    public boolean isChunked() {
+        return false;
+    }
+
+    @Override
+    public Set<String> getTrailerNames() {
+        return null;
+    }
+
+    @Override
     public final void streamStart(final DataStreamChannel channel)  throws \
IOException {  dataStart();
     }

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractCharAsyncEntityConsumer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/AbstractCharAsyncEntityConsumer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractCharAsyncEntityConsumer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractCharAsyncEntityConsumer.java \
Tue Sep 27 17:49:46 2016 @@ -38,6 +38,7 @@ import java.nio.charset.UnsupportedChars
 import java.util.List;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.entity.ContentType;
@@ -63,11 +64,11 @@ public abstract class AbstractCharAsyncE
 
     @Override
     public final void streamStart(
-            final String contentType,
+            final EntityDetails entityDetails,
             final FutureCallback<T> resultCallback) throws IOException, \
HttpException {  Args.notNull(resultCallback, "Result callback");
         try {
-            this.contentType = contentType != null ? ContentType.parse(contentType) \
: null; +            this.contentType = entityDetails != null ? \
ContentType.parse(entityDetails.getContentType()) : null;  \
dataStart(this.contentType, resultCallback);  } catch (UnsupportedCharsetException \
ex) {  throw new UnsupportedEncodingException(ex.getMessage());

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractCharAsyncEntityProducer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/AbstractCharAsyncEntityProducer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractCharAsyncEntityProducer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractCharAsyncEntityProducer.java \
Tue Sep 27 17:49:46 2016 @@ -33,6 +33,7 @@ import java.nio.charset.Charset;
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CoderResult;
 import java.nio.charset.StandardCharsets;
+import java.util.Set;
 
 import org.apache.hc.core5.http.entity.ContentType;
 import org.apache.hc.core5.http2.nio.AsyncEntityProducer;
@@ -92,6 +93,21 @@ public abstract class AbstractCharAsyncE
         return contentType != null ? contentType.toString() : null;
     }
 
+    @Override
+    public String getContentEncoding() {
+        return null;
+    }
+
+    @Override
+    public boolean isChunked() {
+        return false;
+    }
+
+    @Override
+    public Set<String> getTrailerNames() {
+        return null;
+    }
+
     private void checkResult(final CoderResult result) throws IOException {
         if (result.isError()) {
             result.throwException();

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractClassicEntityConsumer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/AbstractClassicEntityConsumer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractClassicEntityConsumer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractClassicEntityConsumer.java \
Tue Sep 27 17:49:46 2016 @@ -36,6 +36,7 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.entity.ContentType;
@@ -74,10 +75,10 @@ public abstract class AbstractClassicEnt
     }
 
     @Override
-    public final void streamStart(final String contentType, final FutureCallback<T> \
                resultCallback) throws HttpException, IOException {
-        final ContentType localContentType;
+    public final void streamStart(final EntityDetails entityDetails, final \
FutureCallback<T> resultCallback) throws HttpException, IOException { +        final \
ContentType contentType;  try {
-            localContentType = ContentType.parse(contentType);
+            contentType = ContentType.parse(entityDetails.getContentType());
         } catch (UnsupportedCharsetException ex) {
             throw new UnsupportedEncodingException(ex.getMessage());
         }
@@ -87,7 +88,7 @@ public abstract class AbstractClassicEnt
                 @Override
                 public void run() {
                     try {
-                        final T result = consumeData(localContentType, new \
ContentInputStream(buffer)); +                        final T result = \
consumeData(contentType, new ContentInputStream(buffer));  \
resultCallback.completed(result);  } catch (Exception ex) {
                         buffer.abort();

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractClassicEntityProducer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/AbstractClassicEntityProducer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractClassicEntityProducer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/AbstractClassicEntityProducer.java \
Tue Sep 27 17:49:46 2016 @@ -28,6 +28,7 @@ package org.apache.hc.core5.http2.nio.en
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.Set;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -90,11 +91,31 @@ public abstract class AbstractClassicEnt
     }
 
     @Override
+    public long getContentLength() {
+        return -1;
+    }
+
+    @Override
     public final String getContentType() {
         return contentType != null ? contentType.toString() : null;
     }
 
     @Override
+    public String getContentEncoding() {
+        return null;
+    }
+
+    @Override
+    public boolean isChunked() {
+        return false;
+    }
+
+    @Override
+    public Set<String> getTrailerNames() {
+        return null;
+    }
+
+    @Override
     public void releaseResources() {
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/ByteArrayAsyncEntityProducer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/ByteArrayAsyncEntityProducer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/ByteArrayAsyncEntityProducer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/ByteArrayAsyncEntityProducer.java \
Tue Sep 27 17:49:46 2016 @@ -40,11 +40,18 @@ import org.apache.hc.core5.util.Asserts;
 public class ByteArrayAsyncEntityProducer extends AbstractBinAsyncEntityProducer {
 
     private final ByteBuffer content;
+    private final int len;
 
     public ByteArrayAsyncEntityProducer(final byte[] content, final int bufferSize, \
final ContentType contentType) {  super(bufferSize, contentType);
         Args.notNull(content, "Byte array");
         this.content = ByteBuffer.wrap(content);
+        this.len = this.content.remaining();
+    }
+
+    @Override
+    public long getContentLength() {
+        return len;
     }
 
     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/NoopEntityConsumer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/NoopEntityConsumer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/NoopEntityConsumer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/NoopEntityConsumer.java \
Tue Sep 27 17:49:46 2016 @@ -31,6 +31,7 @@ import java.nio.ByteBuffer;
 import java.util.List;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http2.nio.AsyncEntityConsumer;
@@ -45,7 +46,7 @@ public final class NoopEntityConsumer im
 
     @Override
     public final void streamStart(
-            final String contentType,
+            final EntityDetails entityDetails,
             final FutureCallback<Void> resultCallback) throws IOException, \
HttpException {  this.resultCallback = resultCallback;
     }

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/StringAsyncEntityProducer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/nio/entity/StringAsyncEntityProducer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/StringAsyncEntityProducer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/StringAsyncEntityProducer.java \
Tue Sep 27 17:49:46 2016 @@ -49,6 +49,11 @@ public class StringAsyncEntityProducer e
     }
 
     @Override
+    public long getContentLength() {
+        return -1;
+    }
+
+    @Override
     protected void dataStart(final StreamChannel<CharBuffer> channel) throws \
IOException {  }
 

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConnControl.java \
(from r1762526, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java)
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/protocol/H2RequestConnControl.java?p2=httpcomponents/ht \
tpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestCo \
nnControl.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/ \
hc/core5/http2/nio/ResponseChannel.java&r1=1762526&r2=1762527&rev=1762527&view=diff \
                ==============================================================================
                
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConnControl.java \
Tue Sep 27 17:49:46 2016 @@ -25,28 +25,38 @@
  *
  */
 
-package org.apache.hc.core5.http2.nio;
+package org.apache.hc.core5.http2.protocol;
 
 import java.io.IOException;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.EntityDetails;
 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.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.RequestConnControl;
+import org.apache.hc.core5.util.Args;
 
 /**
- * Abstract response / response promise channel.
- * <p>
- * Implementations are expected to be thread-safe.
+ * HTTP/2 compatible extension of {@link RequestConnControl}.
  *
  * @since 5.0
  */
-@Contract(threading = ThreadingBehavior.SAFE)
-public interface ResponseChannel {
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class H2RequestConnControl extends RequestConnControl {
 
-    void sendResponse(HttpResponse response, boolean endStream) throws \
                HttpException, IOException;
-
-    void pushPromise(HttpRequest promise, AsyncPushProducer pushProducer) throws \
HttpException, IOException; +    @Override
+    public void process(
+            final HttpRequest request,
+            final EntityDetails entity,
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(context, "HTTP context");
+        final ProtocolVersion ver = context.getProtocolVersion();
+        if (ver.getMajor() < 2) {
+            super.process(request, entity, context);
+        }
+    }
 
 }

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestContent.java \
(from r1762526, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java)
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/protocol/H2RequestContent.java?p2=httpcomponents/httpco \
re/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConten \
t.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java&r1=1762526&r2=1762527&rev=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestContent.java \
Tue Sep 27 17:49:46 2016 @@ -25,28 +25,50 @@
  *
  */
 
-package org.apache.hc.core5.http2.nio;
+package org.apache.hc.core5.http2.protocol;
 
 import java.io.IOException;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.EntityDetails;
 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.message.MessageSupport;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.RequestContent;
+import org.apache.hc.core5.util.Args;
 
 /**
- * Abstract response / response promise channel.
- * <p>
- * Implementations are expected to be thread-safe.
+ * HTTP/2 compatible extension of {@link RequestContent}.
  *
  * @since 5.0
  */
-@Contract(threading = ThreadingBehavior.SAFE)
-public interface ResponseChannel {
-
-    void sendResponse(HttpResponse response, boolean endStream) throws \
                HttpException, IOException;
-
-    void pushPromise(HttpRequest promise, AsyncPushProducer pushProducer) throws \
HttpException, IOException; +@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class H2RequestContent extends RequestContent {
 
+    public H2RequestContent() {
+        super();
+    }
+
+    public H2RequestContent(final boolean overwrite) {
+        super(overwrite);
+    }
+
+    @Override
+    public void process(
+            final HttpRequest request,
+            final EntityDetails entity,
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(context, "HTTP context");
+        final ProtocolVersion ver = context.getProtocolVersion();
+        if (ver.getMajor() < 2) {
+            super.process(request, entity, context);
+        } else if (entity != null) {
+            MessageSupport.addContentTypeHeader(request, entity);
+            MessageSupport.addContentEncodingHeader(request, entity);
+            MessageSupport.addTrailerHeader(request, entity);
+        }
+    }
 }

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestTargetHost.java \
(from r1762526, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java)
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/protocol/H2RequestTargetHost.java?p2=httpcomponents/htt \
pcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestTar \
getHost.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc \
/core5/http2/nio/ResponseChannel.java&r1=1762526&r2=1762527&rev=1762527&view=diff \
                ==============================================================================
                
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestTargetHost.java \
Tue Sep 27 17:49:46 2016 @@ -25,28 +25,38 @@
  *
  */
 
-package org.apache.hc.core5.http2.nio;
+package org.apache.hc.core5.http2.protocol;
 
 import java.io.IOException;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.EntityDetails;
 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.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.RequestTargetHost;
+import org.apache.hc.core5.util.Args;
 
 /**
- * Abstract response / response promise channel.
- * <p>
- * Implementations are expected to be thread-safe.
+ * HTTP/2 compatible extension of {@link RequestTargetHost}.
  *
  * @since 5.0
  */
-@Contract(threading = ThreadingBehavior.SAFE)
-public interface ResponseChannel {
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class H2RequestTargetHost extends RequestTargetHost {
 
-    void sendResponse(HttpResponse response, boolean endStream) throws \
                HttpException, IOException;
-
-    void pushPromise(HttpRequest promise, AsyncPushProducer pushProducer) throws \
HttpException, IOException; +    @Override
+    public void process(
+            final HttpRequest request,
+            final EntityDetails entity,
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(context, "HTTP context");
+        final ProtocolVersion ver = context.getProtocolVersion();
+        if (ver.getMajor() < 2) {
+            super.process(request, entity, context);
+        }
+    }
 
 }

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestValidateHost.java \
(from r1762526, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java)
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/protocol/H2RequestValidateHost.java?p2=httpcomponents/h \
ttpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestV \
alidateHost.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apach \
e/hc/core5/http2/nio/ResponseChannel.java&r1=1762526&r2=1762527&rev=1762527&view=diff \
                ==============================================================================
                
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestValidateHost.java \
Tue Sep 27 17:49:46 2016 @@ -25,28 +25,38 @@
  *
  */
 
-package org.apache.hc.core5.http2.nio;
+package org.apache.hc.core5.http2.protocol;
 
 import java.io.IOException;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.EntityDetails;
 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.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.RequestValidateHost;
+import org.apache.hc.core5.util.Args;
 
 /**
- * Abstract response / response promise channel.
- * <p>
- * Implementations are expected to be thread-safe.
+ * HTTP/2 compatible extension of {@link RequestValidateHost}.
  *
  * @since 5.0
  */
-@Contract(threading = ThreadingBehavior.SAFE)
-public interface ResponseChannel {
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class H2RequestValidateHost extends RequestValidateHost {
 
-    void sendResponse(HttpResponse response, boolean endStream) throws \
                HttpException, IOException;
-
-    void pushPromise(HttpRequest promise, AsyncPushProducer pushProducer) throws \
HttpException, IOException; +    @Override
+    public void process(
+            final HttpRequest request,
+            final EntityDetails entity,
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(context, "HTTP context");
+        final ProtocolVersion ver = context.getProtocolVersion();
+        if (ver.getMajor() < 2) {
+            super.process(request, entity, context);
+        }
+    }
 
 }

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseConnControl.java \
(from r1762526, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java)
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/protocol/H2ResponseConnControl.java?p2=httpcomponents/h \
ttpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2Response \
ConnControl.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apach \
e/hc/core5/http2/nio/ResponseChannel.java&r1=1762526&r2=1762527&rev=1762527&view=diff \
                ==============================================================================
                
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseConnControl.java \
Tue Sep 27 17:49:46 2016 @@ -25,28 +25,37 @@
  *
  */
 
-package org.apache.hc.core5.http2.nio;
+package org.apache.hc.core5.http2.protocol;
 
 import java.io.IOException;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.EntityDetails;
 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.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.ResponseConnControl;
+import org.apache.hc.core5.util.Args;
 
 /**
- * Abstract response / response promise channel.
- * <p>
- * Implementations are expected to be thread-safe.
+ * HTTP/2 compatible extension of {@link ResponseConnControl}.
  *
  * @since 5.0
  */
-@Contract(threading = ThreadingBehavior.SAFE)
-public interface ResponseChannel {
-
-    void sendResponse(HttpResponse response, boolean endStream) throws \
                HttpException, IOException;
-
-    void pushPromise(HttpRequest promise, AsyncPushProducer pushProducer) throws \
HttpException, IOException; +@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class H2ResponseConnControl extends ResponseConnControl {
 
+    @Override
+    public void process(
+            final HttpResponse response,
+            final EntityDetails entity,
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(context, "HTTP context");
+        final ProtocolVersion ver = context.getProtocolVersion();
+        if (ver.getMajor() < 2) {
+            super.process(response, entity, context);
+        }
+    }
 }

Copied: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseContent.java \
(from r1762526, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java)
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/ \
java/org/apache/hc/core5/http2/protocol/H2ResponseContent.java?p2=httpcomponents/httpc \
ore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseCont \
ent.java&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java&r1=1762526&r2=1762527&rev=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/ResponseChannel.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2ResponseContent.java \
Tue Sep 27 17:49:46 2016 @@ -25,28 +25,51 @@
  *
  */
 
-package org.apache.hc.core5.http2.nio;
+package org.apache.hc.core5.http2.protocol;
 
 import java.io.IOException;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.http.EntityDetails;
 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.message.MessageSupport;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.ResponseContent;
+import org.apache.hc.core5.util.Args;
 
 /**
- * Abstract response / response promise channel.
- * <p>
- * Implementations are expected to be thread-safe.
+ * HTTP/2 compatible extension of {@link ResponseContent}.
  *
  * @since 5.0
  */
-@Contract(threading = ThreadingBehavior.SAFE)
-public interface ResponseChannel {
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class H2ResponseContent extends ResponseContent {
 
-    void sendResponse(HttpResponse response, boolean endStream) throws \
                HttpException, IOException;
-
-    void pushPromise(HttpRequest promise, AsyncPushProducer pushProducer) throws \
HttpException, IOException; +    public H2ResponseContent() {
+        super();
+    }
+
+    public H2ResponseContent(final boolean overwrite) {
+        super(overwrite);
+    }
+
+    @Override
+    public void process(
+            final HttpResponse response,
+            final EntityDetails entity,
+            final HttpContext context) throws HttpException, IOException {
+        Args.notNull(context, "HTTP context");
+        final ProtocolVersion ver = context.getProtocolVersion();
+        if (ver.getMajor() < 2) {
+            super.process(response, entity, context);
+        } else if (entity != null) {
+            MessageSupport.addContentTypeHeader(response, entity);
+            MessageSupport.addContentEncodingHeader(response, entity);
+            MessageSupport.addTrailerHeader(response, entity);
+        }
+    }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2IntegrationTest.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/test/ \
java/org/apache/hc/core5/http2/integration/Http2IntegrationTest.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2IntegrationTest.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2IntegrationTest.java \
Tue Sep 27 17:49:46 2016 @@ -52,6 +52,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingDeque;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHeaders;
@@ -189,6 +190,11 @@ public class Http2IntegrationTest extend
         }
 
         @Override
+        public long getContentLength() {
+            return -1;
+        }
+
+        @Override
         protected void dataStart(final StreamChannel<CharBuffer> channel) throws \
IOException {  produceData(channel);
         }
@@ -346,18 +352,10 @@ public class Http2IntegrationTest extend
         @Override
         public void handleRequest(
                 final HttpRequest request,
-                final boolean enclosedBody,
+                final EntityDetails entityDetails,
                 final ResponseChannel responseChannel) throws HttpException, \
                IOException {
             final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK);
-            final Header h1 = request.getFirstHeader(HttpHeaders.CONTENT_TYPE);
-            if (h1 != null) {
-                response.addHeader(h1);
-            }
-            final Header h2 = request.getFirstHeader(HttpHeaders.CONTENT_ENCODING);
-            if (h2 != null) {
-                response.addHeader(h2);
-            }
-            responseChannel.sendResponse(response, enclosedBody);
+            responseChannel.sendResponse(response, entityDetails);
         }
 
         @Override
@@ -848,7 +846,7 @@ public class Http2IntegrationTest extend
 
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, Void>> future = queue.remove();
-            final Message<HttpResponse, Void> result = future.get(50000, \
TimeUnit.SECONDS); +            final Message<HttpResponse, Void> result = \
future.get(5, TimeUnit.SECONDS);  Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             Assert.assertNotNull(response);

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2TestClient.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/test/ \
java/org/apache/hc/core5/http2/integration/Http2TestClient.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2TestClient.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2TestClient.java \
Tue Sep 27 17:49:46 2016 @@ -43,7 +43,11 @@ import org.apache.hc.core5.concurrent.Fu
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
 import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.RequestExpectContinue;
+import org.apache.hc.core5.http.protocol.RequestUserAgent;
 import org.apache.hc.core5.http.protocol.UriPatternMatcher;
 import org.apache.hc.core5.http2.H2ConnectionException;
 import org.apache.hc.core5.http2.H2Error;
@@ -54,6 +58,9 @@ import org.apache.hc.core5.http2.nio.Sup
 import org.apache.hc.core5.http2.nio.command.ClientCommandEndpoint;
 import org.apache.hc.core5.http2.nio.command.ShutdownCommand;
 import org.apache.hc.core5.http2.nio.command.ShutdownType;
+import org.apache.hc.core5.http2.protocol.H2RequestConnControl;
+import org.apache.hc.core5.http2.protocol.H2RequestContent;
+import org.apache.hc.core5.http2.protocol.H2RequestTargetHost;
 import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
 import org.apache.hc.core5.reactor.ExceptionEvent;
 import org.apache.hc.core5.reactor.IOReactorExceptionHandler;
@@ -159,7 +166,14 @@ public class Http2TestClient {
     }
 
     public void start(final H2Config h2Config) throws Exception {
+        final HttpProcessor httpProcessor = new DefaultHttpProcessor(
+                new H2RequestContent(),
+                new H2RequestTargetHost(),
+                new H2RequestConnControl(),
+                new RequestUserAgent("TEST-CLIENT/1.1"),
+                new RequestExpectContinue());
         this.ioReactor = new DefaultConnectingIOReactor(new \
InternalClientHttp2EventHandlerFactory( +                httpProcessor,
                 new HandlerFactory<AsyncPushConsumer>() {
 
                     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2TestServer.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/test/ \
java/org/apache/hc/core5/http2/integration/Http2TestServer.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2TestServer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/Http2TestServer.java \
Tue Sep 27 17:49:46 2016 @@ -39,8 +39,14 @@ import java.util.concurrent.TimeUnit;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpRequestInterceptor;
+import org.apache.hc.core5.http.HttpResponseInterceptor;
 import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
 import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
+import org.apache.hc.core5.http.protocol.ResponseDate;
+import org.apache.hc.core5.http.protocol.ResponseServer;
 import org.apache.hc.core5.http.protocol.UriPatternMatcher;
 import org.apache.hc.core5.http2.config.H2Config;
 import org.apache.hc.core5.http2.nio.AsyncExchangeHandler;
@@ -49,6 +55,9 @@ import org.apache.hc.core5.http2.nio.Han
 import org.apache.hc.core5.http2.nio.Supplier;
 import org.apache.hc.core5.http2.nio.command.ShutdownCommand;
 import org.apache.hc.core5.http2.nio.command.ShutdownType;
+import org.apache.hc.core5.http2.protocol.H2RequestValidateHost;
+import org.apache.hc.core5.http2.protocol.H2ResponseConnControl;
+import org.apache.hc.core5.http2.protocol.H2ResponseContent;
 import org.apache.hc.core5.reactor.DefaultListeningIOReactor;
 import org.apache.hc.core5.reactor.ExceptionEvent;
 import org.apache.hc.core5.reactor.IOReactorExceptionHandler;
@@ -106,7 +115,18 @@ public class Http2TestServer {
     }
 
     public InetSocketAddress start(final H2Config h2Config) throws Exception {
+        final HttpProcessor httpProcessor = new DefaultHttpProcessor(
+                new HttpRequestInterceptor[] {
+                        new H2RequestValidateHost()
+                },
+                new HttpResponseInterceptor[]{
+                        new ResponseDate(),
+                        new ResponseServer("TEST-SERVER/1.1"),
+                        new H2ResponseContent(),
+                        new H2ResponseConnControl()
+                });
         ioReactor = new DefaultListeningIOReactor(new \
InternalServerHttp2EventHandlerFactory( +                httpProcessor,
                 new HandlerFactory<AsyncExchangeHandler>() {
 
                     @Override

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/InternalClientHttp2EventHandlerFactory.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/test/ \
java/org/apache/hc/core5/http2/integration/InternalClientHttp2EventHandlerFactory.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/InternalClientHttp2EventHandlerFactory.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/InternalClientHttp2EventHandlerFactory.java \
Tue Sep 27 17:49:46 2016 @@ -32,6 +32,7 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
 import org.apache.hc.core5.http2.config.H2Config;
 import org.apache.hc.core5.http2.impl.nio.ClientHttp2StreamMultiplexer;
 import org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiator;
@@ -41,19 +42,23 @@ import org.apache.hc.core5.http2.nio.Han
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.util.Args;
 
 public class InternalClientHttp2EventHandlerFactory implements IOEventHandlerFactory \
{  
     private static final AtomicLong COUNT = new AtomicLong();
 
+    private final HttpProcessor httpProcessor;
     private final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory;
     private final Charset charset;
     private final H2Config h2Config;
 
     public InternalClientHttp2EventHandlerFactory(
+            final HttpProcessor httpProcessor,
             final HandlerFactory<AsyncPushConsumer> exchangeHandlerFactory,
             final Charset charset,
             final H2Config h2Config) {
+        this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
         this.exchangeHandlerFactory = exchangeHandlerFactory;
         this.charset = charset;
         this.h2Config = h2Config;
@@ -65,7 +70,7 @@ public class InternalClientHttp2EventHan
         final Log sessionLog = LogFactory.getLog(ioSession.getClass());
         final InternalHttp2StreamListener streamListener = new \
                InternalHttp2StreamListener(id);
         final HttpErrorListener errorListener = new \
                InternalHttpErrorListener(sessionLog);
-        return new ClientHttpProtocolNegotiator(exchangeHandlerFactory, charset, \
h2Config, streamListener, errorListener) { +        return new \
ClientHttpProtocolNegotiator(httpProcessor, exchangeHandlerFactory, charset, \
h2Config, streamListener, errorListener) {  
             @Override
             protected ClientHttp2StreamMultiplexer createStreamMultiplexer(final \
IOSession ioSession) {

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/InternalServerHttp2EventHandlerFactory.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/test/ \
java/org/apache/hc/core5/http2/integration/InternalServerHttp2EventHandlerFactory.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/InternalServerHttp2EventHandlerFactory.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/integration/InternalServerHttp2EventHandlerFactory.java \
Tue Sep 27 17:49:46 2016 @@ -32,6 +32,7 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hc.core5.http.protocol.HttpProcessor;
 import org.apache.hc.core5.http2.config.H2Config;
 import org.apache.hc.core5.http2.impl.nio.HttpErrorListener;
 import org.apache.hc.core5.http2.impl.nio.ServerHttp2StreamMultiplexer;
@@ -41,20 +42,24 @@ import org.apache.hc.core5.http2.nio.Han
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOEventHandlerFactory;
 import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.util.Args;
 
 public class InternalServerHttp2EventHandlerFactory implements IOEventHandlerFactory \
{  
     private static final AtomicLong COUNT = new AtomicLong();
 
+    private final HttpProcessor httpProcessor;
     private final HandlerFactory<AsyncExchangeHandler> exchangeHandlerFactory;
     private final Charset charset;
     private final H2Config h2Config;
 
     public InternalServerHttp2EventHandlerFactory(
+            final HttpProcessor httpProcessor,
             final HandlerFactory<AsyncExchangeHandler> exchangeHandlerFactory,
             final Charset charset,
             final H2Config h2Config) {
-        this.exchangeHandlerFactory = exchangeHandlerFactory;
+        this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
+        this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange \
handler factory");  this.charset = charset;
         this.h2Config = h2Config;
     }
@@ -65,7 +70,7 @@ public class InternalServerHttp2EventHan
         final Log sessionLog = LogFactory.getLog(ioSession.getClass());
         final InternalHttp2StreamListener streamListener = new \
                InternalHttp2StreamListener(id);
         final HttpErrorListener errorListener = new \
                InternalHttpErrorListener(sessionLog);
-        return new ServerHttpProtocolNegotiator(exchangeHandlerFactory, charset, \
h2Config, streamListener, errorListener) { +        return new \
ServerHttpProtocolNegotiator(httpProcessor, exchangeHandlerFactory, charset, \
h2Config, streamListener, errorListener) {  
             @Override
             protected ServerHttp2StreamMultiplexer createStreamMultiplexer(final \
IOSession ioSession) {

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/annotation/ThreadingBehavior.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/annotation/ThreadingBehavior.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/annotation/ThreadingBehavior.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/annotation/ThreadingBehavior.java \
Tue Sep 27 17:49:46 2016 @@ -45,6 +45,12 @@ public enum ThreadingBehavior {
     IMMUTABLE_CONDITIONAL,
 
     /**
+     * Instances of classes with the given contract are expected to maintain no \
state +     * and to be thread-safe.
+     */
+    STATELESS,
+
+    /**
      * Instances of classes with the given contract are expected to be fully \
                thread-safe.
      */
     SAFE,

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/ConnectionReuseStrategy.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/ConnectionReuseStrategy.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/ConnectionReuseStrategy.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/ConnectionReuseStrategy.java \
Tue Sep 27 17:49:46 2016 @@ -27,6 +27,8 @@
 
 package org.apache.hc.core5.http;
 
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.protocol.HttpContext;
 
 /**
@@ -39,6 +41,7 @@ import org.apache.hc.core5.http.protocol
  *
  * @since 4.0
  */
+@Contract(threading = ThreadingBehavior.STATELESS)
 public interface ConnectionReuseStrategy {
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/ContentLengthStrategy.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/ContentLengthStrategy.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/ContentLengthStrategy.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/ContentLengthStrategy.java \
Tue Sep 27 17:49:46 2016 @@ -27,12 +27,16 @@
 
 package org.apache.hc.core5.http;
 
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+
 /**
  * Represents a strategy to determine length of the enclosed content entity
  * based on properties of the HTTP message.
  *
  * @since 4.0
  */
+@Contract(threading = ThreadingBehavior.STATELESS)
 public interface ContentLengthStrategy {
 
     /**

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/jav \
a/org/apache/hc/core5/http/HttpConnection.java?rev=1762527&r1=1762526&r2=1762527&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 Sep 27 17:49:46 2016 @@ -39,6 +39,13 @@ import java.net.SocketAddress;
 public interface HttpConnection extends Closeable {
 
     /**
+     * Returns a collection of connection metrics.
+     *
+     * @return HttpConnectionMetrics
+     */
+    HttpConnectionMetrics getMetrics();
+
+    /**
      * Closes this connection gracefully.
      * This method will attempt to flush the internal output
      * buffer prior to closing the underlying socket.
@@ -87,13 +94,6 @@ public interface HttpConnection extends
     ProtocolVersion getProtocolVersion();
 
     /**
-     * Returns a collection of connection metrics.
-     *
-     * @return HttpConnectionMetrics
-     */
-    HttpConnectionMetrics getMetrics();
-
-    /**
      * @since 5.0
      */
     SocketAddress getRemoteAddress();

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnectionMetrics.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/HttpConnectionMetrics.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnectionMetrics.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnectionMetrics.java \
Tue Sep 27 17:49:46 2016 @@ -58,20 +58,4 @@ public interface HttpConnectionMetrics {
      */
     long getReceivedBytesCount();
 
-    /**
-     * Return the value for the specified metric.
-     *
-     *@param metricName the name of the metric to query.
-     *
-     *@return the object representing the metric requested,
-     *        {@code null} if the metric cannot not found.
-     */
-    Object getMetric(String metricName);
-
-    /**
-     * Resets the counts
-     *
-     */
-    void reset();
-
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequestInterceptor.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/HttpRequestInterceptor.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequestInterceptor.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpRequestInterceptor.java \
Tue Sep 27 17:49:46 2016 @@ -29,6 +29,8 @@ package org.apache.hc.core5.http;
 
 import java.io.IOException;
 
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.protocol.HttpContext;
 
 /**
@@ -48,6 +50,7 @@ import org.apache.hc.core5.http.protocol
  *
  * @since 4.0
  */
+@Contract(threading = ThreadingBehavior.STATELESS)
 public interface HttpRequestInterceptor {
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponseInterceptor.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/HttpResponseInterceptor.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponseInterceptor.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/HttpResponseInterceptor.java \
Tue Sep 27 17:49:46 2016 @@ -29,6 +29,8 @@ package org.apache.hc.core5.http;
 
 import java.io.IOException;
 
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.protocol.HttpContext;
 
 /**
@@ -48,6 +50,7 @@ import org.apache.hc.core5.http.protocol
  *
  * @since 4.0
  */
+@Contract(threading = ThreadingBehavior.STATELESS)
 public interface HttpResponseInterceptor {
 
     /**

Added: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpConnectionMetrics.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/impl/BasicHttpConnectionMetrics.java?rev=1762527&view=auto \
                ==============================================================================
                
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpConnectionMetrics.java \
                (added)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpConnectionMetrics.java \
Tue Sep 27 17:49:46 2016 @@ -0,0 +1,91 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http.impl;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.hc.core5.http.HttpConnectionMetrics;
+import org.apache.hc.core5.http.io.HttpTransportMetrics;
+
+/**
+ * Default implementation of the {@link HttpConnectionMetrics} interface.
+ *
+ * @since 4.0
+ */
+public class BasicHttpConnectionMetrics implements HttpConnectionMetrics {
+
+    private final HttpTransportMetrics inTransportMetric;
+    private final HttpTransportMetrics outTransportMetric;
+    private final AtomicLong requestCount;
+    private final AtomicLong responseCount;
+
+    public BasicHttpConnectionMetrics(
+            final HttpTransportMetrics inTransportMetric,
+            final HttpTransportMetrics outTransportMetric) {
+        super();
+        this.inTransportMetric = inTransportMetric;
+        this.outTransportMetric = outTransportMetric;
+        this.requestCount = new AtomicLong(0);
+        this.responseCount = new AtomicLong(0);
+    }
+
+    @Override
+    public long getReceivedBytesCount() {
+        if (this.inTransportMetric != null) {
+            return this.inTransportMetric.getBytesTransferred();
+        }
+        return -1;
+    }
+
+    @Override
+    public long getSentBytesCount() {
+        if (this.outTransportMetric != null) {
+            return this.outTransportMetric.getBytesTransferred();
+        }
+        return -1;
+    }
+
+    @Override
+    public long getRequestCount() {
+        return this.requestCount.get();
+    }
+
+    public void incrementRequestCount() {
+        this.requestCount.incrementAndGet();
+    }
+
+    @Override
+    public long getResponseCount() {
+        return this.responseCount.get();
+    }
+
+    public void incrementResponseCount() {
+        this.responseCount.incrementAndGet();
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpConnectionMetrics.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpConnectionMetrics.java
                
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpConnectionMetrics.java
                
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpTransportMetrics.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/impl/BasicHttpTransportMetrics.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpTransportMetrics.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/BasicHttpTransportMetrics.java \
Tue Sep 27 17:49:46 2016 @@ -27,6 +27,8 @@
 
 package org.apache.hc.core5.http.impl;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.apache.hc.core5.http.io.HttpTransportMetrics;
 
 /**
@@ -36,24 +38,19 @@ import org.apache.hc.core5.http.io.HttpT
  */
 public class BasicHttpTransportMetrics implements HttpTransportMetrics {
 
-    private long bytesTransferred = 0;
+    private final AtomicLong bytesTransferred;
 
     public BasicHttpTransportMetrics() {
-        super();
+        this.bytesTransferred = new AtomicLong(0);
     }
 
     @Override
     public long getBytesTransferred() {
-        return this.bytesTransferred;
+        return this.bytesTransferred.get();
     }
 
     public void incrementBytesTransferred(final long count) {
-        this.bytesTransferred += count;
-    }
-
-    @Override
-    public void reset() {
-        this.bytesTransferred = 0;
+        this.bytesTransferred.addAndGet(count);
     }
 
 }

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/jav \
a/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java?rev=1762527&r1=1762526&r2=1762527&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 Sep 27 17:49:46 2016 @@ -48,7 +48,7 @@ import org.apache.hc.core5.http.Protocol
 import org.apache.hc.core5.http.TrailerSupplier;
 import org.apache.hc.core5.http.config.MessageConstraints;
 import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
-import org.apache.hc.core5.http.impl.HttpConnectionMetricsImpl;
+import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
 import org.apache.hc.core5.http.impl.IncomingHttpEntity;
 import org.apache.hc.core5.http.io.BHttpConnection;
 import org.apache.hc.core5.http.io.SessionInputBuffer;
@@ -61,7 +61,7 @@ class BHttpConnectionBase implements BHt
     final SessionInputBufferImpl inbuffer;
     final SessionOutputBufferImpl outbuffer;
     final MessageConstraints messageConstraints;
-    final HttpConnectionMetricsImpl connMetrics;
+    final BasicHttpConnectionMetrics connMetrics;
     final AtomicReference<SocketHolder> socketHolderRef;
 
     volatile ProtocolVersion version;
@@ -81,7 +81,7 @@ class BHttpConnectionBase implements BHt
         this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, \
buffersize, fragmentSizeHint,  charencoder);
         this.messageConstraints = messageConstraints;
-        this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, \
outTransportMetrics); +        this.connMetrics = new \
BasicHttpConnectionMetrics(inTransportMetrics, outTransportMetrics);  \
this.socketHolderRef = new AtomicReference<>();  }
 

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/NHttpConnectionBase.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/impl/nio/NHttpConnectionBase.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/NHttpConnectionBase.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/NHttpConnectionBase.java \
Tue Sep 27 17:49:46 2016 @@ -47,7 +47,7 @@ import org.apache.hc.core5.http.Protocol
 import org.apache.hc.core5.http.TrailerSupplier;
 import org.apache.hc.core5.http.config.MessageConstraints;
 import org.apache.hc.core5.http.impl.BasicHttpTransportMetrics;
-import org.apache.hc.core5.http.impl.HttpConnectionMetricsImpl;
+import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
 import org.apache.hc.core5.http.impl.IncomingHttpEntity;
 import org.apache.hc.core5.http.nio.ContentDecoder;
 import org.apache.hc.core5.http.nio.ContentEncoder;
@@ -72,7 +72,7 @@ class NHttpConnectionBase implements NHt
 
     final BasicHttpTransportMetrics inTransportMetrics;
     final BasicHttpTransportMetrics outTransportMetrics;
-    final HttpConnectionMetricsImpl connMetrics;
+    final BasicHttpConnectionMetrics connMetrics;
 
     volatile HttpContext context;
     volatile IOSession session;
@@ -105,7 +105,7 @@ class NHttpConnectionBase implements NHt
         this.fragmentSizeHint = fragmentSizeHint >= 0 ? fragmentSizeHint : \
buffersize;  this.inTransportMetrics = new BasicHttpTransportMetrics();
         this.outTransportMetrics = new BasicHttpTransportMetrics();
-        this.connMetrics = new HttpConnectionMetricsImpl(this.inTransportMetrics, \
this.outTransportMetrics); +        this.connMetrics = new \
                BasicHttpConnectionMetrics(this.inTransportMetrics, \
                this.outTransportMetrics);
         this.constraints = constraints != null ? constraints : \
MessageConstraints.DEFAULT;  
         setSession(session);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/HttpTransportMetrics.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/io/HttpTransportMetrics.java?rev=1762527&r1=1762526&r2=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/HttpTransportMetrics.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/io/HttpTransportMetrics.java \
Tue Sep 27 17:49:46 2016 @@ -28,8 +28,7 @@
 package org.apache.hc.core5.http.io;
 
 /**
- * The point of access to the statistics of {@link SessionInputBuffer} or
- * {@link SessionOutputBuffer}.
+ * Transport level metrics.
  *
  * @since 4.0
  */
@@ -40,9 +39,4 @@ public interface HttpTransportMetrics {
      */
     long getBytesTransferred();
 
-    /**
-     * Resets the counts
-     */
-    void reset();
-
 }

Added: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/AbstractMessageWrapper.java
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/message/AbstractMessageWrapper.java?rev=1762527&view=auto \
                ==============================================================================
                
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/AbstractMessageWrapper.java \
                (added)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/AbstractMessageWrapper.java \
Tue Sep 27 17:49:46 2016 @@ -0,0 +1,144 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.http.message;
+
+import java.util.Iterator;
+
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpMessage;
+import org.apache.hc.core5.http.ProtocolException;
+import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.util.Args;
+
+/**
+ * Abstract {@link HttpMessage} wrapper.
+ */
+public abstract class AbstractMessageWrapper implements HttpMessage {
+
+    private final HttpMessage message;
+
+    public AbstractMessageWrapper(final HttpMessage message) {
+        this.message = Args.notNull(message, "Message");
+    }
+
+    @Override
+    public void setVersion(final ProtocolVersion version) {
+        message.setVersion(version);
+    }
+
+    @Override
+    public ProtocolVersion getVersion() {
+        return message.getVersion();
+    }
+
+    @Override
+    public void addHeader(final Header header) {
+        message.addHeader(header);
+    }
+
+    @Override
+    public void addHeader(final String name, final Object value) {
+        message.addHeader(name, value);
+    }
+
+    @Override
+    public void setHeader(final Header header) {
+        message.setHeader(header);
+    }
+
+    @Override
+    public void setHeader(final String name, final Object value) {
+        message.setHeader(name, value);
+    }
+
+    @Override
+    public void setHeaders(final Header... headers) {
+        message.setHeaders(headers);
+    }
+
+    @Override
+    public void removeHeader(final Header header) {
+        message.removeHeader(header);
+    }
+
+    @Override
+    public void removeHeaders(final String name) {
+        message.removeHeaders(name);
+    }
+
+    @Override
+    public boolean containsHeader(final String name) {
+        return message.containsHeader(name);
+    }
+
+    @Override
+    public int containsHeaders(final String name) {
+        return message.containsHeaders(name);
+    }
+
+    @Override
+    public Header[] getHeaders(final String name) {
+        return message.getHeaders(name);
+    }
+
+    @Override
+    public Header getSingleHeader(final String name) throws ProtocolException {
+        return message.getSingleHeader(name);
+    }
+
+    @Override
+    public Header getFirstHeader(final String name) {
+        return message.getFirstHeader(name);
+    }
+
+    @Override
+    public Header getLastHeader(final String name) {
+        return message.getLastHeader(name);
+    }
+
+    @Override
+    public Header[] getAllHeaders() {
+        return message.getAllHeaders();
+    }
+
+    @Override
+    public Iterator<Header> headerIterator() {
+        return message.headerIterator();
+    }
+
+    @Override
+    public Iterator<Header> headerIterator(final String name) {
+        return message.headerIterator(name);
+    }
+
+    @Override
+    public String toString() {
+        return message.toString();
+    }
+
+}

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/AbstractMessageWrapper.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/AbstractMessageWrapper.java
                
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/AbstractMessageWrapper.java
                
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/HttpRequestWrapper.java \
(from r1762526, httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/ByteArrayAsyncEntityProducer.java)
                
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/jav \
a/org/apache/hc/core5/http/message/HttpRequestWrapper.java?p2=httpcomponents/httpcore/ \
trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/HttpRequestWrapper.java \
&p1=httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2 \
/nio/entity/ByteArrayAsyncEntityProducer.java&r1=1762526&r2=1762527&rev=1762527&view=diff
 ==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/entity/ByteArrayAsyncEntityProducer.java \
                (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/message/HttpRequestWrapper.java \
Tue Sep 27 17:49:46 2016 @@ -24,49 +24,64 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.hc.core5.http2.nio.entity;
 
-import java.io.IOException;
-import java.nio.ByteBuffer;
+package org.apache.hc.core5.http.message;
 
-import org.apache.hc.core5.http.entity.ContentType;
-import org.apache.hc.core5.http2.nio.StreamChannel;
-import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Asserts;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.hc.core5.http.HttpRequest;
 
 /**
- * @since 5.0
+ * {@link HttpRequest} wrapper.
  */
-public class ByteArrayAsyncEntityProducer extends AbstractBinAsyncEntityProducer {
+public class HttpRequestWrapper extends AbstractMessageWrapper implements \
HttpRequest { +
+    private final HttpRequest message;
 
-    private final ByteBuffer content;
+    public HttpRequestWrapper(final HttpRequest message) {
+        super(message);
+        this.message = message;
+    }
 
-    public ByteArrayAsyncEntityProducer(final byte[] content, final int bufferSize, \
                final ContentType contentType) {
-        super(bufferSize, contentType);
-        Args.notNull(content, "Byte array");
-        this.content = ByteBuffer.wrap(content);
+    @Override
+    public String getMethod() {
+        return message.getMethod();
+    }
+
+    @Override
+    public String getPath() {
+        return message.getPath();
+    }
+
+    @Override
+    public void setPath(final String path) {
+        message.setPath(path);
+    }
+
+    @Override
+    public String getScheme() {
+        return message.getScheme();
     }
 
     @Override
-    protected void dataStart() throws IOException {
+    public void setScheme(final String scheme) {
+        message.setScheme(scheme);
     }
 
     @Override
-    public int available() {
-        return Integer.MAX_VALUE;
+    public String getAuthority() {
+        return message.getAuthority();
     }
 
     @Override
-    protected void produceData(final StreamChannel<ByteBuffer> channel) throws \
                IOException {
-        Asserts.notNull(channel, "StreamChannel");
-        channel.write(content);
-        if (!content.hasRemaining()) {
-            channel.endStream();
-        }
+    public void setAuthority(final String authority) {
+        message.setAuthority(authority);
     }
 
     @Override
-    public void releaseResources() {
+    public URI getUri() throws URISyntaxException {
+        return message.getUri();
     }
 
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic