You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/07/26 17:43:24 UTC

[2/3] camel git commit: CAMEL-8643: Do not eager check for content available using the input stream available in case http client is in streaming mode and is slow at sending data.

CAMEL-8643: Do not eager check for content available using the input stream available in case http client is in streaming mode and is slow at sending data.

Conflicts:
	components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
	components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
	components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java
	components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2efa6a04
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2efa6a04
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2efa6a04

Branch: refs/heads/camel-2.15.x
Commit: 2efa6a043a371666af80b6a3ad819395043ab801
Parents: 3d74d4f
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jul 17 12:57:55 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jul 26 17:44:31 2015 +0200

----------------------------------------------------------------------
 .../camel/component/http/HttpBinding.java       |  8 ++++----
 .../camel/component/http/HttpEndpoint.java      |  4 ++--
 .../component/http4/DefaultHttpBinding.java     | 11 +++++++++-
 .../camel/component/http4/HttpBinding.java      | 12 +++++++++++
 .../camel/component/http4/HttpEndpoint.java     | 21 ++++++++++++++++++--
 5 files changed, 47 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2efa6a04/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
index 3f2c069..35f1f4a 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
@@ -98,14 +98,14 @@ public interface HttpBinding {
     void doWriteResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException;
 
     /**
-     * Whether to eager check whether the HTTP requests has content.
-     * This can be used to turn off in case HTTP clients send streamed data and the available check must be delayed.
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
      */
     boolean isEagerCheckContentAvailable();
 
     /**
-     * Whether to eager check whether the HTTP requests has content.
-     * This can be used to turn off in case HTTP clients send streamed data and the available check must be delayed.
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
      */
     void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/2efa6a04/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
index 8c5bee4..97f01ee 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
@@ -396,8 +396,8 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
     }
 
     /**
-     * Whether to eager check whether the HTTP requests has content.
-     * This can be used to turn off in case HTTP clients send streamed data and the available check must be delayed.
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
      */
     public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
         this.eagerCheckContentAvailable = eagerCheckContentAvailable;

http://git-wip-us.apache.org/repos/asf/camel/blob/2efa6a04/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
index ed03770..ce1fca1 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
@@ -58,6 +58,7 @@ public class DefaultHttpBinding implements HttpBinding {
 
     private static final Logger LOG = LoggerFactory.getLogger(DefaultHttpBinding.class);
     private boolean useReaderForPayload;
+    private boolean eagerCheckContentAvailable;
     private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
     private HttpEndpoint endpoint;
 
@@ -411,7 +412,7 @@ public class DefaultHttpBinding implements HttpBinding {
             return request.getReader();
         } else {
             // if we do not know if there is any data at all, then make sure to check the stream first
-            if (len < 0) {
+            if (len < 0 && isEagerCheckContentAvailable()) {
                 InputStream is = request.getInputStream();
                 if (is.available() == 0) {
                     // no data so return null
@@ -431,6 +432,14 @@ public class DefaultHttpBinding implements HttpBinding {
         this.useReaderForPayload = useReaderForPayload;
     }
 
+    public boolean isEagerCheckContentAvailable() {
+        return eagerCheckContentAvailable;
+    }
+
+    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
+        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
+    }
+
     public HeaderFilterStrategy getHeaderFilterStrategy() {
         return headerFilterStrategy;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/2efa6a04/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java
index 339f13b..8f7b92f 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java
@@ -116,6 +116,18 @@ public interface HttpBinding {
     void setUseReaderForPayload(boolean useReaderForPayload);
 
     /**
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
+     */
+    boolean isEagerCheckContentAvailable();
+
+    /**
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
+     */
+    void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable);
+
+    /**
      * Gets the header filter strategy
      *
      * @return the strategy

http://git-wip-us.apache.org/repos/asf/camel/blob/2efa6a04/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
index 4229c1c..4a927e1 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
@@ -84,7 +84,9 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
     @UriParam(defaultValue = "true")
     private boolean clearExpiredCookies = true;
     private CookieStore cookieStore = new BasicCookieStore();
-    
+    @UriParam
+    private boolean eagerCheckContentAvailable;
+
     public HttpEndpoint() {
     }
 
@@ -250,9 +252,11 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         this.httpClientConfigurer = httpClientConfigurer;
     }
 
-    public HttpBinding getBinding() {
+    public HttpBinding getHttpBinding() {
         if (binding == null) {
+            // create a new binding and use the options from this endpoint
             binding = new DefaultHttpBinding(this);
+            binding.setEagerCheckContentAvailable(isEagerCheckContentAvailable());
         }
         return binding;
     }
@@ -412,4 +416,17 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
     public void setAuthenticationPreemptive(boolean authenticationPreemptive) {
         this.authenticationPreemptive = authenticationPreemptive;
     }
+
+    public boolean isEagerCheckContentAvailable() {
+        return eagerCheckContentAvailable;
+    }
+
+    /**
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
+     */
+    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
+        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
+    }
+
 }