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 2020/01/23 05:26:10 UTC

[camel] branch master updated: CAMEL-14424: HTTP responses over 4 MB fail (#3505)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new de7717a  CAMEL-14424: HTTP responses over 4 MB fail (#3505)
de7717a is described below

commit de7717a5e6355fffb8dc4d2d59d9cd72f72c9283
Author: Jeremy Ross <je...@jeremyross.org>
AuthorDate: Wed Jan 22 23:25:59 2020 -0600

    CAMEL-14424: HTTP responses over 4 MB fail (#3505)
    
    This commit allows the user to overwrite the default http client max content length of 4 MB.
---
 .../src/main/docs/salesforce-component.adoc             |  3 ++-
 .../camel/component/salesforce/SalesforceComponent.java | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc b/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc
index 428ef2d..56def60 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/docs/salesforce-component.adoc
@@ -651,7 +651,7 @@ for details on how to generate the DTO.
 
 
 // component options: START
-The Salesforce component supports 33 options, which are listed below.
+The Salesforce component supports 34 options, which are listed below.
 
 
 
@@ -676,6 +676,7 @@ The Salesforce component supports 33 options, which are listed below.
 | *useGlobalSslContextParameters* (security) | Enable usage of global SSL context parameters | false | boolean
 | *httpClientIdleTimeout* (common) | Timeout used by the HttpClient when waiting for response from the Salesforce server. | 10000 | long
 | *httpClientConnectionTimeout* (common) | Connection timeout used by the HttpClient when connecting to the Salesforce server. | 60000 | long
+| *httpMaxContentLength* (common) | Max content length of an HTTP response. |  | Integer
 | *httpProxyHost* (proxy) | Hostname of the HTTP proxy server to use. |  | String
 | *httpProxyPort* (proxy) | Port number of the HTTP proxy server to use. |  | Integer
 | *httpProxyUsername* (security) | Username to use to authenticate against the HTTP proxy server. |  | String
diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
index 0a79091..9f82a40 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java
@@ -82,6 +82,7 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
     public static final String HTTP_PROXY_REALM = "httpProxyRealm";
     public static final String HTTP_CONNECTION_TIMEOUT = "httpConnectionTimeout";
     public static final String HTTP_IDLE_TIMEOUT = "httpIdleTimeout";
+    public static final String HTTP_MAX_CONTENT_LENGTH = "httpMaxContentLength";
 
     static final int CONNECTION_TIMEOUT = 60000;
     static final int IDLE_TIMEOUT = 10000;
@@ -151,6 +152,9 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
     @Metadata(description = "Connection timeout used by the HttpClient when connecting to the Salesforce server.", label = "common", defaultValue = "" + CONNECTION_TIMEOUT)
     private long httpClientConnectionTimeout = CONNECTION_TIMEOUT;
 
+    @Metadata(description = "Max content length of an HTTP response.", label = "common")
+    private Integer httpMaxContentLength;
+
     @Metadata(description = "Used to set any properties that can be configured on the underlying HTTP client. Have a"
                             + " look at properties of SalesforceHttpClient and the Jetty HttpClient for all available options.", label = "common,advanced")
     private Map<String, Object> httpClientProperties;
@@ -550,6 +554,14 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
         this.httpClientConnectionTimeout = httpClientConnectionTimeout;
     }
 
+    public Integer getHttpMaxContentLength() {
+        return httpMaxContentLength;
+    }
+
+    public void setHttpMaxContentLength(Integer httpMaxContentLength) {
+        this.httpMaxContentLength = httpMaxContentLength;
+    }
+
     public String getHttpProxyHost() {
         return httpProxyHost;
     }
@@ -734,6 +746,7 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
 
         final Long httpConnectionTimeout = typeConverter.convertTo(Long.class, httpClientProperties.get(HTTP_CONNECTION_TIMEOUT));
         final Long httpIdleTimeout = typeConverter.convertTo(Long.class, httpClientProperties.get(HTTP_IDLE_TIMEOUT));
+        final Integer maxContentLength = typeConverter.convertTo(Integer.class, httpClientProperties.get(HTTP_MAX_CONTENT_LENGTH));
 
         final String httpProxyHost = typeConverter.convertTo(String.class, httpClientProperties.get(HTTP_PROXY_HOST));
         final Integer httpProxyPort = typeConverter.convertTo(Integer.class, httpClientProperties.get(HTTP_PROXY_PORT));
@@ -756,6 +769,9 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
         if (httpConnectionTimeout != null) {
             httpClient.setConnectTimeout(httpConnectionTimeout);
         }
+        if (maxContentLength != null) {
+            httpClient.setMaxContentLength(maxContentLength);
+        }
 
         // set HTTP proxy settings
         if (httpProxyHost != null && httpProxyPort != null) {
@@ -802,6 +818,7 @@ public class SalesforceComponent extends DefaultComponent implements SSLContextP
         putValueIfGivenTo(httpClientProperties, HTTP_PROXY_PASSWORD, salesforce::getHttpProxyPassword);
         putValueIfGivenTo(httpClientProperties, HTTP_PROXY_REALM, salesforce::getHttpProxyRealm);
         putValueIfGivenTo(httpClientProperties, HTTP_PROXY_AUTH_URI, salesforce::getHttpProxyAuthUri);
+        putValueIfGivenTo(httpClientProperties, HTTP_MAX_CONTENT_LENGTH, salesforce::getHttpMaxContentLength);
 
         if (ObjectHelper.isNotEmpty(salesforce.getHttpProxyHost())) {
             // let's not put `false` values in client properties if no proxy is