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 2017/02/24 09:15:27 UTC

camel git commit: CAMEL-10878: camel-http / camel-http4 - Allow to specify HTTP operation as uri parameter

Repository: camel
Updated Branches:
  refs/heads/master a35caf738 -> 5067c5b89


CAMEL-10878: camel-http / camel-http4 - Allow to specify HTTP operation as uri parameter


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

Branch: refs/heads/master
Commit: 5067c5b892c669ff5aaff98054f83f43e87d831b
Parents: a35caf7
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Feb 24 10:12:46 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Feb 24 10:13:39 2017 +0100

----------------------------------------------------------------------
 .../camel/http/common/HttpCommonEndpoint.java   | 30 +++++++++++---------
 .../apache/camel/http/common/HttpHelper.java    |  7 +++--
 .../src/main/docs/http-component.adoc           | 28 +++++++++---------
 .../src/main/docs/http4-component.adoc          | 28 +++++++++---------
 .../http4/helper/HttpMethodHelper.java          |  6 ++--
 5 files changed, 52 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
index 69763b7..d7094c7 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
@@ -35,9 +35,9 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
 
     @UriPath(label = "producer", description = "The url of the HTTP endpoint to call.") @Metadata(required = "true")
     URI httpUri;
-    @UriParam(description = "To use a custom HeaderFilterStrategy to filter header to and from Camel message.")
+    @UriParam(label = "common", description = "To use a custom HeaderFilterStrategy to filter header to and from Camel message.")
     HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
-    @UriParam(description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
+    @UriParam(label = "common,advanced", description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
     HttpBinding httpBinding;
     @UriParam(label = "producer", defaultValue = "true",
             description = "Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server."
@@ -74,7 +74,7 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
     String proxyHost;
     @UriParam(label = "producer", description = "The proxy port number")
     int proxyPort;
-    @UriParam(label = "producer", enums = "Basic,Digest,NTLM", description = "Authentication method for proxy, either as Basic, Digest or NTLM.")
+    @UriParam(label = "producer,security", enums = "Basic,Digest,NTLM", description = "Authentication method for proxy, either as Basic, Digest or NTLM.")
     String authMethodPriority;
     @UriParam(description = "If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized"
             + " in the response as a application/x-java-serialized-object content type."
@@ -85,10 +85,10 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
     boolean transferException;
     @UriParam(label = "producer", defaultValue = "false", description = "Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.")
     boolean connectionClose;
-    @UriParam(label = "consumer",
+    @UriParam(label = "consumer,advanced",
             description = "Specifies whether to enable HTTP TRACE for this Servlet consumer. By default TRACE is turned off.")
     boolean traceEnabled;
-    @UriParam(label = "consumer",
+    @UriParam(label = "consumer,advanced",
             description = "Specifies whether to enable HTTP OPTIONS for this Servlet consumer. By default OPTIONS is turned off.")
     boolean optionsEnabled;
     @UriParam(label = "consumer",
@@ -104,7 +104,7 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
             description = "If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy."
                     + " Setting this to false, allows to only include the headers from the HTTP response (not propagating IN headers).")
     boolean copyHeaders = true;
-    @UriParam(label = "consumer",
+    @UriParam(label = "consumer,advanced",
             description = "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 eagerCheckContentAvailable;
@@ -120,20 +120,21 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
             description = "If this option is true then IN exchange Form Encoded body of the exchange will be mapped to HTTP."
             + " Setting this to false will avoid the HTTP Form Encoded body mapping.")
     boolean mapHttpMessageFormUrlEncodedBody = true;
-    @UriParam(label = "producer", defaultValue = "200-299",
+    @UriParam(label = "producer,advanced", defaultValue = "200-299",
             description = "The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.")
     private String okStatusCodeRange = "200-299";
     @UriParam(label = "producer,advanced",
             description = "Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite urls when you bridge/proxy endpoints."
                     + " See more details at http://camel.apache.org/urlrewrite.html")
+    @Deprecated
     private UrlRewrite urlRewrite;
     @UriParam(label = "consumer", defaultValue = "false",
             description = "Configure the consumer to work in async mode")
     private boolean async;
-    @UriParam(label = "producer", description = "Configure a cookie handler to maintain a HTTP session")
+    @UriParam(label = "producer,advanced", description = "Configure a cookie handler to maintain a HTTP session")
     private CookieHandler cookieHandler;
-    @UriParam(label = "producer", description = "Configure the http Method to use as URI param. In case this is set, it can't be overriden by the HttpMethod header.")
-    private String httpMethod;
+    @UriParam(label = "producer", description = "Configure the HTTP method to use. The HttpMethod header cannot override this option if set.")
+    private HttpMethods httpMethod;
 
     public HttpCommonEndpoint() {
     }
@@ -429,6 +430,7 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
         this.httpMethodRestrict = httpMethodRestrict;
     }
 
+    @Deprecated
     public UrlRewrite getUrlRewrite() {
         return urlRewrite;
     }
@@ -437,6 +439,7 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
      * Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite urls when you bridge/proxy endpoints.
      * See more details at http://camel.apache.org/urlrewrite.html
      */
+    @Deprecated
     public void setUrlRewrite(UrlRewrite urlRewrite) {
         this.urlRewrite = urlRewrite;
     }
@@ -539,7 +542,6 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
 
     /**
      * If this option is true, the consumer will work in async mode
-     * @param async
      */
     public void setAsync(boolean async) {
         this.async = async;
@@ -556,14 +558,14 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
         this.cookieHandler = cookieHandler;
     }
 
-    public String getHttpMethod() {
+    public HttpMethods getHttpMethod() {
         return httpMethod;
     }
 
     /**
-     * Configure the Http method to use
+     * Configure the HTTP method to use. The HttpMethod header cannot override this option if set.
      */
-    public void setHttpMethod(String httpMethod) {
+    public void setHttpMethod(HttpMethods httpMethod) {
         this.httpMethod = httpMethod;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
index c0b3e34..b03725e 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
@@ -512,11 +512,12 @@ public final class HttpHelper {
             queryString = endpoint.getHttpUri().getRawQuery();
         }
 
-        // compute what method to use either GET or POST
         HttpMethods answer;
-        if (ObjectHelper.isNotEmpty(endpoint.getHttpMethod())) {
-            answer = HttpMethods.valueOf(endpoint.getHttpMethod());
+        if (endpoint.getHttpMethod() != null) {
+            // endpoint configured take precedence
+            answer = endpoint.getHttpMethod();
         } else {
+            // compute what method to use either GET or POST (header take precedence)
             HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
             if (m != null) {
                 // always use what end-user provides in a header

http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http/src/main/docs/http-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/docs/http-component.adoc b/components/camel-http/src/main/docs/http-component.adoc
index b0abe34..7837b04 100644
--- a/components/camel-http/src/main/docs/http-component.adoc
+++ b/components/camel-http/src/main/docs/http-component.adoc
@@ -149,22 +149,21 @@ The HTTP component supports 27 endpoint options which are listed below:
 | Name | Group | Default | Java Type | Description
 | httpUri | producer |  | URI | *Required* The url of the HTTP endpoint to call.
 | disableStreamCache | common | false | boolean | Determines whether or not the raw input stream from Servlet is cached or not (Camel will read the stream into a in memory/overflow to file Stream caching) cache. By default Camel will cache the Servlet input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream such as streaming it directly to a file or other persistent store. DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body if this option is false to support reading the stream multiple times. If you use Servlet to bridge/proxy an endpoint then consider enabling this option to improve performance in case you do not need to read the message payload multiple times. The http/http4 producer will by default cache the response body stream. If setting this option to true then the producers will not ca
 che the response body stream but use the response stream as-is as the message body.
-| authMethodPriority | producer |  | String | Authentication method for proxy either as Basic Digest or NTLM.
+| headerFilterStrategy | common |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
+| httpBinding | common (advanced) |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
 | bridgeEndpoint | producer | false | boolean | If the option is true HttpProducer will ignore the Exchange.HTTP_URI header and use the endpoint's URI for request. You may also set the option throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.
 | chunked | producer | true | boolean | If this option is false the Servlet will disable the HTTP streaming and set the content-length header on the response
 | connectionClose | producer | false | boolean | Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.
-| cookieHandler | producer |  | CookieHandler | Configure a cookie handler to maintain a HTTP session
 | copyHeaders | producer | true | boolean | If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false allows to only include the headers from the HTTP response (not propagating IN headers).
-| headerFilterStrategy | producer |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
-| httpBinding | producer |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-| httpMethod | producer |  | String | Configure the http Method to use as URI param. In case this is set it can't be overriden by the HttpMethod header.
+| httpMethod | producer |  | HttpMethods | Configure the HTTP method to use. The HttpMethod header cannot override this option if set.
 | ignoreResponseBody | producer | false | boolean | If this option is true The http producer won't read response body and cache the input stream
-| okStatusCodeRange | producer | 200-299 | String | The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.
 | preserveHostHeader | producer | false | boolean | If the option is true HttpProducer will set the Host header to the value contained in the current exchange Host header useful in reverse proxy applications where you want the Host header received by the downstream server to reflect the URL called by the upstream client this allows applications which use the Host header to generate accurate URL's for a proxied service
 | proxyHost | producer |  | String | The proxy host name
 | proxyPort | producer |  | int | The proxy port number
 | throwExceptionOnFailure | producer | true | boolean | Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.
 | transferException | producer | false | boolean | If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type. On the producer side the exception will be deserialized and thrown as is instead of the HttpOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.
+| cookieHandler | producer (advanced) |  | CookieHandler | Configure a cookie handler to maintain a HTTP session
+| okStatusCodeRange | producer (advanced) | 200-299 | String | The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.
 | urlRewrite | producer (advanced) |  | UrlRewrite | Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite urls when you bridge/proxy endpoints. See more details at http://camel.apache.org/urlrewrite.html
 | httpClientConfigurer | advanced |  | HttpClientConfigurer | Register a custom configuration strategy for new HttpClient instances created by producers or consumers such as to configure authentication mechanisms etc
 | httpClientOptions | advanced |  | Map | To configure the HttpClient using the key/values from the Map.
@@ -174,6 +173,7 @@ The HTTP component supports 27 endpoint options which are listed below:
 | mapHttpMessageFormUrlEncodedBody | advanced | true | boolean | If this option is true then IN exchange Form Encoded body of the exchange will be mapped to HTTP. Setting this to false will avoid the HTTP Form Encoded body mapping.
 | mapHttpMessageHeaders | advanced | true | boolean | If this option is true then IN exchange Headers of the exchange will be mapped to HTTP headers. Setting this to false will avoid the HTTP Headers mapping.
 | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
+| authMethodPriority | security |  | String | Authentication method for proxy either as Basic Digest or NTLM.
 |=======================================================================
 {% endraw %}
 // endpoint options: END
@@ -265,15 +265,15 @@ This exception contains the following information:
 * Response body as a `java.lang.String`, if server provided a body as
 response
 
-### Calling using GET or POST
+### Which HTTP method will be used
 
-The following algorithm is used to determine if either `GET` or `POST`
-HTTP method should be used: +
- 1. Use method provided in header. +
- 2. `GET` if query string is provided in header. +
- 3. `GET` if endpoint is configured with a query string. +
- 4. `POST` if there is data to send (body is not null). +
- 5. `GET` otherwise.
+The following algorithm is used to determine what HTTP method should be used: +
+ 1. Use method provided as endpoint configuration (`httpMethod`). +
+ 2. Use method provided in header (`Exchange.HTTP_METHOD`). +
+ 3. `GET` if query string is provided in header. +
+ 4. `GET` if endpoint is configured with a query string. +
+ 5. `POST` if there is data to send (body is not `null`). +
+ 6. `GET` otherwise.
 
 ### How to get access to HttpServletRequest and HttpServletResponse
 

http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http4/src/main/docs/http4-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/docs/http4-component.adoc b/components/camel-http4/src/main/docs/http4-component.adoc
index dad818b..facde08 100644
--- a/components/camel-http4/src/main/docs/http4-component.adoc
+++ b/components/camel-http4/src/main/docs/http4-component.adoc
@@ -94,25 +94,24 @@ The HTTP4 component supports 33 endpoint options which are listed below:
 | Name | Group | Default | Java Type | Description
 | httpUri | producer |  | URI | *Required* The url of the HTTP endpoint to call.
 | disableStreamCache | common | false | boolean | Determines whether or not the raw input stream from Servlet is cached or not (Camel will read the stream into a in memory/overflow to file Stream caching) cache. By default Camel will cache the Servlet input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream such as streaming it directly to a file or other persistent store. DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body if this option is false to support reading the stream multiple times. If you use Servlet to bridge/proxy an endpoint then consider enabling this option to improve performance in case you do not need to read the message payload multiple times. The http/http4 producer will by default cache the response body stream. If setting this option to true then the producers will not ca
 che the response body stream but use the response stream as-is as the message body.
+| headerFilterStrategy | common |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
+| httpBinding | common (advanced) |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
 | authenticationPreemptive | producer | false | boolean | If this option is true camel-http4 sends preemptive basic authentication to the server.
-| authMethodPriority | producer |  | String | Authentication method for proxy either as Basic Digest or NTLM.
 | bridgeEndpoint | producer | false | boolean | If the option is true HttpProducer will ignore the Exchange.HTTP_URI header and use the endpoint's URI for request. You may also set the option throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.
 | chunked | producer | true | boolean | If this option is false the Servlet will disable the HTTP streaming and set the content-length header on the response
 | clearExpiredCookies | producer | true | boolean | Whether to clear expired cookies before sending the HTTP request. This ensures the cookies store does not keep growing by adding new cookies which is newer removed when they are expired.
 | connectionClose | producer | false | boolean | Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.
-| cookieHandler | producer |  | CookieHandler | Configure a cookie handler to maintain a HTTP session
 | cookieStore | producer |  | CookieStore | To use a custom org.apache.http.client.CookieStore. By default the org.apache.http.impl.client.BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie store as cookie shouldn't be stored as we are just bridging (eg acting as a proxy). If a cookieHandler is set then the cookie store is also forced to be a noop cookie store as cookie handling is then performed by the cookieHandler.
 | copyHeaders | producer | true | boolean | If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false allows to only include the headers from the HTTP response (not propagating IN headers).
-| headerFilterStrategy | producer |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
-| httpBinding | producer |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-| httpMethod | producer |  | String | Configure the http Method to use as URI param. In case this is set it can't be overriden by the HttpMethod header.
+| httpMethod | producer |  | HttpMethods | Configure the HTTP method to use. The HttpMethod header cannot override this option if set.
 | ignoreResponseBody | producer | false | boolean | If this option is true The http producer won't read response body and cache the input stream
-| okStatusCodeRange | producer | 200-299 | String | The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.
 | preserveHostHeader | producer | false | boolean | If the option is true HttpProducer will set the Host header to the value contained in the current exchange Host header useful in reverse proxy applications where you want the Host header received by the downstream server to reflect the URL called by the upstream client this allows applications which use the Host header to generate accurate URL's for a proxied service
 | proxyHost | producer |  | String | The proxy host name
 | proxyPort | producer |  | int | The proxy port number
 | throwExceptionOnFailure | producer | true | boolean | Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.
 | transferException | producer | false | boolean | If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type. On the producer side the exception will be deserialized and thrown as is instead of the HttpOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.
+| cookieHandler | producer (advanced) |  | CookieHandler | Configure a cookie handler to maintain a HTTP session
+| okStatusCodeRange | producer (advanced) | 200-299 | String | The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.
 | urlRewrite | producer (advanced) |  | UrlRewrite | Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite urls when you bridge/proxy endpoints. See more details at http://camel.apache.org/urlrewrite.html
 | clientBuilder | advanced |  | HttpClientBuilder | Provide access to the http client request parameters used on new RequestConfig instances used by producers or consumers of this endpoint.
 | clientConnectionManager | advanced |  | HttpClientConnectionManager | To use a custom HttpClientConnectionManager to manage connections
@@ -125,6 +124,7 @@ The HTTP4 component supports 33 endpoint options which are listed below:
 | mapHttpMessageHeaders | advanced | true | boolean | If this option is true then IN exchange Headers of the exchange will be mapped to HTTP headers. Setting this to false will avoid the HTTP Headers mapping.
 | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
 | useSystemProperties | advanced | false | boolean | To use System Properties as fallback for configuration
+| authMethodPriority | security |  | String | Authentication method for proxy either as Basic Digest or NTLM.
 |=======================================================================
 {% endraw %}
 // endpoint options: END
@@ -226,15 +226,15 @@ This exception contains the following information:
 * Response body as a `java.lang.String`, if server provided a body as
 response
 
-### Calling using GET or POST
+### Which HTTP method will be used
 
-The following algorithm is used to determine whether the `GET` or `POST`
-HTTP method should be used: +
- 1. Use method provided in header. +
- 2. `GET` if query string is provided in header. +
- 3. `GET` if endpoint is configured with a query string. +
- 4. `POST` if there is data to send (body is not null). +
- 5. `GET` otherwise.
+The following algorithm is used to determine what HTTP method should be used: +
+ 1. Use method provided as endpoint configuration (`httpMethod`). +
+ 2. Use method provided in header (`Exchange.HTTP_METHOD`). +
+ 3. `GET` if query string is provided in header. +
+ 4. `GET` if endpoint is configured with a query string. +
+ 5. `POST` if there is data to send (body is not `null`). +
+ 6. `GET` otherwise.
 
 ### How to get access to HttpServletRequest and HttpServletResponse
 

http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
index a48ca03..6ec04eb 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
@@ -63,9 +63,11 @@ public final class HttpMethodHelper {
 
         // compute what method to use either GET or POST
         HttpMethods answer;
-        if (ObjectHelper.isNotEmpty(endpoint.getHttpMethod())) {
-            answer = HttpMethods.valueOf(endpoint.getHttpMethod());
+        if (endpoint.getHttpMethod() != null) {
+            // endpoint configured take precedence
+            answer = HttpMethods.valueOf(endpoint.getHttpMethod().name());
         } else {
+            // compute what method to use either GET or POST (header take precedence)
             HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
             if (m != null) {
                 // always use what end-user provides in a header


Re: camel git commit: CAMEL-10878: camel-http / camel-http4 - Allow to specify HTTP operation as uri parameter

Posted by Andrea Cosentino <an...@yahoo.com.INVALID>.
I thought a String was better than HttpMethods as uri param.

We had the enum to check into in our components.
 --
Andrea Cosentino 
----------------------------------
Apache Camel PMC Member
Apache Karaf Committer
Apache Servicemix Committer
Email: ancosen1985@yahoo.com
Twitter: @oscerd2
Github: oscerd



On Friday, February 24, 2017 10:15 AM, "davsclaus@apache.org" <da...@apache.org> wrote:
Repository: camel
Updated Branches:
  refs/heads/master a35caf738 -> 5067c5b89


CAMEL-10878: camel-http / camel-http4 - Allow to specify HTTP operation as uri parameter


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

Branch: refs/heads/master
Commit: 5067c5b892c669ff5aaff98054f83f43e87d831b
Parents: a35caf7
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Feb 24 10:12:46 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Feb 24 10:13:39 2017 +0100

----------------------------------------------------------------------
.../camel/http/common/HttpCommonEndpoint.java   | 30 +++++++++++---------
.../apache/camel/http/common/HttpHelper.java    |  7 +++--
.../src/main/docs/http-component.adoc           | 28 +++++++++---------
.../src/main/docs/http4-component.adoc          | 28 +++++++++---------
.../http4/helper/HttpMethodHelper.java          |  6 ++--
5 files changed, 52 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
index 69763b7..d7094c7 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
@@ -35,9 +35,9 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head

     @UriPath(label = "producer", description = "The url of the HTTP endpoint to call.") @Metadata(required = "true")
     URI httpUri;
-    @UriParam(description = "To use a custom HeaderFilterStrategy to filter header to and from Camel message.")
+    @UriParam(label = "common", description = "To use a custom HeaderFilterStrategy to filter header to and from Camel message.")
     HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
-    @UriParam(description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
+    @UriParam(label = "common,advanced", description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
     HttpBinding httpBinding;
     @UriParam(label = "producer", defaultValue = "true",
             description = "Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server."
@@ -74,7 +74,7 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
     String proxyHost;
     @UriParam(label = "producer", description = "The proxy port number")
     int proxyPort;
-    @UriParam(label = "producer", enums = "Basic,Digest,NTLM", description = "Authentication method for proxy, either as Basic, Digest or NTLM.")
+    @UriParam(label = "producer,security", enums = "Basic,Digest,NTLM", description = "Authentication method for proxy, either as Basic, Digest or NTLM.")
     String authMethodPriority;
     @UriParam(description = "If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized"
             + " in the response as a application/x-java-serialized-object content type."
@@ -85,10 +85,10 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
     boolean transferException;
     @UriParam(label = "producer", defaultValue = "false", description = "Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.")
     boolean connectionClose;
-    @UriParam(label = "consumer",
+    @UriParam(label = "consumer,advanced",
             description = "Specifies whether to enable HTTP TRACE for this Servlet consumer. By default TRACE is turned off.")
     boolean traceEnabled;
-    @UriParam(label = "consumer",
+    @UriParam(label = "consumer,advanced",
             description = "Specifies whether to enable HTTP OPTIONS for this Servlet consumer. By default OPTIONS is turned off.")
     boolean optionsEnabled;
     @UriParam(label = "consumer",
@@ -104,7 +104,7 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
             description = "If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy."
                     + " Setting this to false, allows to only include the headers from the HTTP response (not propagating IN headers).")
     boolean copyHeaders = true;
-    @UriParam(label = "consumer",
+    @UriParam(label = "consumer,advanced",
             description = "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 eagerCheckContentAvailable;
@@ -120,20 +120,21 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
             description = "If this option is true then IN exchange Form Encoded body of the exchange will be mapped to HTTP."
             + " Setting this to false will avoid the HTTP Form Encoded body mapping.")
     boolean mapHttpMessageFormUrlEncodedBody = true;
-    @UriParam(label = "producer", defaultValue = "200-299",
+    @UriParam(label = "producer,advanced", defaultValue = "200-299",
             description = "The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.")
     private String okStatusCodeRange = "200-299";
     @UriParam(label = "producer,advanced",
             description = "Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite urls when you bridge/proxy endpoints."
                     + " See more details at http://camel.apache.org/urlrewrite.html")
+    @Deprecated
     private UrlRewrite urlRewrite;
     @UriParam(label = "consumer", defaultValue = "false",
             description = "Configure the consumer to work in async mode")
     private boolean async;
-    @UriParam(label = "producer", description = "Configure a cookie handler to maintain a HTTP session")
+    @UriParam(label = "producer,advanced", description = "Configure a cookie handler to maintain a HTTP session")
     private CookieHandler cookieHandler;
-    @UriParam(label = "producer", description = "Configure the http Method to use as URI param. In case this is set, it can't be overriden by the HttpMethod header.")
-    private String httpMethod;
+    @UriParam(label = "producer", description = "Configure the HTTP method to use. The HttpMethod header cannot override this option if set.")
+    private HttpMethods httpMethod;

     public HttpCommonEndpoint() {
     }
@@ -429,6 +430,7 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
         this.httpMethodRestrict = httpMethodRestrict;
     }

+    @Deprecated
     public UrlRewrite getUrlRewrite() {
         return urlRewrite;
     }
@@ -437,6 +439,7 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
      * Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite urls when you bridge/proxy endpoints.
      * See more details at http://camel.apache.org/urlrewrite.html
      */
+    @Deprecated
     public void setUrlRewrite(UrlRewrite urlRewrite) {
         this.urlRewrite = urlRewrite;
     }
@@ -539,7 +542,6 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head

     /**
      * If this option is true, the consumer will work in async mode
-     * @param async
      */
     public void setAsync(boolean async) {
         this.async = async;
@@ -556,14 +558,14 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
         this.cookieHandler = cookieHandler;
     }

-    public String getHttpMethod() {
+    public HttpMethods getHttpMethod() {
         return httpMethod;
     }

     /**
-     * Configure the Http method to use
+     * Configure the HTTP method to use. The HttpMethod header cannot override this option if set.
      */
-    public void setHttpMethod(String httpMethod) {
+    public void setHttpMethod(HttpMethods httpMethod) {
         this.httpMethod = httpMethod;
     }
}

http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
index c0b3e34..b03725e 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
@@ -512,11 +512,12 @@ public final class HttpHelper {
             queryString = endpoint.getHttpUri().getRawQuery();
         }

-        // compute what method to use either GET or POST
         HttpMethods answer;
-        if (ObjectHelper.isNotEmpty(endpoint.getHttpMethod())) {
-            answer = HttpMethods.valueOf(endpoint.getHttpMethod());
+        if (endpoint.getHttpMethod() != null) {
+            // endpoint configured take precedence
+            answer = endpoint.getHttpMethod();
         } else {
+            // compute what method to use either GET or POST (header take precedence)
             HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
             if (m != null) {
                 // always use what end-user provides in a header

http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http/src/main/docs/http-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/docs/http-component.adoc b/components/camel-http/src/main/docs/http-component.adoc
index b0abe34..7837b04 100644
--- a/components/camel-http/src/main/docs/http-component.adoc
+++ b/components/camel-http/src/main/docs/http-component.adoc
@@ -149,22 +149,21 @@ The HTTP component supports 27 endpoint options which are listed below:
| Name | Group | Default | Java Type | Description
| httpUri | producer |  | URI | *Required* The url of the HTTP endpoint to call.
| disableStreamCache | common | false | boolean | Determines whether or not the raw input stream from Servlet is cached or not (Camel will read the stream into a in memory/overflow to file Stream caching) cache. By default Camel will cache the Servlet input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream such as streaming it directly to a file or other persistent store. DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body if this option is false to support reading the stream multiple times. If you use Servlet to bridge/proxy an endpoint then consider enabling this option to improve performance in case you do not need to read the message payload multiple times. The http/http4 producer will by default cache the response body stream. If setting this option to true then the producers will not ca
che the response body stream but use the response stream as-is as the message body.
-| authMethodPriority | producer |  | String | Authentication method for proxy either as Basic Digest or NTLM.
+| headerFilterStrategy | common |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
+| httpBinding | common (advanced) |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
| bridgeEndpoint | producer | false | boolean | If the option is true HttpProducer will ignore the Exchange.HTTP_URI header and use the endpoint's URI for request. You may also set the option throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.
| chunked | producer | true | boolean | If this option is false the Servlet will disable the HTTP streaming and set the content-length header on the response
| connectionClose | producer | false | boolean | Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.
-| cookieHandler | producer |  | CookieHandler | Configure a cookie handler to maintain a HTTP session
| copyHeaders | producer | true | boolean | If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false allows to only include the headers from the HTTP response (not propagating IN headers).
-| headerFilterStrategy | producer |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
-| httpBinding | producer |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-| httpMethod | producer |  | String | Configure the http Method to use as URI param. In case this is set it can't be overriden by the HttpMethod header.
+| httpMethod | producer |  | HttpMethods | Configure the HTTP method to use. The HttpMethod header cannot override this option if set.
| ignoreResponseBody | producer | false | boolean | If this option is true The http producer won't read response body and cache the input stream
-| okStatusCodeRange | producer | 200-299 | String | The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.
| preserveHostHeader | producer | false | boolean | If the option is true HttpProducer will set the Host header to the value contained in the current exchange Host header useful in reverse proxy applications where you want the Host header received by the downstream server to reflect the URL called by the upstream client this allows applications which use the Host header to generate accurate URL's for a proxied service
| proxyHost | producer |  | String | The proxy host name
| proxyPort | producer |  | int | The proxy port number
| throwExceptionOnFailure | producer | true | boolean | Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.
| transferException | producer | false | boolean | If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type. On the producer side the exception will be deserialized and thrown as is instead of the HttpOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.
+| cookieHandler | producer (advanced) |  | CookieHandler | Configure a cookie handler to maintain a HTTP session
+| okStatusCodeRange | producer (advanced) | 200-299 | String | The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.
| urlRewrite | producer (advanced) |  | UrlRewrite | Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite urls when you bridge/proxy endpoints. See more details at http://camel.apache.org/urlrewrite.html
| httpClientConfigurer | advanced |  | HttpClientConfigurer | Register a custom configuration strategy for new HttpClient instances created by producers or consumers such as to configure authentication mechanisms etc
| httpClientOptions | advanced |  | Map | To configure the HttpClient using the key/values from the Map.
@@ -174,6 +173,7 @@ The HTTP component supports 27 endpoint options which are listed below:
| mapHttpMessageFormUrlEncodedBody | advanced | true | boolean | If this option is true then IN exchange Form Encoded body of the exchange will be mapped to HTTP. Setting this to false will avoid the HTTP Form Encoded body mapping.
| mapHttpMessageHeaders | advanced | true | boolean | If this option is true then IN exchange Headers of the exchange will be mapped to HTTP headers. Setting this to false will avoid the HTTP Headers mapping.
| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
+| authMethodPriority | security |  | String | Authentication method for proxy either as Basic Digest or NTLM.
|=======================================================================
{% endraw %}
// endpoint options: END
@@ -265,15 +265,15 @@ This exception contains the following information:
* Response body as a `java.lang.String`, if server provided a body as
response

-### Calling using GET or POST
+### Which HTTP method will be used

-The following algorithm is used to determine if either `GET` or `POST`
-HTTP method should be used: +
- 1. Use method provided in header. +
- 2. `GET` if query string is provided in header. +
- 3. `GET` if endpoint is configured with a query string. +
- 4. `POST` if there is data to send (body is not null). +
- 5. `GET` otherwise.
+The following algorithm is used to determine what HTTP method should be used: +
+ 1. Use method provided as endpoint configuration (`httpMethod`). +
+ 2. Use method provided in header (`Exchange.HTTP_METHOD`). +
+ 3. `GET` if query string is provided in header. +
+ 4. `GET` if endpoint is configured with a query string. +
+ 5. `POST` if there is data to send (body is not `null`). +
+ 6. `GET` otherwise.

### How to get access to HttpServletRequest and HttpServletResponse


http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http4/src/main/docs/http4-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/docs/http4-component.adoc b/components/camel-http4/src/main/docs/http4-component.adoc
index dad818b..facde08 100644
--- a/components/camel-http4/src/main/docs/http4-component.adoc
+++ b/components/camel-http4/src/main/docs/http4-component.adoc
@@ -94,25 +94,24 @@ The HTTP4 component supports 33 endpoint options which are listed below:
| Name | Group | Default | Java Type | Description
| httpUri | producer |  | URI | *Required* The url of the HTTP endpoint to call.
| disableStreamCache | common | false | boolean | Determines whether or not the raw input stream from Servlet is cached or not (Camel will read the stream into a in memory/overflow to file Stream caching) cache. By default Camel will cache the Servlet input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream such as streaming it directly to a file or other persistent store. DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body if this option is false to support reading the stream multiple times. If you use Servlet to bridge/proxy an endpoint then consider enabling this option to improve performance in case you do not need to read the message payload multiple times. The http/http4 producer will by default cache the response body stream. If setting this option to true then the producers will not ca
che the response body stream but use the response stream as-is as the message body.
+| headerFilterStrategy | common |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
+| httpBinding | common (advanced) |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
| authenticationPreemptive | producer | false | boolean | If this option is true camel-http4 sends preemptive basic authentication to the server.
-| authMethodPriority | producer |  | String | Authentication method for proxy either as Basic Digest or NTLM.
| bridgeEndpoint | producer | false | boolean | If the option is true HttpProducer will ignore the Exchange.HTTP_URI header and use the endpoint's URI for request. You may also set the option throwExceptionOnFailure to be false to let the HttpProducer send all the fault response back.
| chunked | producer | true | boolean | If this option is false the Servlet will disable the HTTP streaming and set the content-length header on the response
| clearExpiredCookies | producer | true | boolean | Whether to clear expired cookies before sending the HTTP request. This ensures the cookies store does not keep growing by adding new cookies which is newer removed when they are expired.
| connectionClose | producer | false | boolean | Specifies whether a Connection Close header must be added to HTTP Request. By default connectionClose is false.
-| cookieHandler | producer |  | CookieHandler | Configure a cookie handler to maintain a HTTP session
| cookieStore | producer |  | CookieStore | To use a custom org.apache.http.client.CookieStore. By default the org.apache.http.impl.client.BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie store as cookie shouldn't be stored as we are just bridging (eg acting as a proxy). If a cookieHandler is set then the cookie store is also forced to be a noop cookie store as cookie handling is then performed by the cookieHandler.
| copyHeaders | producer | true | boolean | If this option is true then IN exchange headers will be copied to OUT exchange headers according to copy strategy. Setting this to false allows to only include the headers from the HTTP response (not propagating IN headers).
-| headerFilterStrategy | producer |  | HeaderFilterStrategy | To use a custom HeaderFilterStrategy to filter header to and from Camel message.
-| httpBinding | producer |  | HttpBinding | To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-| httpMethod | producer |  | String | Configure the http Method to use as URI param. In case this is set it can't be overriden by the HttpMethod header.
+| httpMethod | producer |  | HttpMethods | Configure the HTTP method to use. The HttpMethod header cannot override this option if set.
| ignoreResponseBody | producer | false | boolean | If this option is true The http producer won't read response body and cache the input stream
-| okStatusCodeRange | producer | 200-299 | String | The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.
| preserveHostHeader | producer | false | boolean | If the option is true HttpProducer will set the Host header to the value contained in the current exchange Host header useful in reverse proxy applications where you want the Host header received by the downstream server to reflect the URL called by the upstream client this allows applications which use the Host header to generate accurate URL's for a proxied service
| proxyHost | producer |  | String | The proxy host name
| proxyPort | producer |  | int | The proxy port number
| throwExceptionOnFailure | producer | true | boolean | Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.
| transferException | producer | false | boolean | If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type. On the producer side the exception will be deserialized and thrown as is instead of the HttpOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.
+| cookieHandler | producer (advanced) |  | CookieHandler | Configure a cookie handler to maintain a HTTP session
+| okStatusCodeRange | producer (advanced) | 200-299 | String | The status codes which is considered a success response. The values are inclusive. The range must be defined as from-to with the dash included.
| urlRewrite | producer (advanced) |  | UrlRewrite | Refers to a custom org.apache.camel.component.http.UrlRewrite which allows you to rewrite urls when you bridge/proxy endpoints. See more details at http://camel.apache.org/urlrewrite.html
| clientBuilder | advanced |  | HttpClientBuilder | Provide access to the http client request parameters used on new RequestConfig instances used by producers or consumers of this endpoint.
| clientConnectionManager | advanced |  | HttpClientConnectionManager | To use a custom HttpClientConnectionManager to manage connections
@@ -125,6 +124,7 @@ The HTTP4 component supports 33 endpoint options which are listed below:
| mapHttpMessageHeaders | advanced | true | boolean | If this option is true then IN exchange Headers of the exchange will be mapped to HTTP headers. Setting this to false will avoid the HTTP Headers mapping.
| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
| useSystemProperties | advanced | false | boolean | To use System Properties as fallback for configuration
+| authMethodPriority | security |  | String | Authentication method for proxy either as Basic Digest or NTLM.
|=======================================================================
{% endraw %}
// endpoint options: END
@@ -226,15 +226,15 @@ This exception contains the following information:
* Response body as a `java.lang.String`, if server provided a body as
response

-### Calling using GET or POST
+### Which HTTP method will be used

-The following algorithm is used to determine whether the `GET` or `POST`
-HTTP method should be used: +
- 1. Use method provided in header. +
- 2. `GET` if query string is provided in header. +
- 3. `GET` if endpoint is configured with a query string. +
- 4. `POST` if there is data to send (body is not null). +
- 5. `GET` otherwise.
+The following algorithm is used to determine what HTTP method should be used: +
+ 1. Use method provided as endpoint configuration (`httpMethod`). +
+ 2. Use method provided in header (`Exchange.HTTP_METHOD`). +
+ 3. `GET` if query string is provided in header. +
+ 4. `GET` if endpoint is configured with a query string. +
+ 5. `POST` if there is data to send (body is not `null`). +
+ 6. `GET` otherwise.

### How to get access to HttpServletRequest and HttpServletResponse


http://git-wip-us.apache.org/repos/asf/camel/blob/5067c5b8/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
index a48ca03..6ec04eb 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
@@ -63,9 +63,11 @@ public final class HttpMethodHelper {

         // compute what method to use either GET or POST
         HttpMethods answer;
-        if (ObjectHelper.isNotEmpty(endpoint.getHttpMethod())) {
-            answer = HttpMethods.valueOf(endpoint.getHttpMethod());
+        if (endpoint.getHttpMethod() != null) {
+            // endpoint configured take precedence
+            answer = HttpMethods.valueOf(endpoint.getHttpMethod().name());
         } else {
+            // compute what method to use either GET or POST (header take precedence)
             HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
             if (m != null) {
                 // always use what end-user provides in a header