You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/05/09 20:01:35 UTC

[09/50] httpcomponents-core git commit: HTTPCORE-438: added protected #getContentType method to AbstractAsyncResponseConsumer for customization of Content-Type parsing / inference logic

HTTPCORE-438: added protected #getContentType method to AbstractAsyncResponseConsumer for customization of Content-Type parsing / inference logic

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1772539 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/d48412ec
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/d48412ec
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/d48412ec

Branch: refs/heads/4.4.x
Commit: d48412ec26e9b888d993bf12eedefba9c11301cb
Parents: d550a5e
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Dec 4 14:31:10 2016 +0000
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Dec 4 14:31:10 2016 +0000

----------------------------------------------------------------------
 .../http/nio/protocol/AbstractAsyncResponseConsumer.java  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d48412ec/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
index 860fa6b..0459fd2 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
@@ -119,6 +119,13 @@ public abstract class AbstractAsyncResponseConsumer<T> implements HttpAsyncRespo
     }
 
     /**
+     * @since 4.4
+     */
+    protected ContentType getContentType(final HttpEntity entity) {
+        return entity != null ? ContentType.getOrDefault(entity) : null;
+    }
+
+    /**
      * Use {@link #onResponseReceived(HttpResponse)} instead.
      */
     @Override
@@ -127,8 +134,7 @@ public abstract class AbstractAsyncResponseConsumer<T> implements HttpAsyncRespo
         onResponseReceived(response);
         final HttpEntity entity = response.getEntity();
         if (entity != null) {
-            final ContentType contentType = ContentType.getOrDefault(entity);
-            onEntityEnclosed(entity, contentType);
+            onEntityEnclosed(entity, getContentType(entity));
         }
     }