camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/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.
Date Sun, 26 Jul 2015 15:43:23 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 2bbedff8d -> 25ab4d49d


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/DefaultHttpBinding.java
	components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
	components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java


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

Branch: refs/heads/camel-2.15.x
Commit: 3d74d4fd58f11dcc3272044dd83ed5d0e2ba986c
Parents: 2bbedff
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Jul 17 12:52:27 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Jul 26 17:41:18 2015 +0200

----------------------------------------------------------------------
 .../camel/component/http/DefaultHttpBinding.java    | 11 ++++++++++-
 .../apache/camel/component/http/HttpBinding.java    | 12 ++++++++++++
 .../apache/camel/component/http/HttpEndpoint.java   | 16 ++++++++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3d74d4fd/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
index 7a0beb7..f080021 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/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;
 
@@ -448,7 +449,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
@@ -468,6 +469,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/3d74d4fd/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 a045aee..3f2c069 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,6 +98,18 @@ 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.
+     */
+    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.
+     */
+    void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable);
+
+    /**
      * Should reader by used instead of input stream.
      *
      * @see #setUseReaderForPayload(boolean) for more details

http://git-wip-us.apache.org/repos/asf/camel/blob/3d74d4fd/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 8bf65e5..8c5bee4 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
@@ -83,6 +83,8 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
     private UrlRewrite urlRewrite;
     @UriParam
     private Integer responseBufferSize;
+    @UriParam
+    private boolean eagerCheckContentAvailable;
 
     public HttpEndpoint() {
     }
@@ -228,6 +230,8 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
     public HttpBinding getBinding() {
         if (binding == null) {
             binding = new DefaultHttpBinding(this);
+            // create a new binding and use the options from this endpoint
+            binding.setEagerCheckContentAvailable(isEagerCheckContentAvailable());
         }
         return binding;
     }
@@ -386,4 +390,16 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
     public void setResponseBufferSize(Integer responseBufferSize) {
         this.responseBufferSize = responseBufferSize;
     }
+
+    public boolean isEagerCheckContentAvailable() {
+        return eagerCheckContentAvailable;
+    }
+
+    /**
+     * 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.
+     */
+    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
+        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
+    }
 }


Mime
View raw message