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 2010/04/10 12:49:35 UTC

svn commit: r932690 [2/3] - in /camel/trunk/components/camel-http: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/camel/ src/main/java/org/apache/camel/component/ src/main/java/org/apache/camel/co...

Added: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java (added)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,285 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.component.http.helper.GZIPHelper;
+import org.apache.camel.component.http.helper.HttpProducerHelper;
+import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision$
+ */
+public class HttpProducer extends DefaultProducer {
+    private static final transient Log LOG = LogFactory.getLog(HttpProducer.class);
+    private HttpClient httpClient;
+    private boolean throwException;
+
+    public HttpProducer(HttpEndpoint endpoint) {
+        super(endpoint);
+        this.httpClient = endpoint.createHttpClient();
+        this.throwException = endpoint.isThrowExceptionOnFailure();
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        HttpMethod method = createMethod(exchange);
+        Message in = exchange.getIn();
+        HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();
+
+        // propagate headers as HTTP headers
+        for (String headerName : in.getHeaders().keySet()) {
+            String headerValue = in.getHeader(headerName, String.class);
+            if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
+                method.addRequestHeader(headerName, headerValue);
+            }
+        }
+
+        // lets store the result in the output message.
+        try {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Executing http " + method.getName() + " method: " + method.getURI().toString());
+            }
+            int responseCode = executeMethod(method);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Http responseCode: " + responseCode);
+            }
+
+            if (!throwException) {
+                // if we do not use failed exception then populate response for all response codes
+                populateResponse(exchange, method, in, strategy, responseCode);
+            } else {
+                if (responseCode >= 100 && responseCode < 300) {
+                    // only populate response for OK response
+                    populateResponse(exchange, method, in, strategy, responseCode);
+                } else {
+                    // operation failed so populate exception to throw
+                    throw populateHttpOperationFailedException(exchange, method, responseCode);
+                }
+            }
+        } finally {
+            method.releaseConnection();
+        }
+    }
+
+    @Override
+    public HttpEndpoint getEndpoint() {
+        return (HttpEndpoint) super.getEndpoint();
+    }
+
+    protected void populateResponse(Exchange exchange, HttpMethod method, Message in, HeaderFilterStrategy strategy, int responseCode) throws IOException {
+        Message answer = exchange.getOut();
+
+        answer.setHeaders(in.getHeaders());
+        answer.setHeader(Exchange.HTTP_RESPONSE_CODE, responseCode);
+        answer.setBody(extractResponseBody(method, exchange));
+
+        // propagate HTTP response headers
+        Header[] headers = method.getResponseHeaders();
+        for (Header header : headers) {
+            String name = header.getName();
+            String value = header.getValue();
+            if (name.toLowerCase().equals("content-type")) {
+                name = Exchange.CONTENT_TYPE;
+            }
+            if (strategy != null && !strategy.applyFilterToExternalHeaders(name, value, exchange)) {
+                answer.setHeader(name, value);
+            }
+        }
+    }
+
+    protected HttpOperationFailedException populateHttpOperationFailedException(Exchange exchange, HttpMethod method, int responseCode) throws IOException {
+        HttpOperationFailedException exception;
+        String uri = method.getURI().toString();
+        String statusText = method.getStatusLine() != null ? method.getStatusLine().getReasonPhrase() : null;
+        Map<String, String> headers = extractResponseHeaders(method.getResponseHeaders());
+        InputStream is = extractResponseBody(method, exchange);
+        // make a defensive copy of the response body in the exception so its detached from the cache
+        String copy = null;
+        if (is != null) {
+            copy = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, is);
+        }
+
+        if (responseCode >= 300 && responseCode < 400) {
+            String redirectLocation;
+            Header locationHeader = method.getResponseHeader("location");
+            if (locationHeader != null) {
+                redirectLocation = locationHeader.getValue();
+                exception = new HttpOperationFailedException(uri, responseCode, statusText, redirectLocation, headers, copy);
+            } else {
+                // no redirect location
+                exception = new HttpOperationFailedException(uri, responseCode, statusText, null, headers, copy);
+            }
+        } else {
+            // internal server error (error code 500)
+            exception = new HttpOperationFailedException(uri, responseCode, statusText, null, headers, copy);
+        }
+
+        return exception;
+    }
+
+    /**
+     * Strategy when executing the method (calling the remote server).
+     *
+     * @param method    the method to execute
+     * @return the response code
+     * @throws IOException can be thrown
+     */
+    protected int executeMethod(HttpMethod method) throws IOException {
+        return httpClient.executeMethod(method);
+    }
+
+    /**
+     * Extracts the response headers
+     *
+     * @param responseHeaders the headers
+     * @return the extracted headers or <tt>null</tt> if no headers existed
+     */
+    protected static Map<String, String> extractResponseHeaders(Header[] responseHeaders) {
+        if (responseHeaders == null || responseHeaders.length == 0) {
+            return null;
+        }
+
+        Map<String, String> answer = new HashMap<String, String>();
+        for (Header header : responseHeaders) {
+            answer.put(header.getName(), header.getValue());
+        }
+
+        return answer;
+    }
+
+    /**
+     * Extracts the response from the method as a InputStream.
+     *
+     * @param method  the method that was executed
+     * @return  the response as a stream
+     * @throws IOException can be thrown
+     */
+    protected static InputStream extractResponseBody(HttpMethod method, Exchange exchange) throws IOException {
+        InputStream is = method.getResponseBodyAsStream();
+        if (is == null) {
+            return null;
+        }
+
+        Header header = method.getRequestHeader(Exchange.CONTENT_ENCODING);
+        String contentEncoding = header != null ? header.getValue() : null;
+
+        is = GZIPHelper.toGZIPInputStream(contentEncoding, is);
+        return doExtractResponseBody(is, exchange);
+    }
+
+    private static InputStream doExtractResponseBody(InputStream is, Exchange exchange) throws IOException {
+        try {
+            CachedOutputStream cos = new CachedOutputStream(exchange);
+            IOHelper.copy(is, cos);
+            return cos.getInputStream();
+        } finally {
+            ObjectHelper.close(is, "Extracting response body", LOG);            
+        }
+    }
+
+    /**
+     * Creates the HttpMethod to use to call the remote server, either its GET or POST.
+     *
+     * @param exchange  the exchange
+     * @return the created method as either GET or POST
+     */
+    protected HttpMethod createMethod(Exchange exchange) {
+
+        String url = HttpProducerHelper.createURL(exchange, getEndpoint());
+
+        RequestEntity requestEntity = createRequestEntity(exchange);
+        HttpMethods methodToUse = HttpProducerHelper.createMethod(exchange, getEndpoint(), requestEntity != null);
+        HttpMethod method = methodToUse.createMethod(url);
+
+        // is a query string provided in the endpoint URI or in a header (header overrules endpoint)
+        String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
+        if (queryString == null) {
+            queryString = getEndpoint().getHttpUri().getQuery();
+        }
+        if (queryString != null) {
+            method.setQueryString(queryString);
+        }
+
+        if (methodToUse.isEntityEnclosing()) {
+            ((EntityEnclosingMethod)method).setRequestEntity(requestEntity);
+            if (requestEntity != null && requestEntity.getContentType() == null) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("No Content-Type provided for URL: " + url + " with exchange: " + exchange);
+                }
+            }
+        }
+
+        return method;
+    }
+
+    /**
+     * Creates a holder object for the data to send to the remote server.
+     *
+     * @param exchange  the exchange with the IN message with data to send
+     * @return the data holder
+     */
+    protected RequestEntity createRequestEntity(Exchange exchange) {
+        Message in = exchange.getIn();
+        if (in.getBody() == null) {
+            return null;
+        }
+
+        RequestEntity answer = in.getBody(RequestEntity.class);        
+        if (answer == null) {
+            try {
+                String data = in.getBody(String.class);
+                if (data != null) {
+                    String contentType = ExchangeHelper.getContentType(exchange);
+                    String charset = exchange.getProperty(Exchange.CHARSET_NAME, String.class);
+                    answer = new StringRequestEntity(data, contentType, charset);
+                }
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeCamelException(e);
+            }
+        }
+        return answer;
+    }
+
+    public HttpClient getHttpClient() {
+        return httpClient;
+    }
+
+    public void setHttpClient(HttpClient httpClient) {
+        this.httpClient = httpClient;
+    }
+}

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java (added)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.NTCredentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+
+/**
+ * Strategy for configuring the HttpClient with a proxy
+ *
+ * @version 
+ */
+public class ProxyHttpClientConfigurer implements HttpClientConfigurer {
+
+    private final String host;
+    private final Integer port;
+    
+    private final String username;
+    private final String password;
+    private final String domain;
+    private final String ntHost;
+    
+    public ProxyHttpClientConfigurer(String host, Integer port) {
+        this(host, port, null, null, null, null);
+    }
+    
+    public ProxyHttpClientConfigurer(String host, Integer port, String username, String password, String domain, String ntHost) {
+        this.host = host;
+        this.port = port;
+        this.username = username;
+        this.password = password;
+        this.domain = domain;
+        this.ntHost = ntHost;
+    }
+
+    public void configureHttpClient(HttpClient client) {
+        client.getHostConfiguration().setProxy(host, port);
+
+        if (username != null && password != null) {
+            Credentials defaultcreds;        
+            if (domain != null) {
+                defaultcreds = new NTCredentials(username, password, ntHost, domain);
+            } else {
+                defaultcreds = new UsernamePasswordCredentials(username, password);
+            }
+            client.getState().setProxyCredentials(AuthScope.ANY, defaultcreds);
+        }
+    }
+}

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/ProxyHttpClientConfigurer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java (added)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.camel.Converter;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.http.helper.GZIPHelper;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
+import org.apache.commons.httpclient.methods.RequestEntity;
+
+/**
+ * Some converter methods to make it easier to convert the body to RequestEntity types.
+ */
+@Converter
+public class RequestEntityConverter {
+
+    @Converter
+    public RequestEntity toRequestEntity(byte[] data, Exchange exchange) throws Exception {
+        return asRequestEntity(data, exchange);
+    }
+
+    @Converter
+    public RequestEntity toRequestEntity(InputStream inStream, Exchange exchange) throws Exception {
+        return asRequestEntity(inStream, exchange);
+    }
+
+    @Converter
+    public RequestEntity toRequestEntity(String str, Exchange exchange) throws Exception {
+        if (GZIPHelper.isGzip(exchange.getIn())) {
+            byte[] data = exchange.getContext().getTypeConverter().convertTo(byte[].class, str);
+            return asRequestEntity(data, exchange);
+        } else {
+            // will use the default StringRequestEntity
+            return null;
+        }
+    }
+
+    private RequestEntity asRequestEntity(InputStream in, Exchange exchange) throws IOException {
+        return new InputStreamRequestEntity(
+                GZIPHelper.toGZIPInputStream(
+                        exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class),
+                        in), ExchangeHelper.getContentType(exchange));
+    }
+
+    private RequestEntity asRequestEntity(byte[] data, Exchange exchange) throws Exception {
+        return new InputStreamRequestEntity(
+            GZIPHelper.toGZIPInputStream(
+                    exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class),
+                    data), ExchangeHelper.getContentType(exchange));
+    }
+}
+

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java (added)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http.helper;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Helper class to help wrapping content into GZIP input and output streams.
+ */
+public final class GZIPHelper {
+
+    private GZIPHelper() {
+    }
+    
+    public static InputStream toGZIPInputStream(String contentEncoding, InputStream in) throws IOException {
+        if (isGzip(contentEncoding)) {
+            return new GZIPInputStream(in);
+        } else {
+            return in;
+        }
+    }
+
+    public static InputStream toGZIPInputStream(String contentEncoding, byte[] data) throws IOException {
+        if (isGzip(contentEncoding)) {
+            ByteArrayOutputStream os = null;
+            GZIPOutputStream gzip = null;
+            try {
+                os = new ByteArrayOutputStream();
+                gzip = new GZIPOutputStream(os);
+                gzip.write(data);
+                gzip.finish();
+                return new ByteArrayInputStream(os.toByteArray());
+            } finally {
+                ObjectHelper.close(gzip, "gzip", null);
+                ObjectHelper.close(os, "byte array", null);
+            }
+        } else {
+            return new ByteArrayInputStream(data);
+        }
+    }
+
+    public static byte[] compressGZIP(byte[] data) throws IOException {
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        GZIPOutputStream gzip = new GZIPOutputStream(os);
+        try {
+            gzip.write(data);
+            gzip.finish();
+            return os.toByteArray();
+        } finally {
+            gzip.close();
+            os.close();
+        }
+    }
+
+    public static boolean isGzip(Message message) {
+        return isGzip(message.getHeader(Exchange.CONTENT_ENCODING, String.class));
+    }
+
+    public static boolean isGzip(String header) {
+        return header != null && header.toLowerCase().contains("gzip");
+    }
+
+}

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java (added)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http.helper;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.http.HttpEndpoint;
+import org.apache.camel.component.http.HttpMethods;
+
+/**
+ * Helper methods for HTTP producers.
+ *
+ * @version $Revision$
+ */
+public final class HttpProducerHelper {
+
+    private HttpProducerHelper() {
+    }
+
+    /**
+     * Creates the URL to invoke.
+     *
+     * @param exchange the exchange
+     * @param endpoint the endpoint
+     * @return the URL to invoke
+     */
+    public static String createURL(Exchange exchange, HttpEndpoint endpoint) {
+        String uri = null;
+        if (!(endpoint.isBridgeEndpoint())) {
+            uri = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
+        }
+        if (uri == null) {
+            uri = endpoint.getHttpUri().toString();
+        }
+
+        // append HTTP_PATH to HTTP_URI if it is provided in the header
+        // when the endpoint is not working as a bridge
+        String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
+        if (path != null) {
+            // make sure that there is exactly one "/" between HTTP_URI and
+            // HTTP_PATH
+            if (!uri.endsWith("/")) {
+                uri = uri + "/";
+            }
+            if (path.startsWith("/")) {
+                path = path.substring(1);
+            }
+            uri = uri.concat(path);
+        }
+
+        return uri;
+    }
+
+    /**
+     * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
+     *
+     * @param exchange  the exchange
+     * @return the created method
+     */
+    public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) {
+        // is a query string provided in the endpoint URI or in a header (header
+        // overrules endpoint)
+        String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
+        if (queryString == null) {
+            queryString = endpoint.getHttpUri().getQuery();
+        }
+
+        // compute what method to use either GET or POST
+        HttpMethods answer;
+        HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
+        if (m != null) {
+            // always use what end-user provides in a header
+            answer = m;
+        } else if (queryString != null) {
+            // if a query string is provided then use GET
+            answer = HttpMethods.GET;
+        } else {
+            // fallback to POST if we have payload, otherwise GET
+            answer = hasPayload ? HttpMethods.POST : HttpMethods.GET;
+        }
+
+        return answer;
+    }
+
+}

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpProducerHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java (added)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http.helper;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Subclass of ByteArrayOutputStream that allows creation of a
+ * ByteArrayInputStream directly without creating a copy of the byte[].
+ *
+ * Also, on "toByteArray()" it truncates it's buffer to the current size
+ * and returns the new buffer directly.  Multiple calls to toByteArray()
+ * will return the exact same byte[] unless a write is called in between.
+ *
+ * Note: once the InputStream is created, the output stream should
+ * no longer be used.  In particular, make sure not to call reset()
+ * and then write as that may overwrite the data that the InputStream
+ * is using.
+ */
+public class LoadingByteArrayOutputStream extends ByteArrayOutputStream {
+
+    public LoadingByteArrayOutputStream() {
+        super(1024);
+    }
+
+    public LoadingByteArrayOutputStream(int size) {
+        super(size);
+    }
+
+    public ByteArrayInputStream createInputStream() {
+        return new ByteArrayInputStream(buf, 0, count);
+    }
+
+    public byte[] toByteArray() {
+        if (count != buf.length) {
+            buf = super.toByteArray();
+        }
+        return buf;
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/package.html
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/package.html?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/package.html (added)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/package.html Sat Apr 10 10:49:33 2010
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+   
+    http://www.apache.org/licenses/LICENSE-2.0
+   
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Defines the <a href="http://activemq.apache.org/camel/http.html">HTTP Component</a>
+
+</body>
+</html>

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/package.html
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/package.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: camel/trunk/components/camel-http/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/resources/META-INF/LICENSE.txt?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-http/src/main/resources/META-INF/LICENSE.txt Sat Apr 10 10:49:33 2010
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Propchange: camel/trunk/components/camel-http/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-http/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/resources/META-INF/NOTICE.txt?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-http/src/main/resources/META-INF/NOTICE.txt Sat Apr 10 10:49:33 2010
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Propchange: camel/trunk/components/camel-http/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/main/resources/META-INF/NOTICE.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter (added)
+++ camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter Sat Apr 10 10:49:33 2010
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.camel.component.http
\ No newline at end of file

Added: camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/http
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/http?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/http (added)
+++ camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/http Sat Apr 10 10:49:33 2010
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class=org.apache.camel.component.http.HttpComponent

Added: camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/https
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/https?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/https (added)
+++ camel/trunk/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/https Sat Apr 10 10:49:33 2010
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class=org.apache.camel.component.http.HttpComponent

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import java.util.List;
+import java.util.Map;
+
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class HttpGetTest extends CamelTestSupport {
+    protected String expectedText = "activemq";
+    
+    @Test
+    @Ignore("ignore online tests, will be improved in Camel 2.3")
+    public void testHttpGet() throws Exception {
+        MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
+        mockEndpoint.expectedMessageCount(1);
+
+        template.sendBody("direct:start", null);
+
+        mockEndpoint.assertIsSatisfied();
+        List<Exchange> list = mockEndpoint.getReceivedExchanges();
+        Exchange exchange = list.get(0);
+        assertNotNull("exchange", exchange);
+
+        Message in = exchange.getIn();
+        assertNotNull("in", in);
+
+        Map<String, Object> headers = in.getHeaders();
+
+        log.debug("Headers: " + headers);
+        checkHeaders(headers);       
+
+        String body = in.getBody(String.class);
+
+        log.debug("Body: " + body);
+        assertNotNull("Should have a body!", body);
+        assertTrue("body should contain: " + expectedText, body.contains(expectedText));
+    }
+
+    protected void checkHeaders(Map<String, Object> headers) {
+        assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
+        
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start").setHeader(Exchange.HTTP_QUERY, constant("hl=en&q=activemq"))
+                    .to("http://www.google.com/search").to("mock:results");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithHeadersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithHeadersTest.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithHeadersTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithHeadersTest.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Before;
+
+public class HttpGetWithHeadersTest extends HttpGetTest {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                    .setHeader("TestHeader", constant("test"))
+                    .setHeader("Content-Length", constant(0))
+                    .setHeader("Accept-Language", constant("pl"))
+                    .to("http://www.google.com/search")
+                    .to("mock:results");
+            }
+        };
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        // "Szukaj" is "Search" in polish language
+        expectedText = "Szukaj";
+        super.setUp();
+    }
+    
+    protected void checkHeaders(Map<String, Object> headers) {
+        assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
+        assertEquals("Should get the TestHeader", "test", headers.get("TestHeader"));
+    }
+
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithHeadersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithHeadersTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class HttpGetWithPathHeaderTest extends HttpGetTest {
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                    .setHeader(Exchange.HTTP_PATH, constant("search"))
+                    .setHeader(Exchange.HTTP_QUERY, constant("hl=en&q=activemq"))
+                    .to("http://www.google.com").to("mock:results");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithQueryParamsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithQueryParamsTest.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithQueryParamsTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithQueryParamsTest.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.junit.Before;
+
+/**
+ * @version $Revision$ 
+ */
+public class HttpGetWithQueryParamsTest extends HttpGetTest {
+    
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        expectedText = "activemq.apache.org";
+    }
+
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithQueryParamsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithQueryParamsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class HttpHeaderFilterStrategyTest extends CamelTestSupport {
+
+    private HttpHeaderFilterStrategy filter;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        filter = new HttpHeaderFilterStrategy();
+        exchange = new DefaultExchange(new DefaultCamelContext());
+    }
+
+    @Test
+    public void applyFilterToExternalHeaders() {
+        assertFalse(filter.applyFilterToExternalHeaders("content-length", 10, exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Content-Length", 10, exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("content-type", "text/xml", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Content-Type", "text/xml", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("cache-control", "no-cache", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Cache-Control", "no-cache", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("connection", "close", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Connection", "close", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("date", "close", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Data", "close", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("pragma", "no-cache", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Pragma", "no-cache", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("trailer", "Max-Forwards", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Trailer", "Max-Forwards", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("transfer-encoding", "chunked", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Transfer-Encoding", "chunked", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("upgrade", "HTTP/2.0", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Upgrade", "HTTP/2.0", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("via", "1.1 nowhere.com", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Via", "1.1 nowhere.com", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("warning", "199 Miscellaneous warning", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Warning", "199 Miscellaneous warning", exchange));
+
+        assertFalse(filter.applyFilterToExternalHeaders("CamelHeader", "test", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("org.apache.camel.header", "test", exchange));
+
+        assertFalse(filter.applyFilterToExternalHeaders("notFilteredHeader", "test", exchange));
+    }
+
+    @Test
+    public void applyFilterToCamelHeaders() {
+        assertTrue(filter.applyFilterToCamelHeaders("content-length", 10, exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Content-Length", 10, exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("content-type", "text/xml", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Content-Type", "text/xml", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("cache-control", "no-cache", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Cache-Control", "no-cache", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("connection", "close", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Connection", "close", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("date", "close", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Date", "close", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("pragma", "no-cache", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Pragma", "no-cache", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("trailer", "Max-Forwards", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Trailer", "Max-Forwards", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("transfer-encoding", "chunked", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Transfer-Encoding", "chunked", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("upgrade", "HTTP/2.0", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Upgrade", "HTTP/2.0", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("via", "1.1 nowhere.com", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Via", "1.1 nowhere.com", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("warning", "199 Miscellaneous warning", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Warning", "199 Miscellaneous warning", exchange));
+
+        assertTrue(filter.applyFilterToCamelHeaders("CamelHeader", "test", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("org.apache.camel.header", "test", exchange));
+
+        assertFalse(filter.applyFilterToCamelHeaders("notFilteredHeader", "test", exchange));
+    }
+
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.apache.camel.component.http.HttpMethods.POST;
+
+/**
+ * Unit test of invalid configuration
+ */
+public class HttpInvalidConfigurationTest extends CamelTestSupport {
+
+    @Before
+    public void setUp() throws Exception {
+        try {
+            super.setUp();
+            fail("Should have thrown ResolveEndpointFailedException");
+        } catch (FailedToCreateRouteException e) {
+            ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
+            assertTrue(cause.getMessage().endsWith("You have duplicated the http(s) protocol."));
+        }
+    }
+
+    @Test
+    public void testInvalidHostConfiguration() {
+        // dummy
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start").setHeader(Exchange.HTTP_METHOD, POST).to("http://http://www.google.com");
+            }
+        };
+    }
+
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidConfigurationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.apache.camel.component.http.HttpMethods.POST;
+
+/**
+ * Unit test of invalid configuration
+ */
+public class HttpInvalidHttpClientConfigurationTest extends CamelTestSupport {
+
+    @Before
+    public void setUp() throws Exception {
+        try {
+            super.setUp();
+            fail("Should have thrown ResolveEndpointFailedException");
+        } catch (FailedToCreateRouteException e) {
+            ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
+            assertTrue(cause.getMessage().endsWith("Unknown parameters=[{xxx=true}]"));
+        }
+    }
+
+    @Test
+    public void testInvalidHostConfiguration() {
+        // dummy
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start").setHeader(Exchange.HTTP_METHOD, POST).to("http://www.google.com?httpClient.xxx=true");
+            }
+        };
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInvalidHttpClientConfigurationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java?rev=932690&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java (added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java Sat Apr 10 10:49:33 2010
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.apache.camel.component.http.HttpMethods.GET;
+import static org.apache.camel.component.http.HttpMethods.POST;
+
+
+public class HttpPostWithBodyTest extends CamelTestSupport {
+    protected String expectedText = "Method Not Allowed";
+
+    @Ignore
+    @Test
+    public void testHttpPostWithError() throws Exception {
+
+        Exchange exchange = template.send("direct:start", new Processor() {
+
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("q=test1234");
+            }
+
+        });
+
+        assertNotNull("exchange", exchange);
+        assertTrue("The exchange should be failed", exchange.isFailed());
+
+        // get the ex message
+        HttpOperationFailedException exception = (HttpOperationFailedException)exchange.getException();
+        assertNotNull("exception", exception);
+
+        int statusCode = exception.getStatusCode();
+        assertTrue("The response code should not be 200", statusCode != 200);
+
+        String reason = exception.getStatusText();
+
+        assertNotNull("Should have a body!", reason);
+
+        assertTrue("body should contain: " + expectedText, reason.contains(expectedText));
+
+    }
+
+    @Ignore
+    @Test
+    public void testHttpPostRecovery() throws Exception {
+
+        MockEndpoint mockResult = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
+        MockEndpoint mockRecovery = resolveMandatoryEndpoint("mock:recovery", MockEndpoint.class);
+        mockRecovery.expectedMessageCount(1);
+        mockResult.expectedMessageCount(0);
+
+        template.send("direct:reset", new Processor() {
+
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("q=activemq");
+            }
+
+        });
+
+        mockRecovery.assertIsSatisfied();
+        mockResult.assertIsSatisfied();
+        List<Exchange> list = mockRecovery.getReceivedExchanges();
+        Exchange exchange = list.get(0);
+        assertNotNull("exchange", exchange);
+
+        Message in = exchange.getIn();
+        assertNotNull("in", in);
+
+        Map<String, Object> headers = in.getHeaders();
+
+        log.debug("Headers: " + headers);
+        assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
+
+        String body = in.getBody(String.class);
+
+        log.debug("Body: " + body);
+        assertNotNull("Should have a body!", body);
+        assertTrue("body should contain: <html>", body.contains("<html>"));
+
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start").setHeader(Exchange.HTTP_METHOD, POST).to("http://www.google.com");
+                from("direct:reset")
+                    .errorHandler(deadLetterChannel("direct:recovery").maximumRedeliveries(1))
+                    .setHeader(Exchange.HTTP_METHOD, POST).to("http://www.google.com").to("mock:result");
+                from("direct:recovery").setHeader(Exchange.HTTP_METHOD, GET).to("http://www.google.com").to("mock:recovery");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date