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

[01/24] camel git commit: camel-http-common - as a common module

Repository: camel
Updated Branches:
  refs/heads/master 2a93d6e09 -> 5b63cf5a3


http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/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
new file mode 100644
index 0000000..d22ee6b
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHelper.java
@@ -0,0 +1,429 @@
+/**
+ * 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.http.common;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.RuntimeExchangeException;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.util.CamelObjectInputStream;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class HttpHelper {
+
+    private static final Logger LOG = LoggerFactory.getLogger(HttpHelper.class);
+
+    private HttpHelper() {
+        // Helper class
+    }
+
+    @SuppressWarnings("deprecation")
+    public static void setCharsetFromContentType(String contentType, Exchange exchange) {
+        if (contentType != null) {
+            // find the charset and set it to the Exchange
+            int index = contentType.indexOf("charset=");
+            if (index > 0) {
+                String charset = contentType.substring(index + 8);
+                exchange.setProperty(Exchange.CHARSET_NAME, IOConverter.normalizeCharset(charset));
+            }
+        }
+    }
+
+    public static String getCharsetFromContentType(String contentType) {
+        if (contentType != null) {
+            // find the charset and set it to the Exchange
+            int index = contentType.indexOf("charset=");
+            if (index > 0) {
+                String charset = contentType.substring(index + 8);
+                // there may be another parameter after a semi colon, so skip that
+                if (charset.contains(";")) {
+                    charset = ObjectHelper.before(charset, ";");
+                }
+                return IOHelper.normalizeCharset(charset);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Writes the given object as response body to the servlet response
+     * <p/>
+     * The content type will be set to {@link HttpConstants#CONTENT_TYPE_JAVA_SERIALIZED_OBJECT}
+     *
+     * @param response servlet response
+     * @param target   object to write
+     * @throws IOException is thrown if error writing
+     */
+    public static void writeObjectToServletResponse(ServletResponse response, Object target) throws IOException {
+        response.setContentType(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
+        writeObjectToStream(response.getOutputStream(), target);
+    }
+
+    /**
+     * Writes the given object as response body to the output stream
+     *
+     * @param stream output stream
+     * @param target   object to write
+     * @throws IOException is thrown if error writing
+     */
+    public static void writeObjectToStream(OutputStream stream, Object target) throws IOException {
+        ObjectOutputStream oos = new ObjectOutputStream(stream);
+        oos.writeObject(target);
+        oos.flush();
+        IOHelper.close(oos);
+    }
+
+    /**
+     * Deserializes the input stream to a Java object
+     *
+     * @param is input stream for the Java object
+     * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
+     * @throws ClassNotFoundException is thrown if class not found
+     * @throws IOException can be thrown
+     * @deprecated Camel 3.0 
+     * Please use the one which has the parameter of camel context
+     */
+    @Deprecated
+    public static Object deserializeJavaObjectFromStream(InputStream is) throws ClassNotFoundException, IOException {
+        return deserializeJavaObjectFromStream(is, null);
+    }
+    
+    /**
+     * Deserializes the input stream to a Java object
+     *
+     * @param is input stream for the Java object
+     * @param context the camel context which could help us to apply the customer classloader
+     * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
+     * @throws ClassNotFoundException is thrown if class not found
+     * @throws IOException can be thrown
+     */
+    public static Object deserializeJavaObjectFromStream(InputStream is, CamelContext context) throws ClassNotFoundException, IOException {
+        if (is == null) {
+            return null;
+        }
+
+        Object answer = null;
+        ObjectInputStream ois = new CamelObjectInputStream(is, context);
+        try {
+            answer = ois.readObject();
+        } finally {
+            IOHelper.close(ois);
+        }
+
+        return answer;
+    }
+
+    /**
+     * Reads the response body from the given http servlet request.
+     *
+     * @param request  http servlet request
+     * @param exchange the exchange
+     * @return the request body, can be <tt>null</tt> if no body
+     * @throws IOException is thrown if error reading response body
+     */
+    public static Object readRequestBodyFromServletRequest(HttpServletRequest request, Exchange exchange) throws IOException {
+        InputStream is = HttpConverter.toInputStream(request, exchange);
+        return readResponseBodyFromInputStream(is, exchange);
+    }
+    
+    /**
+     * Reads the response body from the given input stream.
+     *
+     * @param is       the input stream
+     * @param exchange the exchange
+     * @return the response body, can be <tt>null</tt> if no body
+     * @throws IOException is thrown if error reading response body
+     */
+    public static Object readRequestBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
+        if (is == null) {
+            return null;
+        }
+        boolean disableStreamCaching = false;
+        // Just take the consideration of the setting of Camel Context StreamCaching
+        if (exchange.getContext() instanceof DefaultCamelContext) { 
+            DefaultCamelContext context = (DefaultCamelContext) exchange.getContext();
+            disableStreamCaching = !context.isStreamCaching();
+        }
+        // convert the input stream to StreamCache if the stream cache is not disabled
+        if (exchange.getProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, disableStreamCaching, Boolean.class)) {
+            return is;
+        } else {
+            CachedOutputStream cos = new CachedOutputStream(exchange);
+            IOHelper.copyAndCloseInput(is, cos);
+            return cos.newStreamCache();
+        }
+    }
+
+
+    /**
+     * Reads the response body from the given input stream.
+     *
+     * @param is       the input stream
+     * @param exchange the exchange
+     * @return the response body, can be <tt>null</tt> if no body
+     * @throws IOException is thrown if error reading response body
+     */
+    public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
+        if (is == null) {
+            return null;
+        }
+        // convert the input stream to StreamCache if the stream cache is not disabled
+        if (exchange.getProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.FALSE, Boolean.class)) {
+            return is;
+        } else {
+            CachedOutputStream cos = new CachedOutputStream(exchange);
+            IOHelper.copyAndCloseInput(is, cos);
+            return cos.newStreamCache();
+        }
+    }
+
+    /**
+     * Creates the URL to invoke.
+     *
+     * @param exchange the exchange
+     * @param endpoint the endpoint
+     * @return the URL to invoke
+     */
+    public static String createURL(Exchange exchange, HttpCommonEndpoint endpoint) {
+        String uri = null;
+        if (!(endpoint.isBridgeEndpoint())) {
+            uri = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
+        }
+        if (uri == null) {
+            uri = endpoint.getHttpUri().toASCIIString();
+        }
+
+        // resolve placeholders in uri
+        try {
+            uri = exchange.getContext().resolvePropertyPlaceholders(uri);
+        } catch (Exception e) {
+            throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uri, exchange, e);
+        }
+
+        // append HTTP_PATH to HTTP_URI if it is provided in the header
+        String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
+        // NOW the HTTP_PATH is just related path, we don't need to trim it
+        if (path != null) {
+            if (path.startsWith("/")) {
+                path = path.substring(1);
+            }
+            if (path.length() > 0) {
+                // make sure that there is exactly one "/" between HTTP_URI and
+                // HTTP_PATH
+                if (!uri.endsWith("/")) {
+                    uri = uri + "/";
+                }
+                uri = uri.concat(path);
+            }
+        }
+
+        // ensure uri is encoded to be valid
+        uri = UnsafeUriCharactersEncoder.encodeHttpURI(uri);
+
+        return uri;
+    }
+
+    /**
+     * Creates the URI to invoke.
+     *
+     * @param exchange the exchange
+     * @param url      the url to invoke
+     * @param endpoint the endpoint
+     * @return the URI to invoke
+     */
+    public static URI createURI(Exchange exchange, String url, HttpCommonEndpoint endpoint) throws URISyntaxException {
+        URI uri = new URI(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 = endpoint.getHttpUri().getRawQuery();
+        }
+        // We should user the query string from the HTTP_URI header
+        if (queryString == null) {
+            queryString = uri.getRawQuery();
+        }
+        if (queryString != null) {
+            // need to encode query string
+            queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
+            uri = URISupport.createURIWithQuery(uri, queryString);
+        }
+        return uri;
+    }
+
+    /**
+     * Appends the key/value to the headers.
+     * <p/>
+     * This implementation supports keys with multiple values. In such situations the value
+     * will be a {@link java.util.List} that contains the multiple values.
+     *
+     * @param headers  headers
+     * @param key      the key
+     * @param value    the value
+     */
+    @SuppressWarnings("unchecked")
+    public static void appendHeader(Map<String, Object> headers, String key, Object value) {
+        if (headers.containsKey(key)) {
+            Object existing = headers.get(key);
+            List<Object> list;
+            if (existing instanceof List) {
+                list = (List<Object>) existing;
+            } else {
+                list = new ArrayList<Object>();
+                list.add(existing);
+            }
+            list.add(value);
+            value = list;
+        }
+
+        headers.put(key, value);
+    }
+
+    /**
+     * Extracts the parameter value.
+     * <p/>
+     * This implementation supports HTTP multi value parameters which
+     * is based on the syntax of <tt>[value1, value2, value3]</tt> by returning
+     * a {@link List} containing the values.
+     * <p/>
+     * If the value is not a HTTP mulit value the value is returned as is.
+     *
+     * @param value the parameter value
+     * @return the extracted parameter value, see more details in javadoc.
+     */
+    public static Object extractHttpParameterValue(String value) {
+        if (value == null || ObjectHelper.isEmpty(value)) {
+            return value;
+        }
+
+        // trim value before checking for multiple parameters
+        String trimmed = value.trim();
+
+        if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
+            // remove the [ ] markers
+            trimmed = trimmed.substring(1, trimmed.length() - 1);
+            List<String> list = new ArrayList<String>();
+            String[] values = trimmed.split(",");
+            for (String s : values) {
+                list.add(s.trim());
+            }
+            return list;
+        }
+
+        return value;
+    }
+
+    /**
+     * Processes any custom {@link org.apache.camel.http.common.UrlRewrite}.
+     *
+     * @param exchange    the exchange
+     * @param url         the url
+     * @param endpoint    the http endpoint
+     * @param producer    the producer
+     * @return            the rewritten url, or <tt>null</tt> to use original url
+     * @throws Exception is thrown if any error during rewriting url
+     */
+    public static String urlRewrite(Exchange exchange, String url, HttpCommonEndpoint endpoint, Producer producer) throws Exception {
+        String answer = null;
+
+        String relativeUrl;
+        if (endpoint.getUrlRewrite() != null) {
+            // we should use the relative path if possible
+            String baseUrl;
+            relativeUrl = endpoint.getHttpUri().toASCIIString();
+            if (url.startsWith(relativeUrl)) {
+                baseUrl = url.substring(0, relativeUrl.length());
+                relativeUrl = url.substring(relativeUrl.length());
+            } else {
+                baseUrl = null;
+                relativeUrl = url;
+            }
+            // mark it as null if its empty
+            if (ObjectHelper.isEmpty(relativeUrl)) {
+                relativeUrl = null;
+            }
+
+            String newUrl;
+            if (endpoint.getUrlRewrite() instanceof HttpServletUrlRewrite) {
+                // its servlet based, so we need the servlet request
+                HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
+                if (request == null) {
+                    HttpMessage msg = exchange.getIn(HttpMessage.class);
+                    if (msg != null) {
+                        request = msg.getRequest();
+                    }
+                }
+                if (request == null) {
+                    throw new IllegalArgumentException("UrlRewrite " + endpoint.getUrlRewrite() + " requires the message body to be a"
+                            + "HttpServletRequest instance, but was: " + ObjectHelper.className(exchange.getIn().getBody()));
+                }
+                // we need to adapt the context-path to be the path from the endpoint, if it came from a http based endpoint
+                // as eg camel-jetty have hardcoded context-path as / for all its servlets/endpoints
+                // we have the actual context-path stored as a header with the key CamelServletContextPath
+                String contextPath = exchange.getIn().getHeader("CamelServletContextPath", String.class);
+                request = new UrlRewriteHttpServletRequestAdapter(request, contextPath);
+                newUrl = ((HttpServletUrlRewrite) endpoint.getUrlRewrite()).rewrite(url, relativeUrl, producer, request);
+            } else {
+                newUrl = endpoint.getUrlRewrite().rewrite(url, relativeUrl, producer);
+            }
+
+            if (ObjectHelper.isNotEmpty(newUrl) && !newUrl.equals(url)) {
+                // we got a new url back, that can either be a new absolute url
+                // or a new relative url
+                if (newUrl.startsWith("http:") || newUrl.startsWith("https:")) {
+                    answer = newUrl;
+                } else if (baseUrl != null) {
+                    // avoid double // when adding the urls
+                    if (baseUrl.endsWith("/") && newUrl.startsWith("/")) {
+                        answer = baseUrl + newUrl.substring(1);
+                    } else {
+                        answer = baseUrl + newUrl;
+                    }
+                } else {
+                    // use the new url as is
+                    answer = newUrl;
+                }
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Using url rewrite to rewrite from url {} to {} -> {}",
+                            new Object[]{relativeUrl != null ? relativeUrl : url, newUrl, answer});
+                }
+            }
+        }
+
+        return answer;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMessage.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMessage.java
new file mode 100644
index 0000000..b2f4527
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMessage.java
@@ -0,0 +1,81 @@
+/**
+ * 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.http.common;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultMessage;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * @version 
+ */
+public class HttpMessage extends DefaultMessage {
+
+    private HttpServletRequest request;
+    private HttpServletResponse response;
+
+    public HttpMessage(Exchange exchange, HttpServletRequest request, HttpServletResponse response) {
+        setExchange(exchange);
+        this.request = request;
+        this.response = response;
+        // Put the request and response into the message header
+        this.setHeader(Exchange.HTTP_SERVLET_REQUEST, request);
+        this.setHeader(Exchange.HTTP_SERVLET_RESPONSE, response);
+        
+        // Check the setting of exchange
+        Boolean flag = exchange.getProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.class);
+        if (flag != null && flag) {
+            this.setHeader(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
+        }
+
+        // use binding to read the request allowing end users to use their
+        // implementation of the binding
+        getEndpoint().getBinding().readRequest(request, this);
+    }
+
+    public HttpServletRequest getRequest() {
+        return request;
+    }
+
+    public HttpServletResponse getResponse() {
+        return response;
+    }
+
+    @Override
+    protected Object createBody() {
+        try {
+            return getEndpoint().getBinding().parseBody(this);
+        } catch (IOException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
+    
+    private HttpCommonEndpoint getEndpoint() {
+        return (HttpCommonEndpoint) getExchange().getFromEndpoint();
+    }
+
+    @Override
+    public String toString() {
+        // do not use toString on HTTP message
+        return "HttpMessage@" + ObjectHelper.getIdentityHashCode(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpOperationFailedException.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpOperationFailedException.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpOperationFailedException.java
new file mode 100644
index 0000000..2008658
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpOperationFailedException.java
@@ -0,0 +1,75 @@
+/**
+ * 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.http.common;
+
+import java.util.Map;
+
+import org.apache.camel.CamelException;
+import org.apache.camel.util.ObjectHelper;
+
+public class HttpOperationFailedException extends CamelException {
+    private static final long serialVersionUID = -8721487434390572634L;
+    private final String uri;
+    private final String redirectLocation;
+    private final int statusCode;
+    private final String statusText;
+    private final Map<String, String> responseHeaders;
+    private final String responseBody;
+
+    public HttpOperationFailedException(String uri, int statusCode, String statusText, String location, Map<String, String> responseHeaders, String responseBody) {
+        super("HTTP operation failed invoking " + uri + " with statusCode: " + statusCode + (location != null ? ", redirectLocation: " + location : ""));
+        this.uri = uri;
+        this.statusCode = statusCode;
+        this.statusText = statusText;
+        this.redirectLocation = location;
+        this.responseHeaders = responseHeaders;
+        this.responseBody = responseBody;
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    public boolean isRedirectError() {
+        return statusCode >= 300 && statusCode < 400;
+    }
+
+    public boolean hasRedirectLocation() {
+        return ObjectHelper.isNotEmpty(redirectLocation);
+    }
+
+    public String getRedirectLocation() {
+        return redirectLocation;
+    }
+
+    public int getStatusCode() {
+        return statusCode;
+    }
+
+    public String getStatusText() {
+        return statusText;
+    }
+
+    public Map<String, String> getResponseHeaders() {
+        return responseHeaders;
+    }
+
+    public String getResponseBody() {
+        return responseBody;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpProtocolHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpProtocolHeaderFilterStrategy.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpProtocolHeaderFilterStrategy.java
new file mode 100644
index 0000000..bf09881
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpProtocolHeaderFilterStrategy.java
@@ -0,0 +1,87 @@
+/**
+ * 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.http.common;
+
+import org.apache.camel.impl.DefaultHeaderFilterStrategy;
+
+public class HttpProtocolHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
+    
+    public HttpProtocolHeaderFilterStrategy() {
+        initialize();  
+    }
+
+    // Just add the http headers here 
+    protected void initialize() {
+        getInFilter().add("host");
+        
+        getInFilter().add("content-encoding");
+        getInFilter().add("content-language");
+        getInFilter().add("content-location");
+        getInFilter().add("content-md5");
+        getInFilter().add("content-length");
+        getInFilter().add("content-type");
+        getInFilter().add("content-range");
+        
+        getInFilter().add("dav");
+        getInFilter().add("depth");
+        getInFilter().add("destination");
+        getInFilter().add("etag");
+        getInFilter().add("expect");
+        getInFilter().add("expires");
+        getInFilter().add("from");
+        getInFilter().add("if");
+        getInFilter().add("if-match");
+        getInFilter().add("if-modified-since");
+        getInFilter().add("if-none-match");
+        getInFilter().add("if-range");
+        getInFilter().add("if-unmodified-since");
+        getInFilter().add("last-modified");
+        getInFilter().add("location");
+        getInFilter().add("lock-token");
+        getInFilter().add("max-forwards");
+        getInFilter().add("overwrite");
+        getInFilter().add("pragma");
+        getInFilter().add("proxy-authenticate");
+        getInFilter().add("proxy-authorization");
+        getInFilter().add("range");
+        getInFilter().add("referer");
+        getInFilter().add("retry-after");
+        getInFilter().add("server");
+        getInFilter().add("status-uri");
+        getInFilter().add("te");
+        getInFilter().add("timeout");
+      
+        getInFilter().add("user-agent");
+        getInFilter().add("vary");
+  
+        getInFilter().add("www-authenticate");
+        
+        // Add the filter for the Generic Message header
+        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
+        getInFilter().add("cache-control");
+        getInFilter().add("connection");
+        getInFilter().add("date");
+        getInFilter().add("pragma");
+        getInFilter().add("trailer");
+        getInFilter().add("transfer-encoding");
+        getInFilter().add("upgrade");
+        getInFilter().add("via");
+        getInFilter().add("warning");
+               
+        setLowerCase(true);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletResolveConsumerStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletResolveConsumerStrategy.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletResolveConsumerStrategy.java
new file mode 100644
index 0000000..a48f4b6
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletResolveConsumerStrategy.java
@@ -0,0 +1,50 @@
+/**
+ * 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.http.common;
+
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * A default implementation of {@link org.apache.camel.http.common.ServletResolveConsumerStrategy}.
+ */
+public class HttpServletResolveConsumerStrategy implements ServletResolveConsumerStrategy {
+
+    @Override
+    public HttpConsumer resolve(HttpServletRequest request, Map<String, HttpConsumer> consumers) {
+        String path = request.getPathInfo();
+        if (path == null) {
+            return null;
+        }
+        HttpConsumer answer = consumers.get(path);
+
+        if (answer == null) {
+            for (String key : consumers.keySet()) {
+                //We need to look up the consumer path here
+                String consumerPath = consumers.get(key).getPath();
+                HttpConsumer consumer = consumers.get(key);
+                // Just make sure the we get the right consumer path first
+                if (consumerPath.equals(path) || (consumer.getEndpoint().isMatchOnUriPrefix() && path.startsWith(consumerPath))) {
+                    answer = consumers.get(key);
+                    break;
+                }
+            }
+        }
+        return answer;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletUrlRewrite.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletUrlRewrite.java
new file mode 100644
index 0000000..f6db8f1
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpServletUrlRewrite.java
@@ -0,0 +1,45 @@
+/**
+ * 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.http.common;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.camel.Producer;
+
+/**
+ * Extended {@link UrlRewrite} which leverages {@link HttpServletRequest}
+ * during the rewrite process.
+ * <p/>
+ * For example the camel-urlrewrite component supports
+ * {@link HttpServletUrlRewrite} implementations.
+ */
+public interface HttpServletUrlRewrite extends UrlRewrite {
+
+    /**
+     * Rewrite the url.
+     *
+     * @param url  the absolute url (eg with scheme://host:port/path?query)
+     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
+     *                    endpoint from the given producer.
+     * @param producer the producer to use the rewritten url
+     * @param request  the http servlet request
+     * @return the rewritten url, or <tt>null</tt> to use the original url
+     * @throws Exception is thrown if error rewriting the url
+     */
+    String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception;
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/ServletResolveConsumerStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/ServletResolveConsumerStrategy.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/ServletResolveConsumerStrategy.java
new file mode 100644
index 0000000..a16df19
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/ServletResolveConsumerStrategy.java
@@ -0,0 +1,37 @@
+/**
+ * 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.http.common;
+
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Strategy to resolve which consumer to service an incoming {@link javax.servlet.http.HttpServletRequest}.
+ */
+public interface ServletResolveConsumerStrategy {
+
+    /**
+     * Resolve the consumer to use.
+     *
+     * @param request   the http request
+     * @param consumers the map of registered consumers
+     * @return the consumer to service the request, or <tt>null</tt> if no match,
+     * which sends back a {@link javax.servlet.http.HttpServletResponse#SC_NOT_FOUND} to the client.
+     */
+    HttpConsumer resolve(HttpServletRequest request, Map<String, HttpConsumer> consumers);
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/UrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/UrlRewrite.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/UrlRewrite.java
new file mode 100644
index 0000000..1c44624
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/UrlRewrite.java
@@ -0,0 +1,41 @@
+/**
+ * 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.http.common;
+
+import org.apache.camel.Producer;
+
+/**
+ * Allows to plugin custom strategy for rewriting url.
+ * <p/>
+ * This allows for example to proxy http services and plugin a url rewrite
+ * strategy such as the <a href="http://camel.apache.org/urlrewrite">url-rewrite</a> component.
+ */
+public interface UrlRewrite {
+
+    /**
+     * Rewrite the url.
+     *
+     * @param url  the absolute url (eg with scheme://host:port/path?query)
+     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
+     *                    endpoint from the given producer.
+     * @param producer the producer to use the rewritten url
+     * @return the rewritten url, or <tt>null</tt> to use the original url
+     * @throws Exception is thrown if error rewriting the url
+     */
+    String rewrite(String url, String relativeUrl, Producer producer) throws Exception;
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/UrlRewriteHttpServletRequestAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/UrlRewriteHttpServletRequestAdapter.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/UrlRewriteHttpServletRequestAdapter.java
new file mode 100644
index 0000000..78b7b11
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/UrlRewriteHttpServletRequestAdapter.java
@@ -0,0 +1,49 @@
+/**
+ * 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.http.common;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+/**
+ * Special adapter when {@link org.apache.camel.http.common.HttpServletUrlRewrite} is in use,
+ * and the route started from came-jetty/camel-serlvet.
+ * <p/>
+ * This adapter ensures that we can control the context-path returned from the
+ * {@link javax.servlet.http.HttpServletRequest#getContextPath()} method.
+ * This allows us to ensure the context-path is based on the endpoint path, as the
+ * camel-jetty/camel-servlet server implementation uses the root ("/") context-path
+ * for all the servlets/endpoints.
+ */
+public final class UrlRewriteHttpServletRequestAdapter extends HttpServletRequestWrapper {
+
+    private final String contextPath;
+
+    /**
+     * Creates this adapter
+     * @param delegate    the real http servlet request to delegate.
+     * @param contextPath use to override and return this context-path
+     */
+    public UrlRewriteHttpServletRequestAdapter(HttpServletRequest delegate, String contextPath) {
+        super(delegate);
+        this.contextPath = contextPath;
+    }
+
+    public String getContextPath() {
+        return contextPath != null ? contextPath : super.getContextPath();
+    }
+}


[02/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: e51b7f8d9320072a64f60a23836c7ce15ffb45e7
Parents: 600063a
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 09:23:46 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:30 2015 +0200

----------------------------------------------------------------------
 .../camel/http/common/CamelFileDataSource.java  |  52 ++
 .../apache/camel/http/common/CamelServlet.java  | 247 ++++++++++
 .../camel/http/common/DefaultHttpBinding.java   | 494 +++++++++++++++++++
 .../apache/camel/http/common/HttpBinding.java   | 160 ++++++
 .../camel/http/common/HttpCommonComponent.java  |  75 +++
 .../camel/http/common/HttpCommonEndpoint.java   | 383 ++++++++++++++
 .../camel/http/common/HttpConfiguration.java    | 143 ++++++
 .../apache/camel/http/common/HttpConstants.java |  26 +
 .../apache/camel/http/common/HttpConsumer.java  |  80 +++
 .../apache/camel/http/common/HttpConverter.java |  98 ++++
 .../http/common/HttpHeaderFilterStrategy.java   |  49 ++
 .../apache/camel/http/common/HttpHelper.java    | 429 ++++++++++++++++
 .../apache/camel/http/common/HttpMessage.java   |  81 +++
 .../common/HttpOperationFailedException.java    |  75 +++
 .../HttpProtocolHeaderFilterStrategy.java       |  87 ++++
 .../HttpServletResolveConsumerStrategy.java     |  50 ++
 .../http/common/HttpServletUrlRewrite.java      |  45 ++
 .../common/ServletResolveConsumerStrategy.java  |  37 ++
 .../apache/camel/http/common/UrlRewrite.java    |  41 ++
 .../UrlRewriteHttpServletRequestAdapter.java    |  49 ++
 20 files changed, 2701 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelFileDataSource.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelFileDataSource.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelFileDataSource.java
new file mode 100644
index 0000000..8cb4c91
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelFileDataSource.java
@@ -0,0 +1,52 @@
+/**
+ * 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.http.common;
+
+import java.io.File;
+import javax.activation.FileDataSource;
+import javax.activation.FileTypeMap;
+
+public class CamelFileDataSource extends FileDataSource {
+    private final String fileName;
+    private FileTypeMap typeMap;
+
+    public CamelFileDataSource(File file, String fileName) {
+        super(file);
+        this.fileName = fileName;
+    }
+    
+    public String getContentType() {
+        if (typeMap == null) {
+            return FileTypeMap.getDefaultFileTypeMap().getContentType(fileName);
+        } else {
+            return typeMap.getContentType(fileName);
+        }
+    }
+    
+    public void setFileTypeMap(FileTypeMap map) {
+        typeMap = map;
+    }
+    
+    public String getName() {
+        if (fileName != null) {
+            return fileName;
+        } else {
+            return super.getName();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java
new file mode 100644
index 0000000..061bf47
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java
@@ -0,0 +1,247 @@
+/**
+ * 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.http.common;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.impl.DefaultExchange;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A servlet to use as a Camel route as entry.
+ */
+public class CamelServlet extends HttpServlet {
+    private static final long serialVersionUID = -7061982839117697829L;
+    protected final Logger log = LoggerFactory.getLogger(getClass());
+    
+    /**
+     *  We have to define this explicitly so the name can be set as we can not always be
+     *  sure that it is already set via the init method
+     */
+    private String servletName;
+
+    private ServletResolveConsumerStrategy servletResolveConsumerStrategy = new HttpServletResolveConsumerStrategy();
+    private final ConcurrentMap<String, HttpConsumer> consumers = new ConcurrentHashMap<String, HttpConsumer>();
+   
+    @Override
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        this.servletName = config.getServletName();
+    }
+
+    @Override
+    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        log.trace("Service: {}", request);
+
+        // Is there a consumer registered for the request.
+        HttpConsumer consumer = resolve(request);
+        if (consumer == null) {
+            log.debug("No consumer to service request {}", request);
+            response.sendError(HttpServletResponse.SC_NOT_FOUND);
+            return;
+        }       
+        
+        // are we suspended?
+        if (consumer.isSuspended()) {
+            log.debug("Consumer suspended, cannot service request {}", request);
+            response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
+            return;
+        }
+
+        // if its an OPTIONS request then return which method is allowed
+        if ("OPTIONS".equals(request.getMethod())) {
+            String s;
+            if (consumer.getEndpoint().getHttpMethodRestrict() != null) {
+                s = "OPTIONS," + consumer.getEndpoint().getHttpMethodRestrict();
+            } else {
+                // allow them all
+                s = "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,CONNECT,PATCH";
+            }
+            response.addHeader("Allow", s);
+            response.setStatus(HttpServletResponse.SC_OK);
+            return;
+        }
+        
+        if (consumer.getEndpoint().getHttpMethodRestrict() != null 
+            && !consumer.getEndpoint().getHttpMethodRestrict().contains(request.getMethod())) {
+            response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+            return;
+        }
+
+        if ("TRACE".equals(request.getMethod()) && !consumer.isTraceEnabled()) {
+            response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+            return;
+        }
+        
+        // create exchange and set data on it
+        Exchange exchange = new DefaultExchange(consumer.getEndpoint(), ExchangePattern.InOut);
+
+        if (consumer.getEndpoint().isBridgeEndpoint()) {
+            exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE);
+            exchange.setProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
+        }
+        if (consumer.getEndpoint().isDisableStreamCache()) {
+            exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE);
+        }
+
+        // we override the classloader before building the HttpMessage just in case the binding
+        // does some class resolution
+        ClassLoader oldTccl = overrideTccl(exchange);
+        HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
+        exchange.setIn(new HttpMessage(exchange, request, response));
+        // set context path as header
+        String contextPath = consumer.getEndpoint().getPath();
+        exchange.getIn().setHeader("CamelServletContextPath", contextPath);
+
+        String httpPath = (String)exchange.getIn().getHeader(Exchange.HTTP_PATH);
+        // here we just remove the CamelServletContextPath part from the HTTP_PATH
+        if (contextPath != null
+            && httpPath.startsWith(contextPath)) {
+            exchange.getIn().setHeader(Exchange.HTTP_PATH,
+                    httpPath.substring(contextPath.length()));
+        }
+
+        // we want to handle the UoW
+        try {
+            consumer.createUoW(exchange);
+        } catch (Exception e) {
+            log.error("Error processing request", e);
+            throw new ServletException(e);
+        }
+
+        try {
+            if (log.isTraceEnabled()) {
+                log.trace("Processing request for exchangeId: {}", exchange.getExchangeId());
+            }
+            // process the exchange
+            consumer.getProcessor().process(exchange);
+        } catch (Exception e) {
+            exchange.setException(e);
+        }
+
+        try {
+            // now lets output to the response
+            if (log.isTraceEnabled()) {
+                log.trace("Writing response for exchangeId: {}", exchange.getExchangeId());
+            }
+            Integer bs = consumer.getEndpoint().getResponseBufferSize();
+            if (bs != null) {
+                log.trace("Using response buffer size: {}", bs);
+                response.setBufferSize(bs);
+            }
+            consumer.getBinding().writeResponse(exchange, response);
+        } catch (IOException e) {
+            log.error("Error processing request", e);
+            throw e;
+        } catch (Exception e) {
+            log.error("Error processing request", e);
+            throw new ServletException(e);
+        } finally {
+            consumer.doneUoW(exchange);
+            restoreTccl(exchange, oldTccl);
+        }
+    }
+
+    /**
+     * @deprecated use {@link ServletResolveConsumerStrategy#resolve(javax.servlet.http.HttpServletRequest, java.util.Map)}
+     */
+    @Deprecated
+    protected HttpConsumer resolve(HttpServletRequest request) {
+        return getServletResolveConsumerStrategy().resolve(request, getConsumers());
+    }
+
+    public void connect(HttpConsumer consumer) {
+        log.debug("Connecting consumer: {}", consumer);
+        consumers.put(consumer.getEndpoint().getEndpointUri(), consumer);
+    }
+
+    public void disconnect(HttpConsumer consumer) {
+        log.debug("Disconnecting consumer: {}", consumer);
+        consumers.remove(consumer.getEndpoint().getEndpointUri());
+    }
+
+    public String getServletName() {
+        return servletName;
+    }
+
+    public void setServletName(String servletName) {
+        this.servletName = servletName;
+    }
+
+    public ServletResolveConsumerStrategy getServletResolveConsumerStrategy() {
+        return servletResolveConsumerStrategy;
+    }
+
+    public void setServletResolveConsumerStrategy(ServletResolveConsumerStrategy servletResolveConsumerStrategy) {
+        this.servletResolveConsumerStrategy = servletResolveConsumerStrategy;
+    }
+
+    public Map<String, HttpConsumer> getConsumers() {
+        return Collections.unmodifiableMap(consumers);
+    }
+
+    /**
+     * Override the Thread Context ClassLoader if need be.
+     *
+     * @param exchange
+     * @return old classloader if overridden; otherwise returns null
+     */
+    protected ClassLoader overrideTccl(final Exchange exchange) {
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoader appCtxCl = exchange.getContext().getApplicationContextClassLoader();
+        if (oldClassLoader == null || appCtxCl == null) {
+            return null;
+        }
+        
+        if (!oldClassLoader.equals(appCtxCl)) {
+            Thread.currentThread().setContextClassLoader(appCtxCl);
+            if (log.isTraceEnabled()) {
+                log.trace("Overrode TCCL for exchangeId {} to {} on thread {}", 
+                        new Object[] {exchange.getExchangeId(), appCtxCl, Thread.currentThread().getName()});
+            }
+            return oldClassLoader;
+        }
+        return null;
+    }
+
+    /**
+     * Restore the Thread Context ClassLoader if the old TCCL is not null.
+     */
+    protected void restoreTccl(final Exchange exchange, ClassLoader oldTccl) {
+        if (oldTccl == null) {
+            return;
+        }
+        Thread.currentThread().setContextClassLoader(oldTccl);
+        if (log.isTraceEnabled()) {
+            log.trace("Restored TCCL for exchangeId {} to {} on thread {}", 
+                    new String[] {exchange.getExchangeId(), oldTccl.toString(), Thread.currentThread().getName()});
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java
new file mode 100644
index 0000000..dcb3f20
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java
@@ -0,0 +1,494 @@
+/**
+ * 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.http.common;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.net.URLDecoder;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import javax.activation.DataHandler;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.Message;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.StreamCache;
+import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.util.GZIPHelper;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.MessageHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Binding between {@link HttpMessage} and {@link HttpServletResponse}.
+ * <p/>
+ * Uses by default the {@link org.apache.camel.http.common.HttpHeaderFilterStrategy}
+ */
+public class DefaultHttpBinding implements HttpBinding {
+
+    private static final Logger LOG = LoggerFactory.getLogger(DefaultHttpBinding.class);
+    private boolean useReaderForPayload;
+    private boolean eagerCheckContentAvailable;
+    private boolean transferException;
+    private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
+
+    public DefaultHttpBinding() {
+    }
+
+    @Deprecated
+    public DefaultHttpBinding(HeaderFilterStrategy headerFilterStrategy) {
+        this.headerFilterStrategy = headerFilterStrategy;
+    }
+
+    @Deprecated
+    public DefaultHttpBinding(HttpCommonEndpoint endpoint) {
+        this.headerFilterStrategy = endpoint.getHeaderFilterStrategy();
+        this.transferException = endpoint.isTransferException();
+    }
+
+    public void readRequest(HttpServletRequest request, HttpMessage message) {
+        LOG.trace("readRequest {}", request);
+        
+        // lets force a parse of the body and headers
+        message.getBody();
+        // populate the headers from the request
+        Map<String, Object> headers = message.getHeaders();
+        
+        //apply the headerFilterStrategy
+        Enumeration<?> names = request.getHeaderNames();
+        while (names.hasMoreElements()) {
+            String name = (String)names.nextElement();
+            String value = request.getHeader(name);
+            // use http helper to extract parameter value as it may contain multiple values
+            Object extracted = HttpHelper.extractHttpParameterValue(value);
+            // mapping the content-type
+            if (name.toLowerCase().equals("content-type")) {
+                name = Exchange.CONTENT_TYPE;
+            }
+            if (headerFilterStrategy != null
+                && !headerFilterStrategy.applyFilterToExternalHeaders(name, extracted, message.getExchange())) {
+                HttpHelper.appendHeader(headers, name, extracted);
+            }
+        }
+                
+        if (request.getCharacterEncoding() != null) {
+            headers.put(Exchange.HTTP_CHARACTER_ENCODING, request.getCharacterEncoding());
+            message.getExchange().setProperty(Exchange.CHARSET_NAME, request.getCharacterEncoding());
+        }
+
+        try {
+            populateRequestParameters(request, message);
+        } catch (Exception e) {
+            throw new RuntimeCamelException("Cannot read request parameters due " + e.getMessage(), e);
+        }
+        
+        Object body = message.getBody();
+        // reset the stream cache if the body is the instance of StreamCache
+        if (body instanceof StreamCache) {
+            ((StreamCache)body).reset();
+        }
+
+        // store the method and query and other info in headers as String types
+        headers.put(Exchange.HTTP_METHOD, request.getMethod());
+        headers.put(Exchange.HTTP_QUERY, request.getQueryString());
+        headers.put(Exchange.HTTP_URL, request.getRequestURL().toString());
+        headers.put(Exchange.HTTP_URI, request.getRequestURI());
+        headers.put(Exchange.HTTP_PATH, request.getPathInfo());
+        headers.put(Exchange.CONTENT_TYPE, request.getContentType());
+
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("HTTP method {}", request.getMethod());
+            LOG.trace("HTTP query {}", request.getQueryString());
+            LOG.trace("HTTP url {}", request.getRequestURL());
+            LOG.trace("HTTP uri {}", request.getRequestURI());
+            LOG.trace("HTTP path {}", request.getPathInfo());
+            LOG.trace("HTTP content-type {}", request.getContentType());
+        }
+
+        // if content type is serialized java object, then de-serialize it to a Java object
+        if (request.getContentType() != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(request.getContentType())) {
+            try {
+                InputStream is = message.getExchange().getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, body);
+                Object object = HttpHelper.deserializeJavaObjectFromStream(is, message.getExchange().getContext());
+                if (object != null) {
+                    message.setBody(object);
+                }
+            } catch (Exception e) {
+                throw new RuntimeCamelException("Cannot deserialize body to Java object", e);
+            }
+        }
+        
+        populateAttachments(request, message);
+    }
+
+    protected void populateRequestParameters(HttpServletRequest request, HttpMessage message) throws Exception {
+        //we populate the http request parameters without checking the request method
+        Map<String, Object> headers = message.getHeaders();
+        Enumeration<?> names = request.getParameterNames();
+        while (names.hasMoreElements()) {
+            String name = (String)names.nextElement();
+            // there may be multiple values for the same name
+            String[] values = request.getParameterValues(name);
+            LOG.trace("HTTP parameter {} = {}", name, values);
+
+            if (values != null) {
+                for (String value : values) {
+                    if (headerFilterStrategy != null
+                        && !headerFilterStrategy.applyFilterToExternalHeaders(name, value, message.getExchange())) {
+                        HttpHelper.appendHeader(headers, name, value);
+                    }
+                }
+            }
+        }
+
+        LOG.trace("HTTP method {} with Content-Type {}", request.getMethod(), request.getContentType());
+        Boolean flag = message.getHeader(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.class);
+        boolean skipWwwFormUrlEncoding =  flag != null ? flag : false; 
+        if (request.getMethod().equals("POST") && request.getContentType() != null
+                && request.getContentType().startsWith(HttpConstants.CONTENT_TYPE_WWW_FORM_URLENCODED)
+                && !skipWwwFormUrlEncoding) {
+            String charset = request.getCharacterEncoding();
+            if (charset == null) {
+                charset = "UTF-8";
+            }
+            // Push POST form params into the headers to retain compatibility with DefaultHttpBinding
+            String body = message.getBody(String.class);
+            if (ObjectHelper.isNotEmpty(body)) {
+                for (String param : body.split("&")) {
+                    String[] pair = param.split("=", 2);
+                    if (pair.length == 2) {
+                        String name = URLDecoder.decode(pair[0], charset);
+                        String value = URLDecoder.decode(pair[1], charset);
+                        if (headerFilterStrategy != null
+                                && !headerFilterStrategy.applyFilterToExternalHeaders(name, value, message.getExchange())) {
+                            HttpHelper.appendHeader(headers, name, value);
+                        }
+                    } else {
+                        throw new IllegalArgumentException("Invalid parameter, expected to be a pair but was " + param);
+                    }
+                }
+            }
+        }
+    }
+    
+    protected void populateAttachments(HttpServletRequest request, HttpMessage message) {
+        // check if there is multipart files, if so will put it into DataHandler
+        Enumeration<?> names = request.getAttributeNames();
+        while (names.hasMoreElements()) {
+            String name = (String) names.nextElement();
+            Object object = request.getAttribute(name);
+            LOG.trace("HTTP attachment {} = {}", name, object);
+            if (object instanceof File) {
+                String fileName = request.getParameter(name);
+                message.addAttachment(fileName, new DataHandler(new CamelFileDataSource((File)object, fileName)));
+            }
+        }
+    }
+
+    public void writeResponse(Exchange exchange, HttpServletResponse response) throws IOException {
+        Message target = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
+        if (exchange.isFailed()) {
+            if (exchange.getException() != null) {
+                doWriteExceptionResponse(exchange.getException(), response);
+            } else {
+                // it must be a fault, no need to check for the fault flag on the message
+                doWriteFaultResponse(target, response, exchange);
+            }
+        } else {
+            if (exchange.hasOut()) {
+                // just copy the protocol relates header if we do not have them
+                copyProtocolHeaders(exchange.getIn(), exchange.getOut());
+            }
+            doWriteResponse(target, response, exchange);
+        }
+    }
+
+    private void copyProtocolHeaders(Message request, Message response) {
+        if (request.getHeader(Exchange.CONTENT_ENCODING) != null) {
+            String contentEncoding = request.getHeader(Exchange.CONTENT_ENCODING, String.class);
+            response.setHeader(Exchange.CONTENT_ENCODING, contentEncoding);
+        }        
+        if (checkChunked(response, response.getExchange())) {
+            response.setHeader(Exchange.TRANSFER_ENCODING, "chunked");
+        }
+    }
+
+    public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException {
+        // 500 for internal server error
+        response.setStatus(500);
+
+        if (isTransferException()) {
+            // transfer the exception as a serialized java object
+            HttpHelper.writeObjectToServletResponse(response, exception);
+        } else {
+            // write stacktrace as plain text
+            response.setContentType("text/plain");
+            PrintWriter pw = response.getWriter();
+            exception.printStackTrace(pw);
+            pw.flush();
+        }
+    }
+
+    public void doWriteFaultResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
+        message.setHeader(Exchange.HTTP_RESPONSE_CODE, 500);
+        doWriteResponse(message, response, exchange);
+    }
+
+    public void doWriteResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
+        // set the status code in the response. Default is 200.
+        if (message.getHeader(Exchange.HTTP_RESPONSE_CODE) != null) {
+            int code = message.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
+            response.setStatus(code);
+        }
+        // set the content type in the response.
+        String contentType = MessageHelper.getContentType(message);
+        if (contentType != null) {
+            response.setContentType(contentType);
+        }
+
+        // append headers
+        // must use entrySet to ensure case of keys is preserved
+        for (Map.Entry<String, Object> entry : message.getHeaders().entrySet()) {
+            String key = entry.getKey();
+            Object value = entry.getValue();
+            // use an iterator as there can be multiple values. (must not use a delimiter)
+            final Iterator<?> it = ObjectHelper.createIterator(value, null);
+            while (it.hasNext()) {
+                String headerValue = exchange.getContext().getTypeConverter().convertTo(String.class, it.next());
+                if (headerValue != null && headerFilterStrategy != null
+                        && !headerFilterStrategy.applyFilterToCamelHeaders(key, headerValue, exchange)) {
+                    response.addHeader(key, headerValue);
+                }
+            }
+        }
+
+        // write the body.
+        if (message.getBody() != null) {
+            if (GZIPHelper.isGzip(message)) {
+                doWriteGZIPResponse(message, response, exchange);
+            } else {
+                doWriteDirectResponse(message, response, exchange);
+            }
+        }
+    }
+    
+    protected boolean isText(String contentType) {
+        if (contentType != null) {
+            String temp = contentType.toLowerCase();
+            if (temp.indexOf("text") >= 0 || temp.indexOf("html") >= 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    protected int copyStream(InputStream is, OutputStream os, int bufferSize) throws IOException {
+        try {
+            // copy stream, and must flush on each write as etc Jetty has better performance when
+            // flushing after writing to its servlet output stream
+            return IOHelper.copy(is, os, bufferSize, true);
+        } finally {
+            IOHelper.close(os, is);
+        }
+    }
+
+    protected void doWriteDirectResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
+        // if content type is serialized Java object, then serialize and write it to the response
+        String contentType = message.getHeader(Exchange.CONTENT_TYPE, String.class);
+        if (contentType != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) {
+            try {
+                Object object = message.getMandatoryBody(Serializable.class);
+                HttpHelper.writeObjectToServletResponse(response, object);
+                // object is written so return
+                return;
+            } catch (InvalidPayloadException e) {
+                throw new IOException(e);
+            }
+        }
+
+        // prefer streaming
+        InputStream is = null;
+        if (checkChunked(message, exchange)) {
+            is = message.getBody(InputStream.class);
+        } else {
+            // try to use input stream first, so we can copy directly
+            if (!isText(contentType)) {
+                is = exchange.getContext().getTypeConverter().tryConvertTo(InputStream.class, message.getBody());
+            }
+        }
+
+        if (is != null) {
+            ServletOutputStream os = response.getOutputStream();
+            if (!checkChunked(message, exchange)) {
+                CachedOutputStream stream = new CachedOutputStream(exchange);
+                try {
+                    // copy directly from input stream to the cached output stream to get the content length
+                    int len = copyStream(is, stream, response.getBufferSize());
+                    // we need to setup the length if message is not chucked
+                    response.setContentLength(len);
+                    OutputStream current = stream.getCurrentStream();
+                    if (current instanceof ByteArrayOutputStream) {
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("Streaming (direct) response in non-chunked mode with content-length {}");
+                        }
+                        ByteArrayOutputStream bos = (ByteArrayOutputStream) current;
+                        bos.writeTo(os);
+                    } else {
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("Streaming response in non-chunked mode with content-length {} and buffer size: {}", len, len);
+                        }
+                        copyStream(stream.getInputStream(), os, len);
+                    }
+                } finally {
+                    IOHelper.close(is, os);
+                }
+            } else {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Streaming response in chunked mode with buffer size {}", response.getBufferSize());
+                }
+                copyStream(is, os, response.getBufferSize());
+            }
+        } else {
+            // not convertable as a stream so fallback as a String
+            String data = message.getBody(String.class);
+            if (data != null) {
+                // set content length and encoding before we write data
+                String charset = IOHelper.getCharsetName(exchange, true);
+                final int dataByteLength = data.getBytes(charset).length;
+                response.setCharacterEncoding(charset);
+                response.setContentLength(dataByteLength);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Writing response in non-chunked mode as plain text with content-length {} and buffer size: {}", dataByteLength, response.getBufferSize());
+                }
+                try {
+                    response.getWriter().print(data);
+                } finally {
+                    response.getWriter().flush();
+                }
+            }
+        }
+    }
+
+    protected boolean checkChunked(Message message, Exchange exchange) {
+        boolean answer = true;
+        if (message.getHeader(Exchange.HTTP_CHUNKED) == null) {
+            // check the endpoint option
+            Endpoint endpoint = exchange.getFromEndpoint();
+            if (endpoint instanceof HttpCommonEndpoint) {
+                answer = ((HttpCommonEndpoint)endpoint).isChunked();
+            }
+        } else {
+            answer = message.getHeader(Exchange.HTTP_CHUNKED, boolean.class);
+        }
+        return answer;
+    }
+
+    protected void doWriteGZIPResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
+        byte[] bytes;
+        try {
+            bytes = message.getMandatoryBody(byte[].class);
+        } catch (InvalidPayloadException e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        byte[] data = GZIPHelper.compressGZIP(bytes);
+        ServletOutputStream os = response.getOutputStream();
+        try {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Streaming response as GZIP in non-chunked mode with content-length {} and buffer size: {}", data.length, response.getBufferSize());
+            }
+            response.setContentLength(data.length);
+            os.write(data);
+            os.flush();
+        } finally {
+            IOHelper.close(os);
+        }
+    }
+
+    public Object parseBody(HttpMessage httpMessage) throws IOException {
+        // lets assume the body is a reader
+        HttpServletRequest request = httpMessage.getRequest();
+        // there is only a body if we have a content length, or its -1 to indicate unknown length
+        int len = request.getContentLength();
+        LOG.trace("HttpServletRequest content-length: {}", len);
+        if (len == 0) {
+            return null;
+        }
+        if (isUseReaderForPayload()) {
+            // use reader to read the response body
+            return request.getReader();
+        } else {
+            // if we do not know if there is any data at all, then make sure to check the stream first
+            if (len < 0 && isEagerCheckContentAvailable()) {
+                InputStream is = request.getInputStream();
+                if (is.available() == 0) {
+                    // no data so return null
+                    return null;
+                }
+            }
+            // read the response body from servlet request
+            return HttpHelper.readRequestBodyFromServletRequest(request, httpMessage.getExchange());
+        }
+    }
+
+    public boolean isUseReaderForPayload() {
+        return useReaderForPayload;
+    }
+
+    public void setUseReaderForPayload(boolean useReaderForPayload) {
+        this.useReaderForPayload = useReaderForPayload;
+    }
+
+    public boolean isEagerCheckContentAvailable() {
+        return eagerCheckContentAvailable;
+    }
+
+    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
+        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
+    }
+
+    public boolean isTransferException() {
+        return transferException;
+    }
+
+    public void setTransferException(boolean transferException) {
+        this.transferException = transferException;
+    }
+
+    public HeaderFilterStrategy getHeaderFilterStrategy() {
+        return headerFilterStrategy;
+    }
+
+    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
+        this.headerFilterStrategy = headerFilterStrategy;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpBinding.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpBinding.java
new file mode 100644
index 0000000..d76ba10
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpBinding.java
@@ -0,0 +1,160 @@
+/**
+ * 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.http.common;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.spi.HeaderFilterStrategy;
+
+/**
+ * A pluggable strategy for configuring the http binding so reading request and writing response
+ * can be customized using the Java Servlet API.
+ * <p/>
+ * This is also used by the <tt>camel-jetty</tt> component in the <tt>JettyHttpConsumer</tt> class.
+ */
+public interface HttpBinding {
+
+    /**
+     * Strategy to read the given request and bindings it to the given message.
+     *
+     * @param request  the request
+     * @param message  the message to populate with data from request
+     */
+    void readRequest(HttpServletRequest request, HttpMessage message);
+
+    /**
+     * Parses the body from a {@link org.apache.camel.http.common.HttpMessage}
+     *
+     * @param httpMessage the http message
+     * @return the parsed body returned as either a {@link java.io.InputStream} or a {@link java.io.Reader}
+     * depending on the {@link #setUseReaderForPayload(boolean)} property.
+     * @throws java.io.IOException can be thrown
+     */
+    Object parseBody(HttpMessage httpMessage) throws IOException;
+
+    /**
+     * Writes the exchange to the servlet response.
+     * <p/>
+     * Default implementation will delegate to the following methods depending on the status of the exchange
+     * <ul>
+     *   <li>doWriteResponse - processing returns a OUT message </li>
+     *   <li>doWriteFaultResponse - processing returns a fault message</li>
+     *   <li>doWriteResponse - processing returns an exception and status code 500</li>
+     * </ul>
+     *
+     * @param exchange the exchange
+     * @param response the http response
+     * @throws java.io.IOException can be thrown from http response
+     */
+    void writeResponse(Exchange exchange, HttpServletResponse response) throws IOException;
+
+    /**
+     * Strategy method that writes the response to the http response stream when an exception occurred
+     *
+     * @param exception  the exception occurred
+     * @param response   the http response
+     * @throws java.io.IOException can be thrown from http response
+     */
+    void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException;
+
+    /**
+     * Strategy method that writes the response to the http response stream for a fault message
+     *
+     * @param message  the fault message
+     * @param response the http response
+     * @param exchange the exchange to provide context for header filtering
+     * @throws java.io.IOException can be thrown from http response
+     */
+    void doWriteFaultResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException;
+
+    /**
+     * Strategy method that writes the response to the http response stream for an OUT message
+     *
+     * @param message  the OUT message
+     * @param response the http response
+     * @param exchange the exchange to provide context for header filtering
+     * @throws java.io.IOException can be thrown from http response
+     */
+    void doWriteResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException;
+
+    /**
+     * Should reader by used instead of input stream.
+     *
+     * @see #setUseReaderForPayload(boolean) for more details
+     * @return <tt>true</tt> if reader should be used
+     */
+    boolean isUseReaderForPayload();
+
+    /**
+     * Should the {@link javax.servlet.http.HttpServletRequest#getReader()} be exposed as the payload of input messages in the Camel
+     * {@link org.apache.camel.Message#getBody()} or not. If false then the {@link javax.servlet.http.HttpServletRequest#getInputStream()} will be exposed.
+     * <p/>
+     * Is default <tt>false</tt>.
+     *
+     * @param useReaderForPayload whether to use reader or not
+     */
+    void setUseReaderForPayload(boolean useReaderForPayload);
+
+    /**
+     * 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 (for example using Jetty or
+     * Servlet Camel components). 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.
+     */
+    boolean isTransferException();
+
+    /**
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
+     */
+    boolean isEagerCheckContentAvailable();
+
+    /**
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
+     */
+    void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable);
+
+    /**
+     * 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 (for example using Jetty or
+     * Servlet Camel components). 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.
+     */
+    void setTransferException(boolean transferException);
+
+    /**
+     * Gets the header filter strategy
+     *
+     * @return the strategy
+     */
+    HeaderFilterStrategy getHeaderFilterStrategy();
+
+    /**
+     * Sets the header filter strategy to use.
+     * <p/>
+     * Will default use {@link org.apache.camel.http.common.HttpHeaderFilterStrategy}
+     *
+     * @param headerFilterStrategy the custom strategy
+     */
+    void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy);
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java
new file mode 100644
index 0000000..711a878
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java
@@ -0,0 +1,75 @@
+/**
+ * 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.http.common;
+
+import org.apache.camel.impl.HeaderFilterStrategyComponent;
+
+public abstract class HttpCommonComponent extends HeaderFilterStrategyComponent {
+
+    protected HttpBinding httpBinding;
+    protected HttpConfiguration httpConfiguration;
+
+    public HttpCommonComponent(Class<? extends HttpCommonEndpoint> endpointClass) {
+        super(endpointClass);
+    }
+
+    /**
+     * Connects the URL specified on the endpoint to the specified processor.
+     *
+     * @param consumer the consumer
+     * @throws Exception can be thrown
+     */
+    public void connect(HttpConsumer consumer) throws Exception {
+    }
+
+    /**
+     * Disconnects the URL specified on the endpoint from the specified processor.
+     *
+     * @param consumer the consumer
+     * @throws Exception can be thrown
+     */
+    public void disconnect(HttpConsumer consumer) throws Exception {
+    }
+
+    @Override
+    protected boolean useIntrospectionOnEndpoint() {
+        return false;
+    }
+
+    public HttpBinding getHttpBinding() {
+        return httpBinding;
+    }
+
+    /**
+     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
+     */
+    public void setHttpBinding(HttpBinding httpBinding) {
+        this.httpBinding = httpBinding;
+    }
+
+    public HttpConfiguration getHttpConfiguration() {
+        return httpConfiguration;
+    }
+
+    /**
+     * To use the shared HttpConfiguration as base configuration.
+     */
+    public void setHttpConfiguration(HttpConfiguration httpConfiguration) {
+        this.httpConfiguration = httpConfiguration;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/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
new file mode 100644
index 0000000..4ba2163
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
@@ -0,0 +1,383 @@
+/**
+ * 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.http.common;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class HttpCommonEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware {
+
+    // Note: all options must be documented with description in annotations so extended components can access the documentation
+
+    private static final Logger LOG = LoggerFactory.getLogger(HttpCommonEndpoint.class);
+
+    HttpCommonComponent component;
+    UrlRewrite urlRewrite;
+
+    @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.")
+    HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
+    @UriParam(description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
+    HttpBinding binding;
+    @UriParam(label = "producer", defaultValue = "true",
+            description = "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.")
+    boolean throwExceptionOnFailure = true;
+    @UriParam(label = "producer",
+            description = "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.")
+    boolean bridgeEndpoint;
+    @UriParam(label = "consumer",
+            description = "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.")
+    boolean matchOnUriPrefix;
+    @UriParam(defaultValue = "true", description = "If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response")
+    boolean chunked = true;
+    @UriParam(label = "consumer",
+            description = "Determines whether or not the raw input stream from Jetty 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 Jetty 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 Jetty 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.")
+    boolean disableStreamCache;
+    @UriParam(label = "producer", description = "The proxy host name")
+    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.")
+    String authMethodPriority;
+    @UriParam(description = "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.")
+    boolean transferException;
+    @UriParam(label = "consumer",
+            description = "Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.")
+    boolean traceEnabled;
+    @UriParam(label = "consumer",
+            description = "Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. Multiple methods can be specified separated by comma.")
+    String httpMethodRestrict;
+    @UriParam(label = "consumer",
+            description = "To use a custom buffer size on the javax.servlet.ServletResponse.")
+    Integer responseBufferSize;
+    @UriParam(label = "producer",
+            description = "If this option is true, The http producer won't read response body and cache the input stream")
+    boolean ignoreResponseBody;
+    @UriParam(label = "producer", defaultValue = "true",
+            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",
+            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;
+
+    public HttpCommonEndpoint() {
+    }
+
+    public HttpCommonEndpoint(String endPointURI, HttpCommonComponent component, URI httpURI) throws URISyntaxException {
+        super(endPointURI, component);
+        this.component = component;
+        this.httpUri = httpURI;
+    }
+
+    public void connect(HttpConsumer consumer) throws Exception {
+        component.connect(consumer);
+    }
+
+    public void disconnect(HttpConsumer consumer) throws Exception {
+        component.disconnect(consumer);
+    }
+
+    public boolean isLenientProperties() {
+        // true to allow dynamic URI options to be configured and passed to external system for eg. the HttpProducer
+        return true;
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+
+    // Properties
+    //-------------------------------------------------------------------------
+
+    public HttpBinding getBinding() {
+        if (binding == null) {
+            // create a new binding and use the options from this endpoint
+            binding = new DefaultHttpBinding();
+            binding.setHeaderFilterStrategy(getHeaderFilterStrategy());
+            binding.setTransferException(isTransferException());
+            binding.setEagerCheckContentAvailable(isEagerCheckContentAvailable());
+        }
+        return binding;
+    }
+
+    /**
+     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
+     */
+    public void setBinding(HttpBinding binding) {
+        this.binding = binding;
+    }
+
+    public String getPath() {
+        //if the path is empty, we just return the default path here
+        return httpUri.getPath().length() == 0 ? "/" : httpUri.getPath();
+    }
+
+    public int getPort() {
+        if (httpUri.getPort() == -1) {
+            if ("https".equals(getProtocol())) {
+                return 443;
+            } else {
+                return 80;
+            }
+        }
+        return httpUri.getPort();
+    }
+
+    public String getProtocol() {
+        return httpUri.getScheme();
+    }
+
+    public URI getHttpUri() {
+        return httpUri;
+    }
+
+    /**
+     * The url of the HTTP endpoint to call.
+     */
+    public void setHttpUri(URI httpUri) {
+        this.httpUri = httpUri;
+    }
+
+    public HeaderFilterStrategy getHeaderFilterStrategy() {
+        return headerFilterStrategy;
+    }
+
+    /**
+     * To use a custom HeaderFilterStrategy to filter header to and from Camel message.
+     */
+    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
+        this.headerFilterStrategy = headerFilterStrategy;
+    }
+
+    public boolean isThrowExceptionOnFailure() {
+        return throwExceptionOnFailure;
+    }
+
+    /**
+     * 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.
+     */
+    public void setThrowExceptionOnFailure(boolean throwExceptionOnFailure) {
+        this.throwExceptionOnFailure = throwExceptionOnFailure;
+    }
+
+    public boolean isBridgeEndpoint() {
+        return bridgeEndpoint;
+    }
+
+    /**
+     * 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.
+     */
+    public void setBridgeEndpoint(boolean bridge) {
+        this.bridgeEndpoint = bridge;
+    }
+
+    public boolean isMatchOnUriPrefix() {
+        return matchOnUriPrefix;
+    }
+
+    /**
+     * Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.
+     * <p/>
+     * See more details at: http://camel.apache.org/how-do-i-let-jetty-match-wildcards.html
+     */
+    public void setMatchOnUriPrefix(boolean match) {
+        this.matchOnUriPrefix = match;
+    }
+
+    public boolean isDisableStreamCache() {
+        return this.disableStreamCache;
+    }
+
+    /**
+     * Determines whether or not the raw input stream from Jetty 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 Jetty 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 Jetty 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.
+     */
+    public void setDisableStreamCache(boolean disable) {
+        this.disableStreamCache = disable;
+    }
+
+    public boolean isChunked() {
+        return this.chunked;
+    }
+
+    /**
+     * If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response
+     */
+    public void setChunked(boolean chunked) {
+        this.chunked = chunked;
+    }
+
+    public String getProxyHost() {
+        return proxyHost;
+    }
+
+    /**
+     * The proxy host name
+     */
+    public void setProxyHost(String proxyHost) {
+        this.proxyHost = proxyHost;
+    }
+
+    public int getProxyPort() {
+        return proxyPort;
+    }
+
+    /**
+     * The proxy port number
+     */
+    public void setProxyPort(int proxyPort) {
+        this.proxyPort = proxyPort;
+    }
+
+    public String getAuthMethodPriority() {
+        return authMethodPriority;
+    }
+
+    /**
+     * Authentication method for proxy, either as Basic, Digest or NTLM.
+     */
+    public void setAuthMethodPriority(String authMethodPriority) {
+        this.authMethodPriority = authMethodPriority;
+    }
+
+    public boolean isTransferException() {
+        return transferException;
+    }
+
+    /**
+     * 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.
+     */
+    public void setTransferException(boolean transferException) {
+        this.transferException = transferException;
+    }
+
+    public boolean isTraceEnabled() {
+        return this.traceEnabled;
+    }
+
+    /**
+     * Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.
+     */
+    public void setTraceEnabled(boolean traceEnabled) {
+        this.traceEnabled = traceEnabled;
+    }
+
+    public String getHttpMethodRestrict() {
+        return httpMethodRestrict;
+    }
+
+    /**
+     * Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc.
+     * Multiple methods can be specified separated by comma.
+     */
+    public void setHttpMethodRestrict(String httpMethodRestrict) {
+        this.httpMethodRestrict = httpMethodRestrict;
+    }
+
+    public UrlRewrite getUrlRewrite() {
+        return 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
+     */
+    public void setUrlRewrite(UrlRewrite urlRewrite) {
+        this.urlRewrite = urlRewrite;
+    }
+
+    public Integer getResponseBufferSize() {
+        return responseBufferSize;
+    }
+
+    /**
+     * To use a custom buffer size on the javax.servlet.ServletResponse.
+     */
+    public void setResponseBufferSize(Integer responseBufferSize) {
+        this.responseBufferSize = responseBufferSize;
+    }
+
+    public boolean isIgnoreResponseBody() {
+        return ignoreResponseBody;
+    }
+
+    /**
+     * If this option is true, The http producer won't read response body and cache the input stream.
+     */
+    public void setIgnoreResponseBody(boolean ignoreResponseBody) {
+        this.ignoreResponseBody = ignoreResponseBody;
+    }
+
+    /**
+     * 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).
+     */
+    public boolean isCopyHeaders() {
+        return copyHeaders;
+    }
+
+    public void setCopyHeaders(boolean copyHeaders) {
+        this.copyHeaders = copyHeaders;
+    }
+
+    public boolean isEagerCheckContentAvailable() {
+        return eagerCheckContentAvailable;
+    }
+
+    /**
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
+     */
+    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
+        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConfiguration.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConfiguration.java
new file mode 100644
index 0000000..6a3e646
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConfiguration.java
@@ -0,0 +1,143 @@
+/**
+ * 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.http.common;
+
+import java.io.Serializable;
+
+public class HttpConfiguration implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private String authMethod;
+    private String authUsername;
+    private String authPassword;
+    private String authDomain;
+    private String authHost;
+
+    private String proxyAuthMethod;
+    private String proxyAuthUsername;
+    private String proxyAuthPassword;
+    private String proxyAuthDomain;
+    private String proxyAuthHost;
+
+    private String proxyHost;
+    private int proxyPort;
+    private String authMethodPriority;
+
+    public String getAuthUsername() {
+        return authUsername;
+    }
+
+    public void setAuthUsername(String authUsername) {
+        this.authUsername = authUsername;
+    }
+
+    public String getAuthPassword() {
+        return authPassword;
+    }
+
+    public void setAuthPassword(String authPassword) {
+        this.authPassword = authPassword;
+    }
+
+    public String getAuthDomain() {
+        return authDomain;
+    }
+
+    public void setAuthDomain(String authDomain) {
+        this.authDomain = authDomain;
+    }
+
+    public String getAuthHost() {
+        return authHost;
+    }
+
+    public void setAuthHost(String authHost) {
+        this.authHost = authHost;
+    }
+
+    public String getProxyAuthUsername() {
+        return proxyAuthUsername;
+    }
+
+    public void setProxyAuthUsername(String proxyAuthUsername) {
+        this.proxyAuthUsername = proxyAuthUsername;
+    }
+
+    public String getProxyAuthPassword() {
+        return proxyAuthPassword;
+    }
+
+    public void setProxyAuthPassword(String proxyAuthPassword) {
+        this.proxyAuthPassword = proxyAuthPassword;
+    }
+
+    public String getProxyAuthDomain() {
+        return proxyAuthDomain;
+    }
+
+    public void setProxyAuthDomain(String proxyAuthDomain) {
+        this.proxyAuthDomain = proxyAuthDomain;
+    }
+
+    public String getProxyAuthHost() {
+        return proxyAuthHost;
+    }
+
+    public void setProxyAuthHost(String proxyAuthHost) {
+        this.proxyAuthHost = proxyAuthHost;
+    }
+
+    public String getAuthMethod() {
+        return authMethod;
+    }
+
+    public void setAuthMethod(String authMethod) {
+        this.authMethod = authMethod;
+    }
+
+    public String getProxyAuthMethod() {
+        return proxyAuthMethod;
+    }
+
+    public void setProxyAuthMethod(String proxyAuthMethod) {
+        this.proxyAuthMethod = proxyAuthMethod;
+    }
+
+    public String getProxyHost() {
+        return proxyHost;
+    }
+
+    public void setProxyHost(String proxyHost) {
+        this.proxyHost = proxyHost;
+    }
+
+    public int getProxyPort() {
+        return proxyPort;
+    }
+
+    public void setProxyPort(int proxyPort) {
+        this.proxyPort = proxyPort;
+    }
+
+    public String getAuthMethodPriority() {
+        return authMethodPriority;
+    }
+
+    public void setAuthMethodPriority(String authMethodPriority) {
+        this.authMethodPriority = authMethodPriority;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConstants.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConstants.java
new file mode 100644
index 0000000..bccf724
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConstants.java
@@ -0,0 +1,26 @@
+/**
+ * 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.http.common;
+
+public final class HttpConstants {
+
+    public static final String CONTENT_TYPE_JAVA_SERIALIZED_OBJECT = "application/x-java-serialized-object";
+    public static final String CONTENT_TYPE_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
+
+    private HttpConstants() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConsumer.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConsumer.java
new file mode 100644
index 0000000..f389081
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConsumer.java
@@ -0,0 +1,80 @@
+/**
+ * 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.http.common;
+
+import org.apache.camel.Processor;
+import org.apache.camel.SuspendableService;
+import org.apache.camel.impl.DefaultConsumer;
+
+public class HttpConsumer extends DefaultConsumer implements SuspendableService {
+    private volatile boolean suspended;
+    private boolean traceEnabled;
+
+    public HttpConsumer(HttpCommonEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+        if (endpoint.isTraceEnabled()) {
+            setTraceEnabled(true);
+        }
+    }
+
+    @Override
+    public HttpCommonEndpoint getEndpoint() {
+        return (HttpCommonEndpoint)super.getEndpoint();
+    }
+
+    public HttpBinding getBinding() {
+        return getEndpoint().getBinding();
+    }
+
+    public String getPath() {
+        return getEndpoint().getPath();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        getEndpoint().connect(this);
+        suspended = false;
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        suspended = false;
+        getEndpoint().disconnect(this);
+        super.doStop();
+    }
+
+    public void suspend() {
+        suspended = true;
+    }
+
+    public void resume() {
+        suspended = false;
+    }
+
+    public boolean isSuspended() {
+        return suspended;
+    }
+
+    public boolean isTraceEnabled() {
+        return this.traceEnabled;
+    }
+
+    public void setTraceEnabled(boolean traceEnabled) {
+        this.traceEnabled = traceEnabled;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConverter.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConverter.java
new file mode 100644
index 0000000..8efa895
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpConverter.java
@@ -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.http.common;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.camel.Converter;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.util.GZIPHelper;
+
+/**
+ * Some converter methods making it easy to convert the body of a message to servlet types or to switch between
+ * the underlying {@link ServletInputStream} or {@link BufferedReader} payloads etc.
+ */
+@Converter
+public final class HttpConverter {
+
+    private HttpConverter() {
+    }
+
+    @Converter
+    public static HttpServletRequest toServletRequest(Message message) {
+        if (message == null) {
+            return null;
+        }
+        return message.getHeader(Exchange.HTTP_SERVLET_REQUEST, HttpServletRequest.class);
+    }
+
+    @Converter
+    public static HttpServletResponse toServletResponse(Message message) {
+        if (message == null) {
+            return null;
+        }
+        return message.getHeader(Exchange.HTTP_SERVLET_RESPONSE, HttpServletResponse.class);
+    }
+
+    @Converter
+    public static ServletInputStream toServletInputStream(HttpMessage message) throws IOException {
+        HttpServletRequest request = toServletRequest(message);
+        if (request != null) {
+            return request.getInputStream();
+        }
+        return null;
+    }
+
+    @Converter
+    public static InputStream toInputStream(HttpMessage message, Exchange exchange) throws Exception {
+        return toInputStream(toServletRequest(message), exchange);
+    }
+
+    @Converter
+    public static BufferedReader toReader(HttpMessage message) throws IOException {
+        HttpServletRequest request = toServletRequest(message);
+        if (request != null) {
+            return request.getReader();
+        }
+        return null;
+    }
+
+    @Converter
+    public static InputStream toInputStream(HttpServletRequest request, Exchange exchange) throws IOException {
+        if (request == null) {
+            return null;
+        }
+        InputStream is = request.getInputStream();
+        if (is != null && is.available() <= 0) {
+            // there is no data, so we cannot uncompress etc.
+            return is;
+        }
+        if (exchange == null || !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
+            String contentEncoding = request.getHeader(Exchange.CONTENT_ENCODING);
+            return GZIPHelper.uncompressGzip(contentEncoding, is);
+        } else {
+            return is;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e51b7f8d/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHeaderFilterStrategy.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHeaderFilterStrategy.java
new file mode 100644
index 0000000..6df5b34
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpHeaderFilterStrategy.java
@@ -0,0 +1,49 @@
+/**
+ * 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.http.common;
+
+import org.apache.camel.impl.DefaultHeaderFilterStrategy;
+
+public class HttpHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
+    
+    public HttpHeaderFilterStrategy() {
+        initialize();  
+    }
+
+    protected void initialize() {
+        getOutFilter().add("content-length");
+        getOutFilter().add("content-type");
+        getOutFilter().add("host");
+        // Add the filter for the Generic Message header
+        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
+        getOutFilter().add("cache-control");
+        getOutFilter().add("connection");
+        getOutFilter().add("date");
+        getOutFilter().add("pragma");
+        getOutFilter().add("trailer");
+        getOutFilter().add("transfer-encoding");
+        getOutFilter().add("upgrade");
+        getOutFilter().add("via");
+        getOutFilter().add("warning");
+        
+        setLowerCase(true);
+        
+        // filter headers begin with "Camel" or "org.apache.camel"
+        // must ignore case for Http based transports
+        setOutFilterPattern("(?i)(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
+    }
+}


[06/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java
deleted file mode 100644
index 8c7e265..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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.impl.DefaultHeaderFilterStrategy;
-
-/**
- * @version 
- */
-public class HttpHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
-    
-    public HttpHeaderFilterStrategy() {
-        initialize();  
-    }
-
-    protected void initialize() {
-        getOutFilter().add("content-length");
-        getOutFilter().add("content-type");
-        getOutFilter().add("host");
-        // Add the filter for the Generic Message header
-        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
-        getOutFilter().add("cache-control");
-        getOutFilter().add("connection");
-        getOutFilter().add("date");
-        getOutFilter().add("pragma");
-        getOutFilter().add("trailer");
-        getOutFilter().add("transfer-encoding");
-        getOutFilter().add("upgrade");
-        getOutFilter().add("via");
-        getOutFilter().add("warning");
-        
-        setLowerCase(true);
-        
-        // filter headers begin with "Camel" or "org.apache.camel"
-        // must ignore case for Http based transports
-        setOutFilterPattern("(?i)(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
deleted file mode 100644
index f8e8cfd..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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 javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.impl.DefaultMessage;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * @version 
- */
-public class HttpMessage extends DefaultMessage {
-
-    private HttpServletRequest request;
-    private HttpServletResponse response;
-
-    public HttpMessage(Exchange exchange, HttpServletRequest request, HttpServletResponse response) {
-        setExchange(exchange);
-        this.request = request;
-        this.response = response;
-        // Put the request and response into the message header
-        this.setHeader(Exchange.HTTP_SERVLET_REQUEST, request);
-        this.setHeader(Exchange.HTTP_SERVLET_RESPONSE, response);
-        
-        // Check the setting of exchange
-        Boolean flag = exchange.getProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.class);
-        if (flag != null && flag) {
-            this.setHeader(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
-        }
-
-        // use binding to read the request allowing end users to use their
-        // implementation of the binding
-        getEndpoint().getBinding().readRequest(request, this);
-    }
-
-    public HttpServletRequest getRequest() {
-        return request;
-    }
-
-    public HttpServletResponse getResponse() {
-        return response;
-    }
-
-    @Override
-    protected Object createBody() {
-        try {
-            return getEndpoint().getBinding().parseBody(this);
-        } catch (IOException e) {
-            throw new RuntimeCamelException(e);
-        }
-    }
-    
-    private HttpEndpoint getEndpoint() {
-        return (HttpEndpoint) getExchange().getFromEndpoint();
-    }
-
-    @Override
-    public String toString() {
-        // do not use toString on HTTP message
-        return "HttpMessage@" + ObjectHelper.getIdentityHashCode(this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java
deleted file mode 100644
index 2e681d4..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.CamelException;
-import org.apache.camel.util.ObjectHelper;
-
-public class HttpOperationFailedException extends CamelException {
-    private static final long serialVersionUID = -8721487434390572634L;
-    private final String uri;
-    private final String redirectLocation;
-    private final int statusCode;
-    private final String statusText;
-    private final Map<String, String> responseHeaders;
-    private final String responseBody;
-
-    public HttpOperationFailedException(String uri, int statusCode, String statusText, String location, Map<String, String> responseHeaders, String responseBody) {
-        super("HTTP operation failed invoking " + uri + " with statusCode: " + statusCode + (location != null ? ", redirectLocation: " + location : ""));
-        this.uri = uri;
-        this.statusCode = statusCode;
-        this.statusText = statusText;
-        this.redirectLocation = location;
-        this.responseHeaders = responseHeaders;
-        this.responseBody = responseBody;
-    }
-
-    public String getUri() {
-        return uri;
-    }
-
-    public boolean isRedirectError() {
-        return statusCode >= 300 && statusCode < 400;
-    }
-
-    public boolean hasRedirectLocation() {
-        return ObjectHelper.isNotEmpty(redirectLocation);
-    }
-
-    public String getRedirectLocation() {
-        return redirectLocation;
-    }
-
-    public int getStatusCode() {
-        return statusCode;
-    }
-
-    public String getStatusText() {
-        return statusText;
-    }
-
-    public Map<String, String> getResponseHeaders() {
-        return responseHeaders;
-    }
-
-    public String getResponseBody() {
-        return responseBody;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
index 403bb02..6a224eb 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
@@ -22,7 +22,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.ServicePoolAware;
-import org.apache.camel.component.http.helper.HttpHelper;
+import org.apache.camel.http.common.HttpHelper;
 import org.apache.camel.impl.PollingConsumerSupport;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.commons.httpclient.Header;
@@ -103,6 +103,7 @@ public class HttpPollingConsumer extends PollingConsumerSupport implements Servi
 
     // Properties
     //-------------------------------------------------------------------------
+
     public HttpClient getHttpClient() {
         return httpClient;
     }
@@ -113,6 +114,7 @@ public class HttpPollingConsumer extends PollingConsumerSupport implements Servi
 
     // Implementation methods
     //-------------------------------------------------------------------------
+
     protected HttpMethod createMethod(Exchange exchange) {
         String uri = HttpHelper.createURL(exchange, endpoint);
         return new GetMethod(uri);

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index 4edde30..5d48cea 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -33,8 +33,12 @@ import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.file.GenericFile;
-import org.apache.camel.component.http.helper.HttpHelper;
+import org.apache.camel.component.http.helper.HttpMethodsHelper;
 import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.http.common.HttpConstants;
+import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpProtocolHeaderFilterStrategy;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.ExchangeHelper;
@@ -366,7 +370,7 @@ public class HttpProducer extends DefaultProducer {
 
         // create http holder objects for the request
         RequestEntity requestEntity = createRequestEntity(exchange);
-        HttpMethods methodToUse = HttpHelper.createMethod(exchange, getEndpoint(), requestEntity != null);
+        HttpMethods methodToUse = HttpMethodsHelper.createMethod(exchange, getEndpoint(), requestEntity != null);
         HttpMethod method = methodToUse.createMethod(url);
         if (queryString != null) {
             // need to encode query string

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProtocolHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProtocolHeaderFilterStrategy.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProtocolHeaderFilterStrategy.java
deleted file mode 100644
index d8398ae..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProtocolHeaderFilterStrategy.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.impl.DefaultHeaderFilterStrategy;
-
-
-public class HttpProtocolHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
-    
-    public HttpProtocolHeaderFilterStrategy() {
-        initialize();  
-    }
-
-    // Just add the http headers here 
-    protected void initialize() {
-        getInFilter().add("host");
-        
-        getInFilter().add("content-encoding");
-        getInFilter().add("content-language");
-        getInFilter().add("content-location");
-        getInFilter().add("content-md5");
-        getInFilter().add("content-length");
-        getInFilter().add("content-type");
-        getInFilter().add("content-range");
-        
-        getInFilter().add("dav");
-        getInFilter().add("depth");
-        getInFilter().add("destination");
-        getInFilter().add("etag");
-        getInFilter().add("expect");
-        getInFilter().add("expires");
-        getInFilter().add("from");
-        getInFilter().add("if");
-        getInFilter().add("if-match");
-        getInFilter().add("if-modified-since");
-        getInFilter().add("if-none-match");
-        getInFilter().add("if-range");
-        getInFilter().add("if-unmodified-since");
-        getInFilter().add("last-modified");
-        getInFilter().add("location");
-        getInFilter().add("lock-token");
-        getInFilter().add("max-forwards");
-        getInFilter().add("overwrite");
-        getInFilter().add("pragma");
-        getInFilter().add("proxy-authenticate");
-        getInFilter().add("proxy-authorization");
-        getInFilter().add("range");
-        getInFilter().add("referer");
-        getInFilter().add("retry-after");
-        getInFilter().add("server");
-        getInFilter().add("status-uri");
-        getInFilter().add("te");
-        getInFilter().add("timeout");
-      
-        getInFilter().add("user-agent");
-        getInFilter().add("vary");
-  
-        getInFilter().add("www-authenticate");
-        
-        // Add the filter for the Generic Message header
-        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
-        getInFilter().add("cache-control");
-        getInFilter().add("connection");
-        getInFilter().add("date");
-        getInFilter().add("pragma");
-        getInFilter().add("trailer");
-        getInFilter().add("transfer-encoding");
-        getInFilter().add("upgrade");
-        getInFilter().add("via");
-        getInFilter().add("warning");
-               
-        setLowerCase(true);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletResolveConsumerStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletResolveConsumerStrategy.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletResolveConsumerStrategy.java
deleted file mode 100644
index de7ed4a..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletResolveConsumerStrategy.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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 javax.servlet.http.HttpServletRequest;
-
-/**
- * A default implementation of {@link org.apache.camel.component.http.ServletResolveConsumerStrategy}.
- */
-public class HttpServletResolveConsumerStrategy implements ServletResolveConsumerStrategy {
-
-    @Override
-    public HttpConsumer resolve(HttpServletRequest request, Map<String, HttpConsumer> consumers) {
-        String path = request.getPathInfo();
-        if (path == null) {
-            return null;
-        }
-        HttpConsumer answer = consumers.get(path);
-
-        if (answer == null) {
-            for (String key : consumers.keySet()) {
-                //We need to look up the consumer path here
-                String consumerPath = consumers.get(key).getPath();
-                HttpConsumer consumer = consumers.get(key);
-                // Just make sure the we get the right consumer path first
-                if (consumerPath.equals(path) || (consumer.getEndpoint().isMatchOnUriPrefix() && path.startsWith(consumerPath))) {
-                    answer = consumers.get(key);
-                    break;
-                }
-            }
-        }
-        return answer;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java
deleted file mode 100644
index 3780e22..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpServletUrlRewrite.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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 javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.Producer;
-
-/**
- * Extended {@link UrlRewrite} which leverages {@link HttpServletRequest}
- * during the rewrite process.
- * <p/>
- * For example the camel-urlrewrite component supports
- * {@link HttpServletUrlRewrite} implementations.
- */
-public interface HttpServletUrlRewrite extends UrlRewrite {
-
-    /**
-     * Rewrite the url.
-     *
-     * @param url  the absolute url (eg with scheme://host:port/path?query)
-     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
-     *                    endpoint from the given producer.
-     * @param producer the producer to use the rewritten url
-     * @param request  the http servlet request
-     * @return the rewritten url, or <tt>null</tt> to use the original url
-     * @throws Exception is thrown if error rewriting the url
-     */
-    String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception;
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java b/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java
index 94c2acb..ea6a42c 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/SSLContextParametersSecureProtocolSocketFactory.java
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.UnknownHostException;
-
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSocketFactory;
 
@@ -33,7 +32,7 @@ import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
 
 /**
  * A {@code SecureProtocolSocketFactory} implementation to allow configuration
- * of Commons HTTP SSL/TLS options based on a {@link #JSSEClientParameters}
+ * of Commons HTTP SSL/TLS options based on a JSSEClientParameters
  * instance or a provided {@code SSLSocketFactory} instance.
  */
 public class SSLContextParametersSecureProtocolSocketFactory implements SecureProtocolSocketFactory {

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/ServletResolveConsumerStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/ServletResolveConsumerStrategy.java b/components/camel-http/src/main/java/org/apache/camel/component/http/ServletResolveConsumerStrategy.java
deleted file mode 100644
index 68f27fa..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/ServletResolveConsumerStrategy.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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 javax.servlet.http.HttpServletRequest;
-
-/**
- * Strategy to resolve which consumer to service an incoming {@link javax.servlet.http.HttpServletRequest}.
- */
-public interface ServletResolveConsumerStrategy {
-
-    /**
-     * Resolve the consumer to use.
-     *
-     * @param request   the http request
-     * @param consumers the map of registered consumers
-     * @return the consumer to service the request, or <tt>null</tt> if no match,
-     * which sends back a {@link javax.servlet.http.HttpServletResponse#SC_NOT_FOUND} to the client.
-     */
-    HttpConsumer resolve(HttpServletRequest request, Map<String, HttpConsumer> consumers);
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java b/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java
deleted file mode 100644
index cd26624..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/UrlRewrite.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.Producer;
-
-/**
- * Allows to plugin custom strategy for rewriting url.
- * <p/>
- * This allows for example to proxy http services and plugin a url rewrite
- * strategy such as the <a href="http://camel.apache.org/urlrewrite">url-rewrite</a> component.
- */
-public interface UrlRewrite {
-
-    /**
-     * Rewrite the url.
-     *
-     * @param url  the absolute url (eg with scheme://host:port/path?query)
-     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
-     *                    endpoint from the given producer.
-     * @param producer the producer to use the rewritten url
-     * @return the rewritten url, or <tt>null</tt> to use the original url
-     * @throws Exception is thrown if error rewriting the url
-     */
-    String rewrite(String url, String relativeUrl, Producer producer) throws Exception;
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/helper/CamelFileDataSource.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/CamelFileDataSource.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/CamelFileDataSource.java
deleted file mode 100644
index a1934f5..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/CamelFileDataSource.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.File;
-
-import javax.activation.FileDataSource;
-import javax.activation.FileTypeMap;
-
-public class CamelFileDataSource extends FileDataSource {
-    private final String fileName;
-    private FileTypeMap typeMap;
-
-    public CamelFileDataSource(File file, String fileName) {
-        super(file);
-        this.fileName = fileName;
-    }
-    
-    public String getContentType() {
-        if (typeMap == null) {
-            return FileTypeMap.getDefaultFileTypeMap().getContentType(fileName);
-        } else {
-            return typeMap.getContentType(fileName);
-        }
-    }
-    
-    public void setFileTypeMap(FileTypeMap map) {
-        typeMap = map;
-    }
-    
-    public String getName() {
-        if (fileName != null) {
-            return fileName;
-        } else {
-            return super.getName();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
deleted file mode 100644
index d4f4620..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/**
- * 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.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.Producer;
-import org.apache.camel.RuntimeExchangeException;
-import org.apache.camel.component.http.HttpConstants;
-import org.apache.camel.component.http.HttpConverter;
-import org.apache.camel.component.http.HttpEndpoint;
-import org.apache.camel.component.http.HttpMessage;
-import org.apache.camel.component.http.HttpMethods;
-import org.apache.camel.component.http.HttpServletUrlRewrite;
-import org.apache.camel.converter.IOConverter;
-import org.apache.camel.converter.stream.CachedOutputStream;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.util.CamelObjectInputStream;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.URISupport;
-import org.apache.camel.util.UnsafeUriCharactersEncoder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class HttpHelper {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HttpHelper.class);
-
-    private HttpHelper() {
-        // Helper class
-    }
-
-    @SuppressWarnings("deprecation")
-    public static void setCharsetFromContentType(String contentType, Exchange exchange) {
-        if (contentType != null) {
-            // find the charset and set it to the Exchange
-            int index = contentType.indexOf("charset=");
-            if (index > 0) {
-                String charset = contentType.substring(index + 8);
-                exchange.setProperty(Exchange.CHARSET_NAME, IOConverter.normalizeCharset(charset));
-            }
-        }
-    }
-
-    public static String getCharsetFromContentType(String contentType) {
-        if (contentType != null) {
-            // find the charset and set it to the Exchange
-            int index = contentType.indexOf("charset=");
-            if (index > 0) {
-                String charset = contentType.substring(index + 8);
-                // there may be another parameter after a semi colon, so skip that
-                if (charset.contains(";")) {
-                    charset = ObjectHelper.before(charset, ";");
-                }
-                return IOHelper.normalizeCharset(charset);
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Writes the given object as response body to the servlet response
-     * <p/>
-     * The content type will be set to {@link HttpConstants#CONTENT_TYPE_JAVA_SERIALIZED_OBJECT}
-     *
-     * @param response servlet response
-     * @param target   object to write
-     * @throws IOException is thrown if error writing
-     */
-    public static void writeObjectToServletResponse(ServletResponse response, Object target) throws IOException {
-        response.setContentType(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
-        writeObjectToStream(response.getOutputStream(), target);
-    }
-
-    /**
-     * Writes the given object as response body to the output stream
-     *
-     * @param stream output stream
-     * @param target   object to write
-     * @throws IOException is thrown if error writing
-     */
-    public static void writeObjectToStream(OutputStream stream, Object target) throws IOException {
-        ObjectOutputStream oos = new ObjectOutputStream(stream);
-        oos.writeObject(target);
-        oos.flush();
-        IOHelper.close(oos);
-    }
-
-    /**
-     * Deserializes the input stream to a Java object
-     *
-     * @param is input stream for the Java object
-     * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
-     * @throws ClassNotFoundException is thrown if class not found
-     * @throws IOException can be thrown
-     * @deprecated Camel 3.0 
-     * Please use the one which has the parameter of camel context
-     */
-    @Deprecated
-    public static Object deserializeJavaObjectFromStream(InputStream is) throws ClassNotFoundException, IOException {
-        return deserializeJavaObjectFromStream(is, null);
-    }
-    
-    /**
-     * Deserializes the input stream to a Java object
-     *
-     * @param is input stream for the Java object
-     * @param context the camel context which could help us to apply the customer classloader
-     * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
-     * @throws ClassNotFoundException is thrown if class not found
-     * @throws IOException can be thrown
-     */
-    public static Object deserializeJavaObjectFromStream(InputStream is, CamelContext context) throws ClassNotFoundException, IOException {
-        if (is == null) {
-            return null;
-        }
-
-        Object answer = null;
-        ObjectInputStream ois = new CamelObjectInputStream(is, context);
-        try {
-            answer = ois.readObject();
-        } finally {
-            IOHelper.close(ois);
-        }
-
-        return answer;
-    }
-
-    /**
-     * Reads the response body from the given http servlet request.
-     *
-     * @param request  http servlet request
-     * @param exchange the exchange
-     * @return the request body, can be <tt>null</tt> if no body
-     * @throws IOException is thrown if error reading response body
-     */
-    public static Object readRequestBodyFromServletRequest(HttpServletRequest request, Exchange exchange) throws IOException {
-        InputStream is = HttpConverter.toInputStream(request, exchange);
-        return readResponseBodyFromInputStream(is, exchange);
-    }
-    
-    /**
-     * Reads the response body from the given input stream.
-     *
-     * @param is       the input stream
-     * @param exchange the exchange
-     * @return the response body, can be <tt>null</tt> if no body
-     * @throws IOException is thrown if error reading response body
-     */
-    public static Object readRequestBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
-        if (is == null) {
-            return null;
-        }
-        boolean disableStreamCaching = false;
-        // Just take the consideration of the setting of Camel Context StreamCaching
-        if (exchange.getContext() instanceof DefaultCamelContext) { 
-            DefaultCamelContext context = (DefaultCamelContext) exchange.getContext();
-            disableStreamCaching = !context.isStreamCaching();
-        }
-        // convert the input stream to StreamCache if the stream cache is not disabled
-        if (exchange.getProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, disableStreamCaching, Boolean.class)) {
-            return is;
-        } else {
-            CachedOutputStream cos = new CachedOutputStream(exchange);
-            IOHelper.copyAndCloseInput(is, cos);
-            return cos.newStreamCache();
-        }
-    }
-
-
-    /**
-     * Reads the response body from the given input stream.
-     *
-     * @param is       the input stream
-     * @param exchange the exchange
-     * @return the response body, can be <tt>null</tt> if no body
-     * @throws IOException is thrown if error reading response body
-     */
-    public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
-        if (is == null) {
-            return null;
-        }
-        // convert the input stream to StreamCache if the stream cache is not disabled
-        if (exchange.getProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.FALSE, Boolean.class)) {
-            return is;
-        } else {
-            CachedOutputStream cos = new CachedOutputStream(exchange);
-            IOHelper.copyAndCloseInput(is, cos);
-            return cos.newStreamCache();
-        }
-    }
-
-    /**
-     * 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().toASCIIString();
-        }
-
-        // resolve placeholders in uri
-        try {
-            uri = exchange.getContext().resolvePropertyPlaceholders(uri);
-        } catch (Exception e) {
-            throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uri, exchange, e);
-        }
-
-        // append HTTP_PATH to HTTP_URI if it is provided in the header
-        String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
-        // NOW the HTTP_PATH is just related path, we don't need to trim it
-        if (path != null) {
-            if (path.startsWith("/")) {
-                path = path.substring(1);
-            }
-            if (path.length() > 0) {
-                // make sure that there is exactly one "/" between HTTP_URI and
-                // HTTP_PATH
-                if (!uri.endsWith("/")) {
-                    uri = uri + "/";
-                }
-                uri = uri.concat(path);
-            }
-        }
-
-        // ensure uri is encoded to be valid
-        uri = UnsafeUriCharactersEncoder.encodeHttpURI(uri);
-
-        return uri;
-    }
-
-    /**
-     * Creates the URI to invoke.
-     *
-     * @param exchange the exchange
-     * @param url      the url to invoke
-     * @param endpoint the endpoint
-     * @return the URI to invoke
-     */
-    public static URI createURI(Exchange exchange, String url, HttpEndpoint endpoint) throws URISyntaxException {
-        URI uri = new URI(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 = endpoint.getHttpUri().getRawQuery();
-        }
-        // We should user the query string from the HTTP_URI header
-        if (queryString == null) {
-            queryString = uri.getRawQuery();
-        }
-        if (queryString != null) {
-            // need to encode query string
-            queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
-            uri = URISupport.createURIWithQuery(uri, queryString);
-        }
-        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
-     * @throws URISyntaxException
-     */
-    public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
-        // 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 (hasPayload) {
-            // use POST if we have payload
-            answer = HttpMethods.POST;
-        } else {
-            // fallback to GET
-            answer = HttpMethods.GET;
-        }
-
-        return answer;
-    }
-
-    /**
-     * Appends the key/value to the headers.
-     * <p/>
-     * This implementation supports keys with multiple values. In such situations the value
-     * will be a {@link java.util.List} that contains the multiple values.
-     *
-     * @param headers  headers
-     * @param key      the key
-     * @param value    the value
-     */
-    @SuppressWarnings("unchecked")
-    public static void appendHeader(Map<String, Object> headers, String key, Object value) {
-        if (headers.containsKey(key)) {
-            Object existing = headers.get(key);
-            List<Object> list;
-            if (existing instanceof List) {
-                list = (List<Object>) existing;
-            } else {
-                list = new ArrayList<Object>();
-                list.add(existing);
-            }
-            list.add(value);
-            value = list;
-        }
-
-        headers.put(key, value);
-    }
-
-    /**
-     * Extracts the parameter value.
-     * <p/>
-     * This implementation supports HTTP multi value parameters which
-     * is based on the syntax of <tt>[value1, value2, value3]</tt> by returning
-     * a {@link List} containing the values.
-     * <p/>
-     * If the value is not a HTTP mulit value the value is returned as is.
-     *
-     * @param value the parameter value
-     * @return the extracted parameter value, see more details in javadoc.
-     */
-    public static Object extractHttpParameterValue(String value) {
-        if (value == null || ObjectHelper.isEmpty(value)) {
-            return value;
-        }
-
-        // trim value before checking for multiple parameters
-        String trimmed = value.trim();
-
-        if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
-            // remove the [ ] markers
-            trimmed = trimmed.substring(1, trimmed.length() - 1);
-            List<String> list = new ArrayList<String>();
-            String[] values = trimmed.split(",");
-            for (String s : values) {
-                list.add(s.trim());
-            }
-            return list;
-        }
-
-        return value;
-    }
-
-    /**
-     * Processes any custom {@link org.apache.camel.component.http.UrlRewrite}.
-     *
-     * @param exchange    the exchange
-     * @param url         the url
-     * @param endpoint    the http endpoint
-     * @param producer    the producer
-     * @return            the rewritten url, or <tt>null</tt> to use original url
-     * @throws Exception is thrown if any error during rewriting url
-     */
-    public static String urlRewrite(Exchange exchange, String url, HttpEndpoint endpoint, Producer producer) throws Exception {
-        String answer = null;
-
-        String relativeUrl;
-        if (endpoint.getUrlRewrite() != null) {
-            // we should use the relative path if possible
-            String baseUrl;
-            relativeUrl = endpoint.getHttpUri().toASCIIString();
-            if (url.startsWith(relativeUrl)) {
-                baseUrl = url.substring(0, relativeUrl.length());
-                relativeUrl = url.substring(relativeUrl.length());
-            } else {
-                baseUrl = null;
-                relativeUrl = url;
-            }
-            // mark it as null if its empty
-            if (ObjectHelper.isEmpty(relativeUrl)) {
-                relativeUrl = null;
-            }
-
-            String newUrl;
-            if (endpoint.getUrlRewrite() instanceof HttpServletUrlRewrite) {
-                // its servlet based, so we need the servlet request
-                HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
-                if (request == null) {
-                    HttpMessage msg = exchange.getIn(HttpMessage.class);
-                    if (msg != null) {
-                        request = msg.getRequest();
-                    }
-                }
-                if (request == null) {
-                    throw new IllegalArgumentException("UrlRewrite " + endpoint.getUrlRewrite() + " requires the message body to be a"
-                            + "HttpServletRequest instance, but was: " + ObjectHelper.className(exchange.getIn().getBody()));
-                }
-                // we need to adapt the context-path to be the path from the endpoint, if it came from a http based endpoint
-                // as eg camel-jetty have hardcoded context-path as / for all its servlets/endpoints
-                // we have the actual context-path stored as a header with the key CamelServletContextPath
-                String contextPath = exchange.getIn().getHeader("CamelServletContextPath", String.class);
-                request = new UrlRewriteHttpServletRequestAdapter(request, contextPath);
-                newUrl = ((HttpServletUrlRewrite) endpoint.getUrlRewrite()).rewrite(url, relativeUrl, producer, request);
-            } else {
-                newUrl = endpoint.getUrlRewrite().rewrite(url, relativeUrl, producer);
-            }
-
-            if (ObjectHelper.isNotEmpty(newUrl) && !newUrl.equals(url)) {
-                // we got a new url back, that can either be a new absolute url
-                // or a new relative url
-                if (newUrl.startsWith("http:") || newUrl.startsWith("https:")) {
-                    answer = newUrl;
-                } else if (baseUrl != null) {
-                    // avoid double // when adding the urls
-                    if (baseUrl.endsWith("/") && newUrl.startsWith("/")) {
-                        answer = baseUrl + newUrl.substring(1);
-                    } else {
-                        answer = baseUrl + newUrl;
-                    }
-                } else {
-                    // use the new url as is
-                    answer = newUrl;
-                }
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Using url rewrite to rewrite from url {} to {} -> {}",
-                            new Object[]{relativeUrl != null ? relativeUrl : url, newUrl, answer});
-                }
-            }
-        }
-
-        return answer;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodsHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodsHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodsHelper.java
new file mode 100644
index 0000000..2aa04f1
--- /dev/null
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodsHelper.java
@@ -0,0 +1,52 @@
+/**
+ * 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.net.URISyntaxException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.http.HttpEndpoint;
+import org.apache.camel.component.http.HttpMethods;
+
+public final class HttpMethodsHelper {
+
+    /**
+     * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
+     *
+     * @param exchange  the exchange
+     * @return the created method
+     * @throws URISyntaxException
+     */
+    public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
+        // 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 (hasPayload) {
+            // use POST if we have payload
+            answer = HttpMethods.POST;
+        } else {
+            // fallback to GET
+            answer = HttpMethods.GET;
+        }
+
+        return answer;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/helper/UrlRewriteHttpServletRequestAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/UrlRewriteHttpServletRequestAdapter.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/UrlRewriteHttpServletRequestAdapter.java
deleted file mode 100644
index d30e865..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/UrlRewriteHttpServletRequestAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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 javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
-/**
- * Special adapter when {@link org.apache.camel.component.http.HttpServletUrlRewrite} is in use,
- * and the route started from came-jetty/camel-serlvet.
- * <p/>
- * This adapter ensures that we can control the context-path returned from the
- * {@link javax.servlet.http.HttpServletRequest#getContextPath()} method.
- * This allows us to ensure the context-path is based on the endpoint path, as the
- * camel-jetty/camel-servlet server implementation uses the root ("/") context-path
- * for all the servlets/endpoints.
- */
-public final class UrlRewriteHttpServletRequestAdapter extends HttpServletRequestWrapper {
-
-    private final String contextPath;
-
-    /**
-     * Creates this adapter
-     * @param delegate    the real http servlet request to delegate.
-     * @param contextPath use to override and return this context-path
-     */
-    public UrlRewriteHttpServletRequestAdapter(HttpServletRequest delegate, String contextPath) {
-        super(delegate);
-        this.contextPath = contextPath;
-    }
-
-
-    public String getContextPath() {
-        return contextPath != null ? contextPath : super.getContextPath();
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter b/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
index db3d92e..96378be 100644
--- a/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
+++ b/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
@@ -15,5 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.camel.component.http.HttpConverter
 org.apache.camel.component.http.RequestEntityConverter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java b/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java
index 56a223b..807f21a 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/GoogleUrlRewrite.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.Producer;
+import org.apache.camel.http.common.UrlRewrite;
 
 // START SNIPPET: e1
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthMethodPriorityTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthMethodPriorityTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthMethodPriorityTest.java
index 4ea19fb..552b5a0 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthMethodPriorityTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpAuthMethodPriorityTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.http.common.HttpConfiguration;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
@@ -45,7 +46,7 @@ public class HttpAuthMethodPriorityTest extends CamelTestSupport {
             public void configure() {
                 // setup proxy details
                 HttpConfiguration config = new HttpConfiguration();
-                config.setAuthMethod(AuthMethod.Basic);
+                config.setAuthMethod("Basic");
                 config.setAuthUsername("myUser");
                 config.setAuthPassword("myPassword");
                 // to avoid NTLM

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConnectionManagerSettingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConnectionManagerSettingTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConnectionManagerSettingTest.java
index 3457508..f77e09f 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConnectionManagerSettingTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpConnectionManagerSettingTest.java
@@ -24,6 +24,7 @@ import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
 import org.junit.Before;
 import org.junit.Test;
+
 import static org.apache.camel.component.http.HttpMethods.POST;
 
 public class HttpConnectionManagerSettingTest extends CamelTestSupport {

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointOptionsNotChangeComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointOptionsNotChangeComponentTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointOptionsNotChangeComponentTest.java
index e1c9201..83db8cc 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointOptionsNotChangeComponentTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpEndpointOptionsNotChangeComponentTest.java
@@ -17,6 +17,8 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.http.common.DefaultHttpBinding;
+import org.apache.camel.http.common.HttpHeaderFilterStrategy;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java
index 29e49f3..82a2634 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetTest.java
@@ -19,7 +19,6 @@ 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;

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
index f885fed..4f2ac75 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.http.common.HttpHeaderFilterStrategy;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.test.junit4.CamelTestSupport;

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java
index 83f5aac..d0fb60d 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPostWithBodyTest.java
@@ -24,6 +24,7 @@ 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.http.common.HttpOperationFailedException;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Ignore;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
index 8e575dc..886e9c8 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.http;
 import java.io.IOException;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.commons.httpclient.HttpMethod;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthBasicTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthBasicTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthBasicTest.java
index 4b230b0..39c5ca2 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthBasicTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthBasicTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.http.common.HttpConfiguration;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
@@ -48,7 +49,7 @@ public class HttpProxyAuthBasicTest extends CamelTestSupport {
                 config.setProxyHost("myProxyHosy");
                 config.setProxyPort(1234);
                 // proxy requires auth as well
-                config.setProxyAuthMethod(AuthMethod.Basic);
+                config.setProxyAuthMethod("Basic");
                 config.setProxyAuthUsername("myUser");
                 config.setProxyAuthPassword("myPassword");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthDigestTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthDigestTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthDigestTest.java
index e6c2c4b..f20ae26 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthDigestTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthDigestTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.http.common.HttpConfiguration;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
@@ -45,7 +46,7 @@ public class HttpProxyAuthDigestTest extends CamelTestSupport {
             public void configure() {
                 // setup proxy details
                 HttpConfiguration config = new HttpConfiguration();
-                config.setProxyAuthMethod(AuthMethod.Digest);
+                config.setProxyAuthMethod("Digest");
                 config.setProxyAuthUsername("myUser");
                 config.setProxyAuthPassword("myPassword");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthNTLMTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthNTLMTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthNTLMTest.java
index 9e5f01c..ba119ae 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthNTLMTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyAuthNTLMTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.http.common.HttpConfiguration;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
@@ -50,7 +51,7 @@ public class HttpProxyAuthNTLMTest extends CamelTestSupport {
                 config.setProxyHost("myProxyHosy");
                 config.setProxyPort(1234);
 
-                config.setProxyAuthMethod(AuthMethod.NTLM);
+                config.setProxyAuthMethod("NTLM");
                 config.setProxyAuthUsername("myUser");
                 config.setProxyAuthPassword("myPassword");
                 config.setProxyAuthDomain("myDomain");

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
index d9e9721..302ca1f 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.http;
 
+import org.apache.camel.http.common.HttpConfiguration;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.URISupport;
 import org.apache.commons.httpclient.HttpClient;

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryGoogleProxyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryGoogleProxyTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryGoogleProxyTest.java
index 4ee0101..e1157b2 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryGoogleProxyTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpQueryGoogleProxyTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.http;
 
+import org.apache.camel.http.common.HttpConfiguration;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -35,7 +36,7 @@ public class HttpQueryGoogleProxyTest extends CamelTestSupport {
         HttpConfiguration config = new HttpConfiguration();
         config.setProxyHost("myProxyHost");
         config.setProxyPort(8877);
-        config.setProxyAuthMethod(AuthMethod.Basic);
+        config.setProxyAuthMethod("Basic");
         config.setAuthMethodPriority("Digest,Basic");
         config.setProxyAuthUsername("myProxyUsername");
         config.setProxyAuthPassword("myProxyPassword");

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java
index d75d459..5e93ee3 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpReferenceParameterTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.http.common.DefaultHttpBinding;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.commons.httpclient.HttpClient;

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
index 8cd5d16..d8c5a75 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpHelperTest.java
@@ -27,6 +27,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.http.HttpEndpoint;
 import org.apache.camel.component.http.HttpMethods;
+import org.apache.camel.http.common.HttpHelper;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.junit.Test;
@@ -107,46 +108,6 @@ public class HttpHelperTest {
     }
 
     @Test
-    public void createMethodAlwaysUseUserChoosenMethod() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
-                createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", HttpMethods.POST),
-                createHttpEndpoint(true, "http://www.google.com/search"), false);
-        assertEquals(HttpMethods.POST, method);
-    }
-
-    @Test
-    public void createMethodUseGETIfQueryIsProvidedInHeader() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
-                createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", null),
-                createHttpEndpoint(true, "http://www.google.com/search"), false);
-        assertEquals(HttpMethods.GET, method);
-    }
-
-    @Test
-    public void createMethodUseGETIfQueryIsProvidedInEndpointURI() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
-                createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
-                createHttpEndpoint(true, "http://www.google.com/search?q=test"), false);
-        assertEquals(HttpMethods.GET, method);
-    }
-
-    @Test
-    public void createMethodUseGETIfNoneQueryOrPayloadIsProvided() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
-                createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
-                createHttpEndpoint(true, "http://www.google.com/search"), false);
-        assertEquals(HttpMethods.GET, method);
-    }
-
-    @Test
-    public void createMethodUsePOSTIfNoneQueryButPayloadIsProvided() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
-                createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
-                createHttpEndpoint(true, "http://www.google.com/search"), true);
-        assertEquals(HttpMethods.POST, method);
-    }
-
-    @Test
     public void createURIShouldKeepQueryParametersGivenInUrlParameter() throws URISyntaxException {
         URI uri = HttpHelper.createURI(
                 createExchangeWithOptionalCamelHttpUriHeader(null, null),

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java
new file mode 100644
index 0000000..eab55cb
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java
@@ -0,0 +1,99 @@
+/**
+ * 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.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.component.http.HttpEndpoint;
+import org.apache.camel.component.http.HttpMethods;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class HttpMethodsHelperTest {
+
+    @Test
+    public void createMethodAlwaysUseUserChoosenMethod() throws URISyntaxException {
+        HttpMethods method = HttpMethodsHelper.createMethod(
+                createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", HttpMethods.POST),
+                createHttpEndpoint(true, "http://www.google.com/search"), false);
+        assertEquals(HttpMethods.POST, method);
+    }
+
+    @Test
+    public void createMethodUseGETIfQueryIsProvidedInHeader() throws URISyntaxException {
+        HttpMethods method = HttpMethodsHelper.createMethod(
+                createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", null),
+                createHttpEndpoint(true, "http://www.google.com/search"), false);
+        assertEquals(HttpMethods.GET, method);
+    }
+
+    @Test
+    public void createMethodUseGETIfQueryIsProvidedInEndpointURI() throws URISyntaxException {
+        HttpMethods method = HttpMethodsHelper.createMethod(
+                createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
+                createHttpEndpoint(true, "http://www.google.com/search?q=test"), false);
+        assertEquals(HttpMethods.GET, method);
+    }
+
+    @Test
+    public void createMethodUseGETIfNoneQueryOrPayloadIsProvided() throws URISyntaxException {
+        HttpMethods method = HttpMethodsHelper.createMethod(
+                createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
+                createHttpEndpoint(true, "http://www.google.com/search"), false);
+        assertEquals(HttpMethods.GET, method);
+    }
+
+    @Test
+    public void createMethodUsePOSTIfNoneQueryButPayloadIsProvided() throws URISyntaxException {
+        HttpMethods method = HttpMethodsHelper.createMethod(
+                createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
+                createHttpEndpoint(true, "http://www.google.com/search"), true);
+        assertEquals(HttpMethods.POST, method);
+    }
+
+    private Exchange createExchangeWithOptionalHttpQueryAndHttpMethodHeader(String httpQuery, HttpMethods httpMethod) {
+        CamelContext context = new DefaultCamelContext();
+        Exchange exchange = new DefaultExchange(context);
+        Message inMsg = exchange.getIn();
+        if (httpQuery != null) {
+            inMsg.setHeader(Exchange.HTTP_QUERY, httpQuery);
+        }
+        if (httpMethod != null) {
+            inMsg.setHeader(Exchange.HTTP_METHOD, httpMethod);
+        }
+
+        return exchange;
+    }
+
+    private HttpEndpoint createHttpEndpoint(boolean bridgeEndpoint, String endpointURI) throws URISyntaxException {
+        HttpEndpoint endpoint = new HttpEndpoint();
+        endpoint.setBridgeEndpoint(bridgeEndpoint);
+        if (endpointURI != null) {
+            endpoint.setHttpUri(new URI(endpointURI));
+        }
+
+        return endpoint;
+    }
+
+}


[08/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: e191504bc479a6c159ca63362b2b83f9d61b85f0
Parents: e51b7f8
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 09:25:45 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:31 2015 +0200

----------------------------------------------------------------------
 apache-camel/pom.xml                             | 4 ++++
 apache-camel/src/main/descriptors/common-bin.xml | 1 +
 components/camel-http/pom.xml                    | 4 ++++
 parent/pom.xml                                   | 5 +++++
 4 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e191504b/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 7dc0bb4..8b1aff6 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -317,6 +317,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-http4</artifactId>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/e191504b/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index b2eb8db..6c311d7 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -94,6 +94,7 @@
         <include>org.apache.camel:camel-hdfs2</include>
         <include>org.apache.camel:camel-hipchat</include>
         <include>org.apache.camel:camel-http</include>
+        <include>org.apache.camel:camel-http-common</include>
         <include>org.apache.camel:camel-http4</include>
         <include>org.apache.camel:camel-ibatis</include>
         <include>org.apache.camel:camel-ical</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/e191504b/components/camel-http/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-http/pom.xml b/components/camel-http/pom.xml
index 7648d67..b3429b9 100644
--- a/components/camel-http/pom.xml
+++ b/components/camel-http/pom.xml
@@ -47,6 +47,10 @@
       <artifactId>camel-core</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http-common</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-servlet_3.0_spec</artifactId>
     </dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/e191504b/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index d336689..3d7419e 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -961,6 +961,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-http-common</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-http4</artifactId>
         <version>${project.version}</version>
       </dependency>


[19/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 2b89da0957164f75dbf75d8384e09cea132b6a55
Parents: 481baa6
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 13:57:43 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:35 2015 +0200

----------------------------------------------------------------------
 .../component/http4/HttpMethodsConverter.java   | 40 ++++++++++++++++++++
 .../http4/helper/HttpMethodHelper.java          |  1 -
 .../services/org/apache/camel/TypeConverter     |  1 +
 .../http4/HttpProducerSelectMethodTest.java     | 15 ++++++++
 4 files changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2b89da09/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethodsConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethodsConverter.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethodsConverter.java
new file mode 100644
index 0000000..b2c54a4
--- /dev/null
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMethodsConverter.java
@@ -0,0 +1,40 @@
+/**
+ * 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.http4;
+
+import java.util.Locale;
+
+import org.apache.camel.Converter;
+import org.apache.camel.Exchange;
+
+/**
+ * To convert between camel-http4 and camel-http-common for the http methods enums
+ */
+@Converter
+public final class HttpMethodsConverter {
+
+    private HttpMethodsConverter() {
+    }
+
+    @Converter
+    public static HttpMethods toHttp4Methods(org.apache.camel.http.common.HttpMethods method, Exchange exchange) throws Exception {
+        String name = method.name();
+        name = name.toUpperCase(Locale.ENGLISH);
+        return HttpMethods.valueOf(name);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2b89da09/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 ac37192..ddf408f 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
@@ -41,7 +41,6 @@ public final class HttpMethodHelper {
      * @return the created method
      * @throws URISyntaxException 
      */
-    @Deprecated
     public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
         // is a query string provided in the endpoint URI or in a header (header
         // overrules endpoint)

http://git-wip-us.apache.org/repos/asf/camel/blob/2b89da09/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter b/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
index bbb63c3..244025a 100644
--- a/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
+++ b/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
@@ -16,3 +16,4 @@
 #
 
 org.apache.camel.component.http4.HttpEntityConverter
+org.apache.camel.component.http4.HttpMethodsConverter

http://git-wip-us.apache.org/repos/asf/camel/blob/2b89da09/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerSelectMethodTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerSelectMethodTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerSelectMethodTest.java
index 6b66dad..466c27d 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerSelectMethodTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerSelectMethodTest.java
@@ -126,6 +126,21 @@ public class HttpProducerSelectMethodTest extends BaseHttpTest {
     }
 
     @Test
+    public void withMethodCommonHttpGetInHeader() throws Exception {
+        HttpComponent component = context.getComponent("http4", HttpComponent.class);
+
+        HttpEndpoint endpoiont = (HttpEndpoint) component.createEndpoint("http4://" + localServer.getInetAddress().getHostName() + ":" + localServer.getLocalPort() + "/myget");
+        HttpProducer producer = new HttpProducer(endpoiont);
+
+        Exchange exchange = producer.createExchange();
+        exchange.getIn().setBody("");
+        exchange.getIn().setHeader(Exchange.HTTP_METHOD, org.apache.camel.http.common.HttpMethods.GET);
+        producer.start();
+        producer.process(exchange);
+        producer.stop();
+    }
+
+    @Test
     public void withEndpointQuery() throws Exception {
         HttpComponent component = context.getComponent("http4", HttpComponent.class);
 


[04/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: b48be21c697002265e1f31d365a3924bd9c340ce
Parents: 2a93d6e
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 09:04:48 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:30 2015 +0200

----------------------------------------------------------------------
 components/camel-http-common/pom.xml            |  74 ++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 ++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../camel/component/http/HttpBinding.java       |   1 -
 .../component/http/HttpCommonComponent.java     |  77 ++++
 .../component/http/HttpCommonEndpoint.java      | 383 +++++++++++++++++++
 .../camel/component/http/HttpComponent.java     |  50 +--
 components/pom.xml                              |   1 +
 8 files changed, 750 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b48be21c/components/camel-http-common/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-http-common/pom.xml b/components/camel-http-common/pom.xml
new file mode 100644
index 0000000..87b166e
--- /dev/null
+++ b/components/camel-http-common/pom.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.16-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-http-common</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: HTTP :: Common</name>
+  <description>Camel HTTP common</description>
+
+  <properties>
+    <camel.osgi.import.before.defaults>
+      javax.servlet.*;version="${servlet-version-range}"
+    </camel.osgi.import.before.defaults>
+    <camel.osgi.export.pkg>org.apache.camel.http.*</camel.osgi.export.pkg>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-servlet_3.0_spec</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>      
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/b48be21c/components/camel-http-common/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/resources/META-INF/LICENSE.txt b/components/camel-http-common/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-http-common/src/main/resources/META-INF/LICENSE.txt
@@ -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.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/b48be21c/components/camel-http-common/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/resources/META-INF/NOTICE.txt b/components/camel-http-common/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-http-common/src/main/resources/META-INF/NOTICE.txt
@@ -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.

http://git-wip-us.apache.org/repos/asf/camel/blob/b48be21c/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
index 10141ae..eb6670c 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
@@ -20,7 +20,6 @@ import java.io.IOException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.camel.CamelContextAware;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.spi.HeaderFilterStrategy;

http://git-wip-us.apache.org/repos/asf/camel/blob/b48be21c/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
new file mode 100644
index 0000000..8443963
--- /dev/null
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
@@ -0,0 +1,77 @@
+/**
+ * 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.Endpoint;
+import org.apache.camel.impl.HeaderFilterStrategyComponent;
+
+public abstract class HttpCommonComponent extends HeaderFilterStrategyComponent {
+
+    protected HttpBinding httpBinding;
+    protected HttpConfiguration httpConfiguration;
+
+    // TODO: HttpCommonEndpoint
+    public HttpCommonComponent(Class<? extends Endpoint> endpointClass) {
+        super(endpointClass);
+    }
+
+    /**
+     * Connects the URL specified on the endpoint to the specified processor.
+     *
+     * @param consumer the consumer
+     * @throws Exception can be thrown
+     */
+    public void connect(HttpConsumer consumer) throws Exception {
+    }
+
+    /**
+     * Disconnects the URL specified on the endpoint from the specified processor.
+     *
+     * @param consumer the consumer
+     * @throws Exception can be thrown
+     */
+    public void disconnect(HttpConsumer consumer) throws Exception {
+    }
+
+    @Override
+    protected boolean useIntrospectionOnEndpoint() {
+        return false;
+    }
+
+    public HttpBinding getHttpBinding() {
+        return httpBinding;
+    }
+
+    /**
+     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
+     */
+    public void setHttpBinding(HttpBinding httpBinding) {
+        this.httpBinding = httpBinding;
+    }
+
+    public HttpConfiguration getHttpConfiguration() {
+        return httpConfiguration;
+    }
+
+    /**
+     * To use the shared HttpConfiguration as base configuration.
+     */
+    public void setHttpConfiguration(HttpConfiguration httpConfiguration) {
+        this.httpConfiguration = httpConfiguration;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/b48be21c/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
new file mode 100644
index 0000000..1c40e38
--- /dev/null
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
@@ -0,0 +1,383 @@
+/**
+ * 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.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class HttpCommonEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware {
+
+    // Note: all options must be documented with description in annotations so extended components can access the documentation
+
+    private static final Logger LOG = LoggerFactory.getLogger(HttpEndpoint.class);
+
+    private HttpCommonComponent component;
+    private UrlRewrite urlRewrite;
+
+    @UriPath(label = "producer", description = "The url of the HTTP endpoint to call.") @Metadata(required = "true")
+    private URI httpUri;
+    @UriParam(description = "To use a custom HeaderFilterStrategy to filter header to and from Camel message.")
+    private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
+    @UriParam(description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
+    private HttpBinding binding;
+    @UriParam(label = "producer", defaultValue = "true",
+            description = "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.")
+    private boolean throwExceptionOnFailure = true;
+    @UriParam(label = "producer",
+            description = "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.")
+    private boolean bridgeEndpoint;
+    @UriParam(label = "consumer",
+            description = "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.")
+    private boolean matchOnUriPrefix;
+    @UriParam(defaultValue = "true", description = "If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response")
+    private boolean chunked = true;
+    @UriParam(label = "consumer",
+            description = "Determines whether or not the raw input stream from Jetty 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 Jetty 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 Jetty 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.")
+    private boolean disableStreamCache;
+    @UriParam(label = "producer", description = "The proxy host name")
+    private String proxyHost;
+    @UriParam(label = "producer", description = "The proxy port number")
+    private int proxyPort;
+    @UriParam(label = "producer", enums = "Basic,Digest,NTLM", description = "Authentication method for proxy, either as Basic, Digest or NTLM.")
+    private String authMethodPriority;
+    @UriParam(description = "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.")
+    private boolean transferException;
+    @UriParam(label = "consumer",
+            description = "Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.")
+    private boolean traceEnabled;
+    @UriParam(label = "consumer",
+            description = "Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. Multiple methods can be specified separated by comma.")
+    private String httpMethodRestrict;
+    @UriParam(label = "consumer",
+            description = "To use a custom buffer size on the javax.servlet.ServletResponse.")
+    private Integer responseBufferSize;
+    @UriParam(label = "producer",
+            description = "If this option is true, The http producer won't read response body and cache the input stream")
+    private boolean ignoreResponseBody;
+    @UriParam(label = "producer", defaultValue = "true",
+            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).")
+    private boolean copyHeaders = true;
+    @UriParam(label = "consumer",
+            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.")
+    private boolean eagerCheckContentAvailable;
+
+    public HttpCommonEndpoint() {
+    }
+
+    public HttpCommonEndpoint(String endPointURI, HttpCommonComponent component, URI httpURI) throws URISyntaxException {
+        super(endPointURI, component);
+        this.component = component;
+        this.httpUri = httpURI;
+    }
+
+    public void connect(HttpConsumer consumer) throws Exception {
+        component.connect(consumer);
+    }
+
+    public void disconnect(HttpConsumer consumer) throws Exception {
+        component.disconnect(consumer);
+    }
+
+    public boolean isLenientProperties() {
+        // true to allow dynamic URI options to be configured and passed to external system for eg. the HttpProducer
+        return true;
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+
+    // Properties
+    //-------------------------------------------------------------------------
+
+    public HttpBinding getBinding() {
+        if (binding == null) {
+            // create a new binding and use the options from this endpoint
+            binding = new DefaultHttpBinding();
+            binding.setHeaderFilterStrategy(getHeaderFilterStrategy());
+            binding.setTransferException(isTransferException());
+            binding.setEagerCheckContentAvailable(isEagerCheckContentAvailable());
+        }
+        return binding;
+    }
+
+    /**
+     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
+     */
+    public void setBinding(HttpBinding binding) {
+        this.binding = binding;
+    }
+
+    public String getPath() {
+        //if the path is empty, we just return the default path here
+        return httpUri.getPath().length() == 0 ? "/" : httpUri.getPath();
+    }
+
+    public int getPort() {
+        if (httpUri.getPort() == -1) {
+            if ("https".equals(getProtocol())) {
+                return 443;
+            } else {
+                return 80;
+            }
+        }
+        return httpUri.getPort();
+    }
+
+    public String getProtocol() {
+        return httpUri.getScheme();
+    }
+
+    public URI getHttpUri() {
+        return httpUri;
+    }
+
+    /**
+     * The url of the HTTP endpoint to call.
+     */
+    public void setHttpUri(URI httpUri) {
+        this.httpUri = httpUri;
+    }
+
+    public HeaderFilterStrategy getHeaderFilterStrategy() {
+        return headerFilterStrategy;
+    }
+
+    /**
+     * To use a custom HeaderFilterStrategy to filter header to and from Camel message.
+     */
+    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
+        this.headerFilterStrategy = headerFilterStrategy;
+    }
+
+    public boolean isThrowExceptionOnFailure() {
+        return throwExceptionOnFailure;
+    }
+
+    /**
+     * 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.
+     */
+    public void setThrowExceptionOnFailure(boolean throwExceptionOnFailure) {
+        this.throwExceptionOnFailure = throwExceptionOnFailure;
+    }
+
+    public boolean isBridgeEndpoint() {
+        return bridgeEndpoint;
+    }
+
+    /**
+     * 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.
+     */
+    public void setBridgeEndpoint(boolean bridge) {
+        this.bridgeEndpoint = bridge;
+    }
+
+    public boolean isMatchOnUriPrefix() {
+        return matchOnUriPrefix;
+    }
+
+    /**
+     * Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.
+     * <p/>
+     * See more details at: http://camel.apache.org/how-do-i-let-jetty-match-wildcards.html
+     */
+    public void setMatchOnUriPrefix(boolean match) {
+        this.matchOnUriPrefix = match;
+    }
+
+    public boolean isDisableStreamCache() {
+        return this.disableStreamCache;
+    }
+
+    /**
+     * Determines whether or not the raw input stream from Jetty 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 Jetty 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 Jetty 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.
+     */
+    public void setDisableStreamCache(boolean disable) {
+        this.disableStreamCache = disable;
+    }
+
+    public boolean isChunked() {
+        return this.chunked;
+    }
+
+    /**
+     * If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response
+     */
+    public void setChunked(boolean chunked) {
+        this.chunked = chunked;
+    }
+
+    public String getProxyHost() {
+        return proxyHost;
+    }
+
+    /**
+     * The proxy host name
+     */
+    public void setProxyHost(String proxyHost) {
+        this.proxyHost = proxyHost;
+    }
+
+    public int getProxyPort() {
+        return proxyPort;
+    }
+
+    /**
+     * The proxy port number
+     */
+    public void setProxyPort(int proxyPort) {
+        this.proxyPort = proxyPort;
+    }
+
+    public String getAuthMethodPriority() {
+        return authMethodPriority;
+    }
+
+    /**
+     * Authentication method for proxy, either as Basic, Digest or NTLM.
+     */
+    public void setAuthMethodPriority(String authMethodPriority) {
+        this.authMethodPriority = authMethodPriority;
+    }
+
+    public boolean isTransferException() {
+        return transferException;
+    }
+
+    /**
+     * 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.
+     */
+    public void setTransferException(boolean transferException) {
+        this.transferException = transferException;
+    }
+
+    public boolean isTraceEnabled() {
+        return this.traceEnabled;
+    }
+
+    /**
+     * Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.
+     */
+    public void setTraceEnabled(boolean traceEnabled) {
+        this.traceEnabled = traceEnabled;
+    }
+
+    public String getHttpMethodRestrict() {
+        return httpMethodRestrict;
+    }
+
+    /**
+     * Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc.
+     * Multiple methods can be specified separated by comma.
+     */
+    public void setHttpMethodRestrict(String httpMethodRestrict) {
+        this.httpMethodRestrict = httpMethodRestrict;
+    }
+
+    public UrlRewrite getUrlRewrite() {
+        return 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
+     */
+    public void setUrlRewrite(UrlRewrite urlRewrite) {
+        this.urlRewrite = urlRewrite;
+    }
+
+    public Integer getResponseBufferSize() {
+        return responseBufferSize;
+    }
+
+    /**
+     * To use a custom buffer size on the javax.servlet.ServletResponse.
+     */
+    public void setResponseBufferSize(Integer responseBufferSize) {
+        this.responseBufferSize = responseBufferSize;
+    }
+
+    public boolean isIgnoreResponseBody() {
+        return ignoreResponseBody;
+    }
+
+    /**
+     * If this option is true, The http producer won't read response body and cache the input stream.
+     */
+    public void setIgnoreResponseBody(boolean ignoreResponseBody) {
+        this.ignoreResponseBody = ignoreResponseBody;
+    }
+
+    /**
+     * 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).
+     */
+    public boolean isCopyHeaders() {
+        return copyHeaders;
+    }
+
+    public void setCopyHeaders(boolean copyHeaders) {
+        this.copyHeaders = copyHeaders;
+    }
+
+    public boolean isEagerCheckContentAvailable() {
+        return eagerCheckContentAvailable;
+    }
+
+    /**
+     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
+     * This can be turned on in case HTTP clients do not send streamed data.
+     */
+    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
+        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/b48be21c/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
index 5c6f80f..e817d55 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
@@ -25,7 +25,6 @@ import java.util.Set;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.ResolveEndpointFailedException;
-import org.apache.camel.impl.HeaderFilterStrategyComponent;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.CollectionHelper;
 import org.apache.camel.util.IntrospectionSupport;
@@ -42,11 +41,9 @@ import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
  *
  * @version 
  */
-public class HttpComponent extends HeaderFilterStrategyComponent {
+public class HttpComponent extends HttpCommonComponent {
     protected HttpClientConfigurer httpClientConfigurer;
     protected HttpConnectionManager httpConnectionManager;
-    protected HttpBinding httpBinding;
-    protected HttpConfiguration httpConfiguration;
 
     public HttpComponent() {
         super(HttpEndpoint.class);
@@ -57,24 +54,6 @@ public class HttpComponent extends HeaderFilterStrategyComponent {
     }
 
     /**
-     * Connects the URL specified on the endpoint to the specified processor.
-     *
-     * @param consumer the consumer
-     * @throws Exception can be thrown
-     */
-    public void connect(HttpConsumer consumer) throws Exception {
-    }
-
-    /**
-     * Disconnects the URL specified on the endpoint from the specified processor.
-     *
-     * @param consumer the consumer
-     * @throws Exception can be thrown
-     */
-    public void disconnect(HttpConsumer consumer) throws Exception {
-    }
-
-    /** 
      * Creates the HttpClientConfigurer based on the given parameters
      * 
      * @param parameters the map of parameters 
@@ -311,11 +290,6 @@ public class HttpComponent extends HeaderFilterStrategyComponent {
         return new HttpEndpoint(uri, component, clientParams, connectionManager, configurer);
     }
     
-    @Override
-    protected boolean useIntrospectionOnEndpoint() {
-        return false;
-    }
-
     public HttpClientConfigurer getHttpClientConfigurer() {
         return httpClientConfigurer;
     }
@@ -338,26 +312,4 @@ public class HttpComponent extends HeaderFilterStrategyComponent {
         this.httpConnectionManager = httpConnectionManager;
     }
 
-    public HttpBinding getHttpBinding() {
-        return httpBinding;
-    }
-
-    /**
-     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-     */
-    public void setHttpBinding(HttpBinding httpBinding) {
-        this.httpBinding = httpBinding;
-    }
-
-    public HttpConfiguration getHttpConfiguration() {
-        return httpConfiguration;
-    }
-
-    /**
-     * To use the shared HttpConfiguration as base configuration.
-     */
-    public void setHttpConfiguration(HttpConfiguration httpConfiguration) {
-        this.httpConfiguration = httpConfiguration;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b48be21c/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index ad84bdf..f79d07d 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -45,6 +45,7 @@
     <module>camel-bam</module>
     <module>camel-groovy</module>
     <module>camel-scala</module>
+    <module>camel-http-common</module>
     <module>camel-http</module>
     <module>camel-http4</module>
     <module>camel-jetty-common</module>


[17/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 05019f6f0d63447ca9f9e3bc22bd0671580d5433
Parents: ac1f1af
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 11:31:35 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:34 2015 +0200

----------------------------------------------------------------------
 components/camel-gae/pom.xml                    | 49 ++++++++++----------
 .../gae/bind/HttpBindingInvocationHandler.java  |  4 +-
 .../camel/component/gae/http/GHttpBinding.java  |  2 -
 .../component/gae/http/GHttpComponent.java      | 13 +-----
 .../camel/component/gae/http/GHttpEndpoint.java | 16 ++-----
 .../camel/component/gae/task/GTaskBinding.java  |  7 +--
 .../component/gae/task/GTaskComponent.java      | 15 ++----
 .../camel/component/gae/task/GTaskEndpoint.java | 12 ++---
 .../component/gae/task/GTaskBindingTest.java    |  2 +-
 9 files changed, 43 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-gae/pom.xml b/components/camel-gae/pom.xml
index 981e395..3b537c5 100644
--- a/components/camel-gae/pom.xml
+++ b/components/camel-gae/pom.xml
@@ -15,7 +15,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
@@ -30,18 +31,18 @@
   <description>Camel GAE support</description>
 
   <properties>
-        <camel.osgi.import.before.defaults>
-            javax.servlet.*;version="${servlet-version-range}"
-        </camel.osgi.import.before.defaults>
-	<camel.osgi.export.pkg>org.apache.camel.component.gae.*</camel.osgi.export.pkg>
-	<camel.osgi.export.service>
-		org.apache.camel.spi.ComponentResolver;component=gauth,
-		org.apache.camel.spi.ComponentResolver;component=ghttp,
-		org.apache.camel.spi.ComponentResolver;component=ghttps,
-		org.apache.camel.spi.ComponentResolver;component=glogin,
-		org.apache.camel.spi.ComponentResolver;component=gmail,
-		org.apache.camel.spi.ComponentResolver;component=gtask
-	</camel.osgi.export.service>
+    <camel.osgi.import.before.defaults>
+      javax.servlet.*;version="${servlet-version-range}"
+    </camel.osgi.import.before.defaults>
+    <camel.osgi.export.pkg>org.apache.camel.component.gae.*</camel.osgi.export.pkg>
+    <camel.osgi.export.service>
+      org.apache.camel.spi.ComponentResolver;component=gauth,
+      org.apache.camel.spi.ComponentResolver;component=ghttp,
+      org.apache.camel.spi.ComponentResolver;component=ghttps,
+      org.apache.camel.spi.ComponentResolver;component=glogin,
+      org.apache.camel.spi.ComponentResolver;component=gmail,
+      org.apache.camel.spi.ComponentResolver;component=gtask
+    </camel.osgi.export.service>
   </properties>
 
   <dependencies>
@@ -134,15 +135,15 @@
     </dependency>
   </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <forkCount>1</forkCount>
-		    <reuseForks>false</reuseForks>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkCount>1</forkCount>
+          <reuseForks>false</reuseForks>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java b/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java
index 21328e5..e2229ea 100644
--- a/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java
+++ b/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java
@@ -21,8 +21,8 @@ import java.lang.reflect.Method;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
-import org.apache.camel.component.http.HttpBinding;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.http.common.HttpBinding;
+import org.apache.camel.http.common.HttpMessage;
 
 /**
  * Post-processes {@link HttpBinding} invocations by delegating to an

http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java b/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java
index 1493edd..fd86339 100644
--- a/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java
+++ b/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java
@@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.zip.GZIPInputStream;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -28,7 +27,6 @@ import com.google.appengine.api.urlfetch.HTTPHeader;
 import com.google.appengine.api.urlfetch.HTTPMethod;
 import com.google.appengine.api.urlfetch.HTTPRequest;
 import com.google.appengine.api.urlfetch.HTTPResponse;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.gae.bind.InboundBinding;

http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java b/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java
index 1aaa6b1..c5bb708 100644
--- a/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java
+++ b/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java
@@ -18,21 +18,16 @@ package org.apache.camel.component.gae.http;
 
 import java.net.URI;
 import java.util.Map;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.google.appengine.api.urlfetch.HTTPRequest;
 import com.google.appengine.api.urlfetch.HTTPResponse;
-
 import org.apache.camel.Endpoint;
 import org.apache.camel.component.gae.bind.InboundBinding;
 import org.apache.camel.component.gae.bind.OutboundBinding;
-import org.apache.camel.component.http.HttpClientConfigurer;
 import org.apache.camel.component.servlet.ServletComponent;
 import org.apache.camel.component.servlet.ServletEndpoint;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
 
 /**
  * The <a href="http://camel.apache.org/ghttp.html">Google App Engine HTTP
@@ -65,11 +60,7 @@ public class GHttpComponent extends ServletComponent {
     }
 
     @Override
-    protected ServletEndpoint createServletEndpoint(String endpointUri,
-            ServletComponent component, URI httpUri, HttpClientParams params,
-            HttpConnectionManager httpConnectionManager,
-            HttpClientConfigurer clientConfigurer) throws Exception {
-        return new GHttpEndpoint(endpointUri, component, httpUri, params,
-                httpConnectionManager, clientConfigurer);
+    protected ServletEndpoint createServletEndpoint(String endpointUri, ServletComponent component, URI httpUri) throws Exception {
+        return new GHttpEndpoint(endpointUri, component, httpUri);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java b/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java
index 897a09b..75e3cf7 100644
--- a/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java
+++ b/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java
@@ -34,15 +34,12 @@ import org.apache.camel.component.gae.bind.HttpBindingInvocationHandler;
 import org.apache.camel.component.gae.bind.InboundBinding;
 import org.apache.camel.component.gae.bind.OutboundBinding;
 import org.apache.camel.component.gae.bind.OutboundBindingSupport;
-import org.apache.camel.component.http.HttpBinding;
-import org.apache.camel.component.http.HttpClientConfigurer;
 import org.apache.camel.component.servlet.ServletComponent;
 import org.apache.camel.component.servlet.ServletEndpoint;
+import org.apache.camel.http.common.HttpBinding;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
 
 /**
  * Represents a <a href="http://camel.apache.org/ghttp.html">Google App Engine
@@ -62,12 +59,9 @@ public class GHttpEndpoint extends ServletEndpoint implements OutboundBindingSup
     private OutboundBinding<GHttpEndpoint, HTTPRequest, HTTPResponse> outboundBinding;
     private InboundBinding<GHttpEndpoint, HttpServletRequest, HttpServletResponse> inboundBinding;
     
-    public GHttpEndpoint(String endpointUri, ServletComponent component,
-            URI httpUri, HttpClientParams params,
-            HttpConnectionManager httpConnectionManager,
-            HttpClientConfigurer clientConfigurer) throws URISyntaxException {
+    public GHttpEndpoint(String endpointUri, ServletComponent component, URI httpUri) throws URISyntaxException {
         // set the endpoint uri with httpUri as we need to create http producer here
-        super(httpUri.toString(), component, httpUri, params, httpConnectionManager, clientConfigurer);
+        super(httpUri.toString(), component, httpUri);
         urlFetchService = URLFetchServiceFactory.getURLFetchService();
     }
 
@@ -129,12 +123,12 @@ public class GHttpEndpoint extends ServletEndpoint implements OutboundBindingSup
     }
 
     /**
-     * Proxies the {@link HttpBinding} returned by {@link super#getBinding()}
+     * Proxies the {@link org.apache.camel.http.common.HttpBinding} returned by {@link super#getBinding()}
      * with a dynamic proxy. The proxy's invocation handler further delegates to
      * {@link InboundBinding#readRequest(org.apache.camel.Endpoint, Exchange, Object)}
      * .
      * 
-     * @return proxied {@link HttpBinding}.
+     * @return proxied {@link org.apache.camel.http.common.HttpBinding}.
      */
     @Override
     public HttpBinding getBinding() {

http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java b/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java
index 1ca9acd..ba971d3 100644
--- a/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java
+++ b/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java
@@ -20,19 +20,16 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.google.appengine.api.taskqueue.TaskOptions;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.gae.bind.InboundBinding;
 import org.apache.camel.component.gae.bind.OutboundBinding;
-import org.apache.camel.component.http.DefaultHttpBinding;
-import org.apache.camel.component.http.HttpMessage;
 import org.apache.camel.spi.HeaderFilterStrategy;
 
 /**
  * Binds the {@link TaskOptions} of the task queueing service to a Camel
  * {@link Exchange} for outbound communication. For inbound communication a
- * {@link HttpMessage} is bound to {@link Exchange}.
+ * {@link org.apache.camel.http.common.HttpMessage} is bound to {@link Exchange}.
  */
 public class GTaskBinding implements 
     OutboundBinding <GTaskEndpoint, TaskOptions, Void>,
@@ -98,7 +95,7 @@ public class GTaskBinding implements
      * @see GTaskBinding#GTASK_QUEUE_NAME
      * @see GTaskBinding#GTASK_TASK_NAME
      * @see GTaskBinding#GTASK_RETRY_COUNT
-     * @see DefaultHttpBinding#readRequest(HttpServletRequest, HttpMessage)
+     * @see org.apache.camel.http.common.DefaultHttpBinding#readRequest(HttpServletRequest, org.apache.camel.http.common.HttpMessage)
      */
     public Exchange readRequest(GTaskEndpoint endpoint, Exchange exchange, HttpServletRequest request) {
         readRequestHeaders(endpoint, exchange, request);

http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java b/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java
index d248d5d..da029e6 100644
--- a/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java
+++ b/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java
@@ -18,22 +18,17 @@ package org.apache.camel.component.gae.task;
 
 import java.net.URI;
 import java.util.Map;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.google.appengine.api.taskqueue.QueueFactory;
 import com.google.appengine.api.taskqueue.TaskOptions;
-
 import org.apache.camel.Endpoint;
 import org.apache.camel.component.gae.bind.InboundBinding;
 import org.apache.camel.component.gae.bind.OutboundBinding;
-import org.apache.camel.component.http.HttpClientConfigurer;
-import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.servlet.ServletComponent;
 import org.apache.camel.component.servlet.ServletEndpoint;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.camel.http.common.HttpConsumer;
 
 /**
  * The <a href="http://camel.apache.org/gtask.html">Google App Engine Task
@@ -79,12 +74,8 @@ public class GTaskComponent extends ServletComponent {
     }
 
     @Override
-    protected ServletEndpoint createServletEndpoint(String endpointUri,
-            ServletComponent component, URI httpUri, HttpClientParams params,
-            HttpConnectionManager httpConnectionManager,
-            HttpClientConfigurer clientConfigurer) throws Exception {
-        return new GTaskEndpoint(endpointUri, component, httpUri, params,
-                httpConnectionManager, clientConfigurer);
+    protected ServletEndpoint createServletEndpoint(String endpointUri, ServletComponent component, URI httpUri) throws Exception {
+        return new GTaskEndpoint(endpointUri, component, httpUri);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java b/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java
index 371094e..e688d67 100644
--- a/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java
+++ b/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java
@@ -30,16 +30,13 @@ import org.apache.camel.component.gae.bind.HttpBindingInvocationHandler;
 import org.apache.camel.component.gae.bind.InboundBinding;
 import org.apache.camel.component.gae.bind.OutboundBinding;
 import org.apache.camel.component.gae.bind.OutboundBindingSupport;
-import org.apache.camel.component.http.HttpBinding;
-import org.apache.camel.component.http.HttpClientConfigurer;
 import org.apache.camel.component.servlet.ServletComponent;
 import org.apache.camel.component.servlet.ServletEndpoint;
+import org.apache.camel.http.common.HttpBinding;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
 
 /**
  * Represents a <a href="http://camel.apache.org/gtask.html">Google App Engine Task Queueing endpoint</a>.
@@ -61,11 +58,8 @@ public class GTaskEndpoint extends ServletEndpoint implements OutboundBindingSup
     @UriParam(label = "producer")
     private String outboundBindingRef;
 
-    public GTaskEndpoint(String endpointUri, ServletComponent component,
-            URI httpUri, HttpClientParams params,
-            HttpConnectionManager httpConnectionManager,
-            HttpClientConfigurer clientConfigurer) throws URISyntaxException {
-        super(endpointUri, component, httpUri, params, httpConnectionManager, clientConfigurer);
+    public GTaskEndpoint(String endpointUri, ServletComponent component, URI httpUri) throws URISyntaxException {
+        super(endpointUri, component, httpUri);
     }
 
     public OutboundBinding<GTaskEndpoint, TaskOptions, Void> getOutboundBinding() {

http://git-wip-us.apache.org/repos/asf/camel/blob/05019f6f/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java b/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java
index 8cc42df..0154529 100644
--- a/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java
+++ b/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java
@@ -27,7 +27,7 @@ import com.google.appengine.api.taskqueue.dev.QueueStateInfo.TaskStateInfo;
 import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
 import com.google.appengine.tools.development.testing.LocalTaskQueueTestConfig;
 import org.apache.camel.Exchange;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.http.common.HttpMessage;
 import org.apache.camel.impl.DefaultExchange;
 import org.junit.After;
 import org.junit.Before;


[21/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: be77f1a08acee401b62686bc6db3109cfaa4263e
Parents: f899941
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 13:30:52 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:35 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/http/common/HttpHelper.java    |  34 ++
 components/camel-http4/pom.xml                  | 147 +++---
 .../camel/component/http4/CamelServlet.java     | 116 -----
 .../component/http4/DefaultHttpBinding.java     | 461 -----------------
 .../camel/component/http4/HttpBinding.java      | 162 ------
 .../camel/component/http4/HttpComponent.java    |  49 +-
 .../camel/component/http4/HttpConsumer.java     |  69 ---
 .../camel/component/http4/HttpConverter.java    | 101 ----
 .../camel/component/http4/HttpEndpoint.java     | 279 +----------
 .../http4/HttpHeaderFilterStrategy.java         |  52 --
 .../camel/component/http4/HttpMessage.java      |  82 ---
 .../http4/HttpOperationFailedException.java     |  75 ---
 .../component/http4/HttpPollingConsumer.java    |   2 +-
 .../camel/component/http4/HttpProducer.java     |  12 +-
 .../http4/HttpProtocolHeaderFilterStrategy.java |  88 ----
 .../component/http4/HttpServletUrlRewrite.java  |  45 --
 .../camel/component/http4/UrlRewrite.java       |  41 --
 .../http4/helper/CamelFileDataSource.java       |  53 --
 .../component/http4/helper/HttpHelper.java      | 498 -------------------
 .../http4/helper/HttpMethodHelper.java          |  82 +++
 .../UrlRewriteHttpServletRequestAdapter.java    |  50 --
 .../services/org/apache/camel/TypeConverter     |   1 -
 .../camel/component/http4/GoogleUrlRewrite.java |   1 +
 ...tpEndpointOptionsNotChangeComponentTest.java |   8 +-
 .../http4/HttpHeaderFilterStrategyTest.java     |   1 +
 .../camel/component/http4/HttpRedirectTest.java |   1 +
 .../http4/HttpReferenceParameterTest.java       |   5 +-
 .../http4/HttpThrowExceptionOnFailureTest.java  |   1 +
 .../component/http4/helper/HttpHelperTest.java  |  11 +-
 29 files changed, 252 insertions(+), 2275 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/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 e7311b0..2a7189a 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
@@ -21,6 +21,7 @@ import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.OutputStream;
+import java.net.ProtocolException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -52,6 +53,39 @@ public final class HttpHelper {
         // Helper class
     }
 
+    public static boolean isSecureConnection(String uri) {
+        return uri.startsWith("https");
+    }
+
+    public static int[] parserHttpVersion(String s) throws ProtocolException {
+        int major;
+        int minor;
+        if (s == null) {
+            throw new IllegalArgumentException("String may not be null");
+        }
+        if (!s.startsWith("HTTP/")) {
+            throw new ProtocolException("Invalid HTTP version string: " + s);
+        }
+        int i1 = "HTTP/".length();
+        int i2 = s.indexOf(".", i1);
+        if (i2 == -1) {
+            throw new ProtocolException("Invalid HTTP version number: " + s);
+        }
+        try {
+            major = Integer.parseInt(s.substring(i1, i2));
+        } catch (NumberFormatException e) {
+            throw new ProtocolException("Invalid HTTP major version number: " + s);
+        }
+        i1 = i2 + 1;
+        i2 = s.length();
+        try {
+            minor = Integer.parseInt(s.substring(i1, i2));
+        } catch (NumberFormatException e) {
+            throw new ProtocolException("Invalid HTTP minor version number: " + s);
+        }
+        return new int[]{major, minor};
+    }
+
     @SuppressWarnings("deprecation")
     public static void setCharsetFromContentType(String contentType, Exchange exchange) {
         if (contentType != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-http4/pom.xml b/components/camel-http4/pom.xml
index 4ce95aa..e1f4edf 100644
--- a/components/camel-http4/pom.xml
+++ b/components/camel-http4/pom.xml
@@ -15,85 +15,86 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
 
-    <parent>
-        <groupId>org.apache.camel</groupId>
-        <artifactId>components</artifactId>
-        <version>2.16-SNAPSHOT</version>
-    </parent>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.16-SNAPSHOT</version>
+  </parent>
 
-    <artifactId>camel-http4</artifactId>
-    <packaging>bundle</packaging>
-    <name>Camel :: HTTP4</name>
-    <description>Camel HTTP (Apache HttpClient 4.x) support</description>
+  <artifactId>camel-http4</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: HTTP4</name>
+  <description>Camel HTTP (Apache HttpClient 4.x) support</description>
 
-    <properties>
-      <!-- CAMEL-7010 Now we move to HttpClient 4.3 API -->
-      <camel.osgi.import.before.defaults>
-        javax.servlet.*;version="${servlet-version-range}",
-        org.apache.http.*;version="[4.3,5)"
-      </camel.osgi.import.before.defaults>
-      <camel.osgi.export.pkg>org.apache.camel.component.http4.*</camel.osgi.export.pkg>
-      <camel.osgi.export.service>
-        org.apache.camel.spi.ComponentResolver;component=http4,
-        org.apache.camel.spi.ComponentResolver;component=https4
-      </camel.osgi.export.service>
-    </properties>
+  <properties>
+    <!-- CAMEL-7010 Now we move to HttpClient 4.3 API -->
+    <camel.osgi.import.before.defaults>
+      javax.servlet.*;version="${servlet-version-range}",
+      org.apache.http.*;version="[4.3,5)"
+    </camel.osgi.import.before.defaults>
+    <camel.osgi.export.pkg>org.apache.camel.component.http4.*</camel.osgi.export.pkg>
+    <camel.osgi.export.service>
+      org.apache.camel.spi.ComponentResolver;component=http4,
+      org.apache.camel.spi.ComponentResolver;component=https4
+    </camel.osgi.export.service>
+  </properties>
 
-    <dependencies>
+  <dependencies>
 
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-servlet_3.0_spec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
-        </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpclient4-version}</version>
+    </dependency>
 
-        <!-- testing -->
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>${httpclient4-version}</version>
-            <classifier>tests</classifier>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpclient4-version}</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <plugins>
-            <!-- use per test fork mode to avoid side effects -->
-            <plugin>
-              <artifactId>maven-surefire-plugin</artifactId>
-              <configuration>
-		  <forkCount>1</forkCount>
-		  <reuseForks>false</reuseForks>
-              </configuration>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <!-- use per test fork mode to avoid side effects -->
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkCount>1</forkCount>
+          <reuseForks>false</reuseForks>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
deleted file mode 100644
index ca5de47..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * 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.http4;
-
-import java.io.IOException;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.component.http4.helper.HttpHelper;
-import org.apache.camel.impl.DefaultExchange;
-
-/**
- * @version 
- */
-@Deprecated
-public class CamelServlet extends HttpServlet {
-
-    private static final long serialVersionUID = -7061982839117697829L;
-
-    private ConcurrentMap<String, HttpConsumer> consumers = new ConcurrentHashMap<String, HttpConsumer>();
-   
-    @Override
-    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        try {
-
-            // Is there a consumer registered for the request.
-            HttpConsumer consumer = resolve(request);
-            if (consumer == null) {
-                response.sendError(HttpServletResponse.SC_NOT_FOUND);
-                return;
-            }
-            
-            if (consumer.getEndpoint().getHttpMethodRestrict() != null 
-                && !consumer.getEndpoint().getHttpMethodRestrict().equals(request.getMethod())) {
-                response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
-                return;
-            }
-
-            if ("TRACE".equals(request.getMethod()) && !consumer.isTraceEnabled()) {
-                response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
-                return;
-            }
-            
-            // Have the camel process the HTTP exchange.
-            DefaultExchange exchange = new DefaultExchange(consumer.getEndpoint(), ExchangePattern.InOut);
-            if (consumer.getEndpoint().isBridgeEndpoint()) {
-                exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE);
-                exchange.setProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
-            }
-            if (consumer.getEndpoint().isDisableStreamCache()) {
-                exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE);
-            }
-            HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
-            exchange.setIn(new HttpMessage(exchange, request, response));
-            // set context path as header
-            String contextPath = consumer.getEndpoint().getPath();
-            exchange.getIn().setHeader("CamelServletContextPath", contextPath);
-
-            consumer.getProcessor().process(exchange);
-
-            // now lets output to the response
-            consumer.getBinding().writeResponse(exchange, response);
-
-        } catch (Exception e) {
-            throw new ServletException(e);
-        }
-    }
-
-    protected HttpConsumer resolve(HttpServletRequest request) {
-        String path = request.getPathInfo();
-        if (path == null) {
-            return null;
-        }
-        HttpConsumer answer = consumers.get(path);
-               
-        if (answer == null) {
-            for (String key : consumers.keySet()) {
-                if (consumers.get(key).getEndpoint().isMatchOnUriPrefix() && path.startsWith(key)) {
-                    answer = consumers.get(key);
-                    break;
-                }
-            }
-        }
-        return answer;
-    }
-
-    public void connect(HttpConsumer consumer) {
-        consumers.put(consumer.getPath(), consumer);
-    }
-
-    public void disconnect(HttpConsumer consumer) {
-        consumers.remove(consumer.getPath());
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
deleted file mode 100644
index 4420c69..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/**
- * 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.http4;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.net.URLDecoder;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.activation.DataHandler;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.InvalidPayloadException;
-import org.apache.camel.Message;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.StreamCache;
-import org.apache.camel.component.http4.helper.CamelFileDataSource;
-import org.apache.camel.component.http4.helper.HttpHelper;
-import org.apache.camel.converter.stream.CachedOutputStream;
-import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.util.GZIPHelper;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.MessageHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Binding between {@link HttpMessage} and {@link HttpServletResponse}.
- * <p/>
- * Uses by default the {@link org.apache.camel.component.http4.HttpHeaderFilterStrategy}
- *
- * @version 
- */
-public class DefaultHttpBinding implements HttpBinding {
-
-    private static final Logger LOG = LoggerFactory.getLogger(DefaultHttpBinding.class);
-    private boolean useReaderForPayload;
-    private boolean transferException;
-    private boolean eagerCheckContentAvailable;
-    private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
-
-    public DefaultHttpBinding() {
-    }
-
-    @Deprecated
-    public DefaultHttpBinding(HeaderFilterStrategy headerFilterStrategy) {
-        this.headerFilterStrategy = headerFilterStrategy;
-    }
-
-    @Deprecated
-    public DefaultHttpBinding(HttpEndpoint endpoint) {
-        this.headerFilterStrategy = endpoint.getHeaderFilterStrategy();
-        this.transferException = endpoint.isTransferException();
-    }
-
-    public void readRequest(HttpServletRequest request, HttpMessage message) {
-        // lets force a parse of the body and headers
-        message.getBody();
-        // populate the headers from the request
-        Map<String, Object> headers = message.getHeaders();
-
-        //apply the headerFilterStrategy
-        Enumeration<?> names = request.getHeaderNames();
-        while (names.hasMoreElements()) {
-            String name = (String) names.nextElement();
-            Object value = request.getHeader(name);
-            // mapping the content-type 
-            if (name.toLowerCase().equals("content-type")) {
-                name = Exchange.CONTENT_TYPE;
-            }
-            if (headerFilterStrategy != null
-                    && !headerFilterStrategy.applyFilterToExternalHeaders(name, value, message.getExchange())) {
-                HttpHelper.appendHeader(headers, name, value);
-            }
-        }
-
-        if (request.getCharacterEncoding() != null) {
-            headers.put(Exchange.HTTP_CHARACTER_ENCODING, request.getCharacterEncoding());
-            message.getExchange().setProperty(Exchange.CHARSET_NAME, request.getCharacterEncoding());
-        }
-
-        try {
-            populateRequestParameters(request, message);
-        } catch (Exception e) {
-            throw new RuntimeCamelException("Cannot read request parameters due " + e.getMessage(), e);
-        }
-
-        Object body = message.getBody();
-        // reset the stream cache if the body is the instance of StreamCache
-        if (body instanceof StreamCache) {
-            ((StreamCache) body).reset();
-        }
-
-        // store the method and query and other info in headers
-        headers.put(Exchange.HTTP_METHOD, request.getMethod());
-        headers.put(Exchange.HTTP_QUERY, request.getQueryString());
-        headers.put(Exchange.HTTP_URL, request.getRequestURL());
-        headers.put(Exchange.HTTP_URI, request.getRequestURI());
-        headers.put(Exchange.HTTP_PATH, request.getPathInfo());
-        headers.put(Exchange.CONTENT_TYPE, request.getContentType());
-
-        // if content type is serialized java object, then de-serialize it to a Java object
-        if (request.getContentType() != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(request.getContentType())) {
-            try {
-                InputStream is = message.getExchange().getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, body);
-                Object object = HttpHelper.deserializeJavaObjectFromStream(is, message.getExchange().getContext());
-                if (object != null) {
-                    message.setBody(object);
-                }
-            } catch (Exception e) {
-                throw new RuntimeCamelException("Cannot deserialize body to Java object", e);
-            }
-        }
-
-        populateAttachments(request, message);
-    }
-
-    protected void populateRequestParameters(HttpServletRequest request, HttpMessage message) throws Exception {
-        //we populate the http request parameters without checking the request method
-        Map<String, Object> headers = message.getHeaders();
-        Enumeration<?> names = request.getParameterNames();
-        while (names.hasMoreElements()) {
-            String name = (String) names.nextElement();
-            // there may be multiple values for the same name
-            String[] values = request.getParameterValues(name);
-            LOG.trace("HTTP parameter {} = {}", name, values);
-
-            if (values != null) {
-                for (String value : values) {
-                    if (headerFilterStrategy != null
-                        && !headerFilterStrategy.applyFilterToExternalHeaders(name, value, message.getExchange())) {
-                        HttpHelper.appendHeader(headers, name, value);
-                    }
-                }
-            }
-        }
-        Boolean flag = message.getHeader(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.class);
-        boolean skipWwwFormUrlEncoding =  flag != null ? flag : false; 
-        if (request.getMethod().equals("POST") && request.getContentType() != null
-                && request.getContentType().startsWith(HttpConstants.CONTENT_TYPE_WWW_FORM_URLENCODED)
-                && !skipWwwFormUrlEncoding) {
-            String charset = request.getCharacterEncoding();
-            if (charset == null) {
-                charset = "UTF-8";
-            }
-            // Push POST form params into the headers to retain compatibility with DefaultHttpBinding
-            String body = message.getBody(String.class);
-            if (ObjectHelper.isNotEmpty(body)) {
-                for (String param : body.split("&")) {
-                    String[] pair = param.split("=", 2);
-                    if (pair.length == 2) {
-                        String name = URLDecoder.decode(pair[0], charset);
-                        String value = URLDecoder.decode(pair[1], charset);
-                        if (headerFilterStrategy != null
-                                && !headerFilterStrategy.applyFilterToExternalHeaders(name, value, message.getExchange())) {
-                            headers.put(name, value);
-                        }
-                    } else {
-                        throw new IllegalArgumentException("Invalid parameter, expected to be a pair but was " + param);
-                    }
-                }
-            }
-        }
-    }
-
-    protected void populateAttachments(HttpServletRequest request, HttpMessage message) {
-        // check if there is multipart files, if so will put it into DataHandler
-        Enumeration<?> names = request.getAttributeNames();
-        while (names.hasMoreElements()) {
-            String name = (String) names.nextElement();
-            Object object = request.getAttribute(name);
-            if (object instanceof File) {
-                String fileName = request.getParameter(name);
-                message.addAttachment(fileName, new DataHandler(new CamelFileDataSource((File) object, fileName)));
-            }
-        }
-    }
-
-    public void writeResponse(Exchange exchange, HttpServletResponse response) throws IOException {
-        if (exchange.isFailed()) {
-            if (exchange.getException() != null) {
-                doWriteExceptionResponse(exchange.getException(), response);
-            } else {
-                // it must be a fault, no need to check for the fault flag on the message
-                doWriteFaultResponse(exchange.getOut(), response, exchange);
-            }
-        } else {
-            // just copy the protocol relates header
-            copyProtocolHeaders(exchange.getIn(), exchange.getOut());
-            Message out = exchange.getOut();
-            if (out != null) {
-                doWriteResponse(out, response, exchange);
-            }
-        }
-    }
-
-    private void copyProtocolHeaders(Message request, Message response) {
-        if (request.getHeader(Exchange.CONTENT_ENCODING) != null) {
-            String contentEncoding = request.getHeader(Exchange.CONTENT_ENCODING, String.class);
-            response.setHeader(Exchange.CONTENT_ENCODING, contentEncoding);
-        }
-        if (checkChunked(response, response.getExchange())) {
-            response.setHeader(Exchange.TRANSFER_ENCODING, "chunked");
-        }
-    }
-
-    public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException {
-        // 500 for internal server error
-        response.setStatus(500);
-        if (isTransferException()) {
-            // transfer the exception as a serialized java object
-            HttpHelper.writeObjectToServletResponse(response, exception);
-        } else {
-            // write stacktrace as plain text
-            response.setContentType("text/plain");
-            PrintWriter pw = response.getWriter();
-            exception.printStackTrace(pw);
-            pw.flush();
-        }
-    }
-
-    public void doWriteFaultResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
-        message.setHeader(Exchange.HTTP_RESPONSE_CODE, 500);
-        doWriteResponse(message, response, exchange);
-    }
-
-    public void doWriteResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
-        // set the status code in the response. Default is 200.
-        if (message.getHeader(Exchange.HTTP_RESPONSE_CODE) != null) {
-            int code = message.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
-            response.setStatus(code);
-        }
-        // set the content type in the response.
-        String contentType = MessageHelper.getContentType(message);
-        if (MessageHelper.getContentType(message) != null) {
-            response.setContentType(contentType);
-        }
-
-        // append headers
-        // must use entrySet to ensure case of keys is preserved
-        for (Map.Entry<String, Object> entry : message.getHeaders().entrySet()) {
-            String key = entry.getKey();
-            Object value = entry.getValue();
-            // use an iterator as there can be multiple values. (must not use a delimiter)
-            final Iterator<?> it = ObjectHelper.createIterator(value, null);
-            while (it.hasNext()) {
-                String headerValue = exchange.getContext().getTypeConverter().convertTo(String.class, it.next());
-                if (headerValue != null && headerFilterStrategy != null
-                        && !headerFilterStrategy.applyFilterToCamelHeaders(key, headerValue, exchange)) {
-                    response.addHeader(key, headerValue);
-                }
-            }
-        }
-
-        // write the body.
-        if (message.getBody() != null) {
-            if (GZIPHelper.isGzip(message)) {
-                doWriteGZIPResponse(message, response, exchange);
-            } else {
-                doWriteDirectResponse(message, response, exchange);
-            }
-        }
-    }
-    
-    protected boolean isText(String contentType) {
-        if (contentType != null) {
-            String temp = contentType.toLowerCase();
-            if (temp.indexOf("text") >= 0 || temp.indexOf("html") >= 0) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    protected void copyStream(InputStream is, OutputStream os) throws IOException {
-        try {
-            // copy directly from input stream to output stream
-            IOHelper.copy(is, os);
-        } finally {
-            IOHelper.close(os, is);
-        }
-    }
-
-    protected void doWriteDirectResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
-        // if content type is serialized Java object, then serialize and write it to the response
-        String contentType = message.getHeader(Exchange.CONTENT_TYPE, String.class);
-        if (contentType != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) {
-            try {
-                Object object = message.getMandatoryBody(Serializable.class);
-                HttpHelper.writeObjectToServletResponse(response, object);
-                // object is written so return
-                return;
-            } catch (InvalidPayloadException e) {
-                throw new IOException(e);
-            }
-        }
-
-        // prefer streaming
-        InputStream is = null;
-        if (checkChunked(message, exchange)) {
-            is = message.getBody(InputStream.class);
-        } else {
-         // try to use input stream first, so we can copy directly
-            if (!isText(contentType)) {
-                is = exchange.getContext().getTypeConverter().tryConvertTo(InputStream.class, message.getBody());
-            }
-        }
-
-        if (is != null) {
-            ServletOutputStream os = response.getOutputStream();
-            LOG.trace("Writing direct response from source input stream to servlet output stream");
-            if (!checkChunked(message, exchange)) {
-                CachedOutputStream stream = new CachedOutputStream(exchange);
-                try {
-                    // copy directly from input stream to the cached output stream to get the content length
-                    int len = IOHelper.copy(is, stream);
-                    // we need to setup the length if message is not chucked
-                    response.setContentLength(len);
-                    copyStream(stream.getInputStream(), os);
-                } finally {
-                    IOHelper.close(is, stream);
-                }
-            } else {
-                copyStream(is, os);
-            }
-        } else {
-            // not convertable as a stream so try as a String
-            String data = message.getBody(String.class);
-            if (data != null) {
-                LOG.debug("Cannot write from source input stream, falling back to using String content. For binary content this can be a problem.");
-                // set content length before we write data
-                String charset = IOHelper.getCharsetName(exchange, true);
-                final int dataByteLength = data.getBytes(charset).length;
-                response.setCharacterEncoding(charset);
-                response.setContentLength(dataByteLength);
-                try {
-                    response.getWriter().print(data);
-                } finally {
-                    response.getWriter().flush();
-                }
-            }
-        }
-    }
-
-    protected boolean checkChunked(Message message, Exchange exchange) {
-        boolean answer = true;
-        if (message.getHeader(Exchange.HTTP_CHUNKED) == null) {
-            // check the endpoint option
-            Endpoint endpoint = exchange.getFromEndpoint();
-            if (endpoint instanceof HttpEndpoint) {
-                answer = ((HttpEndpoint) endpoint).isChunked();
-            }
-        } else {
-            answer = message.getHeader(Exchange.HTTP_CHUNKED, boolean.class);
-        }
-        return answer;
-    }
-
-    protected void doWriteGZIPResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
-        byte[] bytes;
-        try {
-            bytes = message.getMandatoryBody(byte[].class);
-        } catch (InvalidPayloadException e) {
-            throw ObjectHelper.wrapRuntimeCamelException(e);
-        }
-
-        byte[] data = GZIPHelper.compressGZIP(bytes);
-        ServletOutputStream os = response.getOutputStream();
-        try {
-            response.setContentLength(data.length);
-            os.write(data);
-            os.flush();
-        } finally {
-            IOHelper.close(os);
-        }
-    }
-
-    public Object parseBody(HttpMessage httpMessage) throws IOException {
-        // lets assume the body is a reader
-        HttpServletRequest request = httpMessage.getRequest();
-        // there is only a body if we have a content length, or its -1 to indicate unknown length
-        int len = request.getContentLength();
-        LOG.trace("HttpServletRequest content-length: {}", len);
-        if (len == 0) {
-            return null;
-        }
-        if (isUseReaderForPayload()) {
-            // use reader to read the response body
-            return request.getReader();
-        } else {
-            // if we do not know if there is any data at all, then make sure to check the stream first
-            if (len < 0 && isEagerCheckContentAvailable()) {
-                InputStream is = request.getInputStream();
-                if (is.available() == 0) {
-                    // no data so return null
-                    return null;
-                }
-            }
-            // read the response body from servlet request
-            return HttpHelper.readRequestBodyFromServletRequest(request, httpMessage.getExchange());
-        }
-    }
-
-    public boolean isUseReaderForPayload() {
-        return useReaderForPayload;
-    }
-
-    public void setUseReaderForPayload(boolean useReaderForPayload) {
-        this.useReaderForPayload = useReaderForPayload;
-    }
-
-    public boolean isEagerCheckContentAvailable() {
-        return eagerCheckContentAvailable;
-    }
-
-    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
-        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
-    }
-
-    public boolean isTransferException() {
-        return transferException;
-    }
-
-    public void setTransferException(boolean transferException) {
-        this.transferException = transferException;
-    }
-
-    public HeaderFilterStrategy getHeaderFilterStrategy() {
-        return headerFilterStrategy;
-    }
-
-    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
-        this.headerFilterStrategy = headerFilterStrategy;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java
deleted file mode 100644
index 3c8b87d..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpBinding.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * 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.http4;
-
-import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.spi.HeaderFilterStrategy;
-
-/**
- * A pluggable strategy for configuring the http binding so reading request and writing response
- * can be customized using the Java Servlet API.
- * <p/>
- * This is also used by the <tt>camel-jetty</tt> component in the <tt>JettyHttpConsumer</tt> class.
- *
- * @version 
- */
-public interface HttpBinding {
-
-    /**
-     * Strategy to read the given request and bindings it to the given message.
-     *
-     * @param request  the request
-     * @param message  the message to populate with data from request
-     */
-    void readRequest(HttpServletRequest request, HttpMessage message);
-
-    /**
-     * Parses the body from a {@link org.apache.camel.component.http4.HttpMessage}
-     *
-     * @param httpMessage the http message
-     * @return the parsed body returned as either a {@link java.io.InputStream} or a {@link java.io.Reader}
-     * depending on the {@link #setUseReaderForPayload(boolean)} property.
-     * @throws java.io.IOException can be thrown
-     */
-    Object parseBody(HttpMessage httpMessage) throws IOException;
-
-    /**
-     * Writes the exchange to the servlet response.
-     * <p/>
-     * Default implementation will delegate to the following methods depending on the status of the exchange
-     * <ul>
-     *   <li>doWriteResponse - processing returns a OUT message </li>
-     *   <li>doWriteFaultResponse - processing returns a fault message</li>
-     *   <li>doWriteResponse - processing returns an exception and status code 500</li>
-     * </ul>
-     *
-     * @param exchange the exchange
-     * @param response the http response
-     * @throws java.io.IOException can be thrown from http response
-     */
-    void writeResponse(Exchange exchange, HttpServletResponse response) throws IOException;
-
-    /**
-     * Strategy method that writes the response to the http response stream when an exception occurred
-     *
-     * @param exception  the exception occurred
-     * @param response   the http response
-     * @throws java.io.IOException can be thrown from http response
-     */
-    void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException;
-
-    /**
-     * Strategy method that writes the response to the http response stream for a fault message
-     *
-     * @param message  the fault message
-     * @param response the http response
-     * @param exchange the exchange to provide context for header filtering
-     * @throws java.io.IOException can be thrown from http response
-     */
-    void doWriteFaultResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException;
-
-    /**
-     * Strategy method that writes the response to the http response stream for an OUT message
-     *
-     * @param message  the OUT message
-     * @param response the http response
-     * @param exchange the exchange to provide context for header filtering
-     * @throws java.io.IOException can be thrown from http response
-     */
-    void doWriteResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException;
-
-    /**
-     * Should reader by used instead of input stream.
-     *
-     * @see #setUseReaderForPayload(boolean) for more details
-     * @return <tt>true</tt> if reader should be used
-     */
-    boolean isUseReaderForPayload();
-
-    /**
-     * Should the {@link javax.servlet.http.HttpServletRequest#getReader()} be exposed as the payload of input messages in the Camel
-     * {@link org.apache.camel.Message#getBody()} or not. If false then the {@link javax.servlet.http.HttpServletRequest#getInputStream()} will be exposed.
-     * <p/>
-     * Is default <tt>false</tt>.
-     *
-     * @param useReaderForPayload whether to use reader or not
-     */
-    void setUseReaderForPayload(boolean useReaderForPayload);
-
-    /**
-     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
-     * This can be turned on in case HTTP clients do not send streamed data.
-     */
-    boolean isEagerCheckContentAvailable();
-
-    /**
-     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
-     * This can be turned on in case HTTP clients do not send streamed data.
-     */
-    void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable);
-
-    /**
-     * 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 (for example using Jetty or
-     * Servlet Camel components). 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.
-     */
-    boolean isTransferException();
-
-    /**
-     * 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 (for example using Jetty or
-     * Servlet Camel components). 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.
-     */
-    void setTransferException(boolean transferException);
-
-    /**
-     * Gets the header filter strategy
-     *
-     * @return the strategy
-     */
-    HeaderFilterStrategy getHeaderFilterStrategy();
-
-    /**
-     * Sets the header filter strategy to use.
-     * <p/>
-     * Will default use {@link org.apache.camel.component.http4.HttpHeaderFilterStrategy}
-     *
-     * @param headerFilterStrategy the custom strategy
-     */
-    void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy);
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
index 9fc700d..a2be672 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
@@ -25,8 +25,11 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.ResolveEndpointFailedException;
-import org.apache.camel.component.http4.helper.HttpHelper;
-import org.apache.camel.impl.HeaderFilterStrategyComponent;
+import org.apache.camel.http.common.HttpBinding;
+import org.apache.camel.http.common.HttpCommonComponent;
+import org.apache.camel.http.common.HttpConfiguration;
+import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.UrlRewrite;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.ObjectHelper;
@@ -56,12 +59,12 @@ import org.slf4j.LoggerFactory;
  *
  * @version 
  */
-public class HttpComponent extends HeaderFilterStrategyComponent {
+public class HttpComponent extends HttpCommonComponent {
+
     private static final Logger LOG = LoggerFactory.getLogger(HttpComponent.class);
 
     protected HttpClientConfigurer httpClientConfigurer;
     protected HttpClientConnectionManager clientConnectionManager;
-    protected HttpBinding httpBinding;
     protected HttpContext httpContext;
     protected SSLContextParameters sslContextParameters;
     protected X509HostnameVerifier x509HostnameVerifier = new BrowserCompatHostnameVerifier();
@@ -77,22 +80,8 @@ public class HttpComponent extends HeaderFilterStrategyComponent {
         super(HttpEndpoint.class);
     }
 
-    /**
-     * Connects the URL specified on the endpoint to the specified processor.
-     *
-     * @param consumer the consumer
-     * @throws Exception can be thrown
-     */
-    public void connect(HttpConsumer consumer) throws Exception {
-    }
-
-    /**
-     * Disconnects the URL specified on the endpoint from the specified processor.
-     *
-     * @param consumer the consumer
-     * @throws Exception can be thrown
-     */
-    public void disconnect(HttpConsumer consumer) throws Exception {
+    public HttpComponent(Class<? extends HttpEndpoint> endpointClass) {
+        super(endpointClass);
     }
 
     /**
@@ -286,9 +275,9 @@ public class HttpComponent extends HeaderFilterStrategyComponent {
         } else {
             setEndpointHeaderFilterStrategy(endpoint);
         }
-        endpoint.setHttpBinding(getHttpBinding());
+        endpoint.setBinding(getHttpBinding());
         if (httpBinding != null) {
-            endpoint.setHttpBinding(httpBinding);
+            endpoint.setBinding(httpBinding);
         }
         if (httpMethodRestrict != null) {
             endpoint.setHttpMethodRestrict(httpMethodRestrict);
@@ -375,15 +364,21 @@ public class HttpComponent extends HeaderFilterStrategyComponent {
         this.clientConnectionManager = clientConnectionManager;
     }
 
-    public HttpBinding getHttpBinding() {
-        return httpBinding;
-    }
-
     /**
      * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
      */
     public void setHttpBinding(HttpBinding httpBinding) {
-        this.httpBinding = httpBinding;
+        // need to override and call super for component docs
+        super.setHttpBinding(httpBinding);
+    }
+
+    /**
+     * To use the shared HttpConfiguration as base configuration.
+     */
+    @Override
+    public void setHttpConfiguration(HttpConfiguration httpConfiguration) {
+        // need to override and call super for component docs
+        super.setHttpConfiguration(httpConfiguration);
     }
 
     public HttpContext getHttpContext() {

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java
deleted file mode 100644
index 1ddf687..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConsumer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * 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.http4;
-
-import org.apache.camel.Processor;
-import org.apache.camel.impl.DefaultConsumer;
-
-/**
- * @version 
- */
-@Deprecated
-public class HttpConsumer extends DefaultConsumer {
-
-    private boolean traceEnabled;
-
-    public HttpConsumer(HttpEndpoint endpoint, Processor processor) {
-        super(endpoint, processor);
-        if (endpoint.isTraceEnabled()) {
-            setTraceEnabled(true);
-        }
-    }
-
-    @Override
-    public HttpEndpoint getEndpoint() {
-        return (HttpEndpoint)super.getEndpoint();
-    }
-
-    public HttpBinding getBinding() {
-        return getEndpoint().getHttpBinding();
-    }
-
-    public String getPath() {
-        return getEndpoint().getPath();
-    }
-
-    @Override
-    protected void doStart() throws Exception {
-        super.doStart();
-        getEndpoint().connect(this);
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        getEndpoint().disconnect(this);
-        super.doStop();
-    }
-
-    public boolean isTraceEnabled() {
-        return traceEnabled;
-    }
-
-    public void setTraceEnabled(boolean traceEnabled) {
-        this.traceEnabled = traceEnabled;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConverter.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConverter.java
deleted file mode 100644
index dead494..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpConverter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * 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.http4;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Converter;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.util.GZIPHelper;
-
-/**
- * Some converter methods making it easy to convert the body of a message to servlet types or to switch between
- * the underlying {@link ServletInputStream} or {@link BufferedReader} payloads etc.
- *
- * @version 
- */
-@Converter
-public final class HttpConverter {
-
-    private HttpConverter() {
-    }
-
-    @Converter
-    public static HttpServletRequest toServletRequest(Message message) {
-        if (message == null) {
-            return null;
-        }
-        return message.getHeader(Exchange.HTTP_SERVLET_REQUEST, HttpServletRequest.class);
-    }
-
-    @Converter
-    public static HttpServletResponse toServletResponse(Message message) {
-        if (message == null) {
-            return null;
-        }
-        return message.getHeader(Exchange.HTTP_SERVLET_RESPONSE, HttpServletResponse.class);
-    }
-
-    @Converter
-    public static ServletInputStream toServletInputStream(HttpMessage message) throws IOException {
-        HttpServletRequest request = toServletRequest(message);
-        if (request != null) {
-            return request.getInputStream();
-        }
-        return null;
-    }
-
-    @Converter
-    public static InputStream toInputStream(HttpMessage message, Exchange exchange) throws Exception {
-        return toInputStream(toServletRequest(message), exchange);
-    }
-
-    @Converter
-    public static BufferedReader toReader(HttpMessage message) throws IOException {
-        HttpServletRequest request = toServletRequest(message);
-        if (request != null) {
-            return request.getReader();
-        }
-        return null;
-    }
-
-    @Converter
-    public static InputStream toInputStream(HttpServletRequest request, Exchange exchange) throws IOException {
-        if (request == null) {
-            return null;
-        }
-        InputStream is = request.getInputStream();
-        if (is != null && is.available() <= 0) {
-            // there is no data, so we cannot uncompress etc.
-            return is;
-        }
-        if (exchange == null || !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
-            String contentEncoding = request.getHeader(Exchange.CONTENT_ENCODING);
-            return GZIPHelper.uncompressGzip(contentEncoding, is);
-        } else {
-            return is;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
index c2c2c57..57e9795 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
@@ -23,14 +23,10 @@ import org.apache.camel.Consumer;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
-import org.apache.camel.component.http4.helper.HttpHelper;
-import org.apache.camel.impl.DefaultEndpoint;
-import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.spi.HeaderFilterStrategyAware;
-import org.apache.camel.spi.Metadata;
+import org.apache.camel.http.common.HttpCommonEndpoint;
+import org.apache.camel.http.common.HttpHelper;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
-import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.http.HttpHost;
 import org.apache.http.client.CookieStore;
@@ -49,50 +45,24 @@ import org.slf4j.LoggerFactory;
  * @version 
  */
 @UriEndpoint(scheme = "http4,http4s", title = "HTTP4,HTTP4S", syntax = "http4:httpUri", producerOnly = true, label = "http")
-public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware {
+public class HttpEndpoint extends HttpCommonEndpoint {
 
     private static final Logger LOG = LoggerFactory.getLogger(HttpEndpoint.class);
+
+    // Note: all options must be documented with description in annotations so extended components can access the documentation
+
     private HttpContext httpContext;
-    private HttpComponent component;
     private HttpClientConfigurer httpClientConfigurer;
     private HttpClientConnectionManager clientConnectionManager;
     private HttpClientBuilder clientBuilder;
-    private HttpClient httpClient;
-    private UrlRewrite urlRewrite;
-    private CookieStore cookieStore = new BasicCookieStore();
+    private  HttpClient httpClient;
 
-    @UriPath @Metadata(required = "true", label = "producer")
-    private URI httpUri;
-    @UriParam
-    private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
-    @UriParam
-    private HttpBinding httpBinding;
-    @UriParam(label = "producer", defaultValue = "true")
-    private boolean throwExceptionOnFailure = true;
     @UriParam(label = "producer")
-    private boolean bridgeEndpoint;
-    @UriParam(label = "consumer")
-    private boolean matchOnUriPrefix;
-    @UriParam(defaultValue = "true")
-    private boolean chunked = true;
-    @UriParam(label = "consumer")
-    private boolean disableStreamCache;
-    @UriParam
-    private boolean transferException;
-    @UriParam(label = "consumer")
-    private boolean traceEnabled;
+    private CookieStore cookieStore = new BasicCookieStore();
     @UriParam(label = "producer")
     private boolean authenticationPreemptive;
-    @UriParam(label = "consumer")
-    private String httpMethodRestrict;
     @UriParam(label = "producer", defaultValue = "true")
     private boolean clearExpiredCookies = true;
-    @UriParam(label = "producer")
-    private boolean ignoreResponseBody;
-    @UriParam(label = "producer", defaultValue = "true")
-    private boolean copyHeaders = true;
-    @UriParam(label = "consumer")
-    private boolean eagerCheckContentAvailable;
 
     public HttpEndpoint() {
     }
@@ -112,9 +82,7 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
 
     public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, HttpClientBuilder clientBuilder,
                         HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer) throws URISyntaxException {
-        super(endPointURI, component);
-        this.component = component;
-        this.httpUri = httpURI;
+        super(endPointURI, component, httpURI);
         this.clientBuilder = clientBuilder;
         this.httpClientConfigurer = clientConfigurer;
         this.clientConnectionManager = clientConnectionManager;
@@ -196,32 +164,19 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         return clientBuilder.build();
     }
 
-    public void connect(HttpConsumer consumer) throws Exception {
-        component.connect(consumer);
-    }
-
-    public void disconnect(HttpConsumer consumer) throws Exception {
-        component.disconnect(consumer);
-    }
-
-    public boolean isLenientProperties() {
-        // true to allow dynamic URI options to be configured and passed to external system for eg. the HttpProducer
-        return true;
+    @Override
+    public HttpComponent getComponent() {
+        return (HttpComponent) super.getComponent();
     }
 
-    public boolean isSingleton() {
-        return true;
-    }
-    
     @Override
     protected void doStop() throws Exception {
-        if (component != null && component.getClientConnectionManager() != clientConnectionManager) {
+        if (getComponent() != null && getComponent().getClientConnectionManager() != clientConnectionManager) {
             // need to shutdown the ConnectionManager
             clientConnectionManager.shutdown();
         }
     }
 
-
     // Properties
     //-------------------------------------------------------------------------
 
@@ -257,59 +212,10 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         this.httpClientConfigurer = httpClientConfigurer;
     }
 
-    public HttpBinding getHttpBinding() {
-        if (httpBinding == null) {
-            // create a new binding and use the options from this endpoint
-            httpBinding = new DefaultHttpBinding();
-            httpBinding.setHeaderFilterStrategy(getHeaderFilterStrategy());
-            httpBinding.setTransferException(isTransferException());
-            httpBinding.setEagerCheckContentAvailable(isEagerCheckContentAvailable());
-        }
-        return httpBinding;
-    }
-
-    /**
-     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-     */
-    public void setHttpBinding(HttpBinding httpBinding) {
-        this.httpBinding = httpBinding;
-    }
-
     public void setHttpContext(HttpContext httpContext) {
         this.httpContext = httpContext;
     }
 
-    public String getPath() {
-        //if the path is empty, we just return the default path here
-        return httpUri.getPath().length() == 0 ? "/" : httpUri.getPath();
-    }
-
-    public int getPort() {
-        if (httpUri.getPort() == -1) {
-            if ("https".equals(getProtocol()) || "https4".equals(getProtocol())) {
-                return 443;
-            } else {
-                return 80;
-            }
-        }
-        return httpUri.getPort();
-    }
-
-    public String getProtocol() {
-        return httpUri.getScheme();
-    }
-
-    public URI getHttpUri() {
-        return httpUri;
-    }
-
-    /**
-     * The url of the HTTP endpoint to call.
-     */
-    public void setHttpUri(URI httpUri) {
-        this.httpUri = httpUri;
-    }
-
     public HttpClientConnectionManager getClientConnectionManager() {
         return clientConnectionManager;
     }
@@ -321,131 +227,6 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         this.clientConnectionManager = clientConnectionManager;
     }
 
-    public HeaderFilterStrategy getHeaderFilterStrategy() {
-        return headerFilterStrategy;
-    }
-
-    /**
-     * To use a custom HeaderFilterStrategy to filter header to and from Camel message.
-     */
-    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
-        this.headerFilterStrategy = headerFilterStrategy;
-    }
-
-    public boolean isThrowExceptionOnFailure() {
-        return throwExceptionOnFailure;
-    }
-
-    /**
-     * 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.
-     */
-    public void setThrowExceptionOnFailure(boolean throwExceptionOnFailure) {
-        this.throwExceptionOnFailure = throwExceptionOnFailure;
-    }
-
-    public boolean isBridgeEndpoint() {
-        return bridgeEndpoint;
-    }
-
-    /**
-     * 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.
-     */
-    public void setBridgeEndpoint(boolean bridge) {
-        this.bridgeEndpoint = bridge;
-    }
-
-    public boolean isMatchOnUriPrefix() {
-        return matchOnUriPrefix;
-    }
-
-    /**
-     * Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.
-     * <p/>
-     * See more details at: http://camel.apache.org/how-do-i-let-jetty-match-wildcards.html
-     */
-    public void setMatchOnUriPrefix(boolean match) {
-        this.matchOnUriPrefix = match;
-    }
-    
-    public boolean isDisableStreamCache() {
-        return this.disableStreamCache;
-    }
-
-    /**
-     * Determines whether or not the raw input stream from Jetty 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 Jetty 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 bod
-     * if this option is false to support reading the stream multiple times.
-     * If you use Jetty 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.
-     */
-    public void setDisableStreamCache(boolean disable) {
-        this.disableStreamCache = disable;
-    }
-
-    public boolean isChunked() {
-        return this.chunked;
-    }
-
-    /**
-     * If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response
-     */
-    public void setChunked(boolean chunked) {
-        this.chunked = chunked;
-    }
-
-    public boolean isTransferException() {
-        return transferException;
-    }
-
-    /**
-     * 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.
-     */
-    public void setTransferException(boolean transferException) {
-        this.transferException = transferException;
-    }
-    
-    public boolean isTraceEnabled() {
-        return this.traceEnabled;
-    }
-
-    /**
-     * Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.
-     */
-    public void setTraceEnabled(boolean traceEnabled) {
-        this.traceEnabled = traceEnabled;
-    }
-
-    public String getHttpMethodRestrict() {
-        return httpMethodRestrict;
-    }
-
-    /**
-     * Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc.
-     * Multiple methods can be specified separated by comma.
-     */
-    public void setHttpMethodRestrict(String httpMethodRestrict) {
-        this.httpMethodRestrict = httpMethodRestrict;
-    }
-
-    public UrlRewrite getUrlRewrite() {
-        return 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
-     */
-    public void setUrlRewrite(UrlRewrite urlRewrite) {
-        this.urlRewrite = urlRewrite;
-    }
-
     public boolean isClearExpiredCookies() {
         return clearExpiredCookies;
     }
@@ -483,38 +264,4 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         this.authenticationPreemptive = authenticationPreemptive;
     }
 
-    public boolean isIgnoreResponseBody() {
-        return ignoreResponseBody;
-    }
-
-    /**
-     * If this option is true, The http producer won't read response body and cached the input stream.
-     */
-    public void setIgnoreResponseBody(boolean ignoreResponseBody) {
-        this.ignoreResponseBody = ignoreResponseBody;
-    }
-
-    public boolean isEagerCheckContentAvailable() {
-        return eagerCheckContentAvailable;
-    }
-
-    /**
-     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
-     * This can be turned on in case HTTP clients do not send streamed data.
-     */
-    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
-        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
-    }
-
-    /**
-     * 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).
-     */
-    public boolean isCopyHeaders() {
-        return copyHeaders;
-    }
-
-    public void setCopyHeaders(boolean copyHeaders) {
-        this.copyHeaders = copyHeaders;
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpHeaderFilterStrategy.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpHeaderFilterStrategy.java
deleted file mode 100644
index 906bf29..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpHeaderFilterStrategy.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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.http4;
-
-import org.apache.camel.impl.DefaultHeaderFilterStrategy;
-
-/**
- * @version 
- */
-public class HttpHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
-    
-    public HttpHeaderFilterStrategy() {
-        initialize();  
-    }
-
-    protected void initialize() {
-        getOutFilter().add("content-length");
-        getOutFilter().add("content-type");
-        getOutFilter().add("host");
-        // Add the filter for the Generic Message header
-        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
-        getOutFilter().add("cache-control");
-        getOutFilter().add("connection");
-        getOutFilter().add("date");
-        getOutFilter().add("pragma");
-        getOutFilter().add("trailer");
-        getOutFilter().add("transfer-encoding");
-        getOutFilter().add("upgrade");
-        getOutFilter().add("via");
-        getOutFilter().add("warning");
-        
-        setLowerCase(true);
-        
-        // filter headers begin with "Camel" or "org.apache.camel"
-        // must ignore case for Http based transports
-        setOutFilterPattern("(?i)(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java
deleted file mode 100644
index 69df1d6..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpMessage.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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.http4;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.impl.DefaultMessage;
-import org.apache.camel.util.ObjectHelper;
-
-/**
- * @version 
- */
-public class HttpMessage extends DefaultMessage {
-
-    private HttpServletRequest request;
-    private HttpServletResponse response;
-
-    public HttpMessage(Exchange exchange, HttpServletRequest request, HttpServletResponse response) {
-        setExchange(exchange);
-        this.request = request;
-        this.response = response;
-        // Put the request and response into the message header
-        this.setHeader(Exchange.HTTP_SERVLET_REQUEST, request);
-        this.setHeader(Exchange.HTTP_SERVLET_RESPONSE, response);
-
-        // Check the setting of exchange
-        Boolean flag = exchange.getProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.class);
-        if (flag != null && flag) {
-            this.setHeader(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
-        }
-        // use binding to read the request allowing end users to use their
-        // implementation of the binding
-        getEndpoint().getHttpBinding().readRequest(request, this);
-    }
-
-    public HttpServletRequest getRequest() {
-        return request;
-    }
-
-    public HttpServletResponse getResponse() {
-        return response;
-    }
-
-    @Override
-    protected Object createBody() {
-        try {
-            return getEndpoint().getHttpBinding().parseBody(this);
-        } catch (IOException e) {
-            throw new RuntimeCamelException(e);
-        }
-    }
-    
-    private HttpEndpoint getEndpoint() {
-        return (HttpEndpoint) getExchange().getFromEndpoint();
-    }
-
-    @Override
-    public String toString() {
-        // do not use toString on HTTP message
-        return "HttpMessage@" + ObjectHelper.getIdentityHashCode(this);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpOperationFailedException.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpOperationFailedException.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpOperationFailedException.java
deleted file mode 100644
index 2c3f354..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpOperationFailedException.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.http4;
-
-import java.util.Map;
-
-import org.apache.camel.CamelException;
-import org.apache.camel.util.ObjectHelper;
-
-public class HttpOperationFailedException extends CamelException {
-    private static final long serialVersionUID = -8721487434390572634L;
-    private final String uri;
-    private final String redirectLocation;
-    private final int statusCode;
-    private final String statusText;
-    private final Map<String, String> responseHeaders;
-    private final String responseBody;
-
-    public HttpOperationFailedException(String uri, int statusCode, String statusText, String location, Map<String, String> responseHeaders, String responseBody) {
-        super("HTTP operation failed invoking " + uri + " with statusCode: " + statusCode + (location != null ? ", redirectLocation: " + location : ""));
-        this.uri = uri;
-        this.statusCode = statusCode;
-        this.statusText = statusText;
-        this.redirectLocation = location;
-        this.responseHeaders = responseHeaders;
-        this.responseBody = responseBody;
-    }
-
-    public String getUri() {
-        return uri;
-    }
-
-    public boolean isRedirectError() {
-        return statusCode >= 300 && statusCode < 400;
-    }
-
-    public boolean hasRedirectLocation() {
-        return ObjectHelper.isNotEmpty(redirectLocation);
-    }
-
-    public String getRedirectLocation() {
-        return redirectLocation;
-    }
-
-    public int getStatusCode() {
-        return statusCode;
-    }
-
-    public String getStatusText() {
-        return statusText;
-    }
-
-    public Map<String, String> getResponseHeaders() {
-        return responseHeaders;
-    }
-
-    public String getResponseBody() {
-        return responseBody;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
index ff74cee..0020094 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
@@ -22,7 +22,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.ServicePoolAware;
-import org.apache.camel.component.http4.helper.HttpHelper;
+import org.apache.camel.http.common.HttpHelper;
 import org.apache.camel.impl.PollingConsumerSupport;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.http.Header;

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
index 258c6a4..026754c 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
@@ -36,9 +36,11 @@ import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.file.GenericFile;
-import org.apache.camel.component.http4.helper.HttpHelper;
-
+import org.apache.camel.component.http4.helper.HttpMethodHelper;
 import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpProtocolHeaderFilterStrategy;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.ExchangeHelper;
@@ -50,6 +52,7 @@ import org.apache.camel.util.URISupport;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.http.client.methods.HttpRequestBase;
@@ -110,7 +113,8 @@ public class HttpProducer extends DefaultProducer {
         String httpProtocolVersion = in.getHeader(Exchange.HTTP_PROTOCOL_VERSION, String.class);
         if (httpProtocolVersion != null) {
             // set the HTTP protocol version
-            httpRequest.setProtocolVersion(HttpHelper.parserHttpVersion(httpProtocolVersion));
+            int[] version = HttpHelper.parserHttpVersion(httpProtocolVersion);
+            httpRequest.setProtocolVersion(new HttpVersion(version[0], version[1]));
         }
         HeaderFilterStrategy strategy = getEndpoint().getHeaderFilterStrategy();
 
@@ -377,7 +381,7 @@ public class HttpProducer extends DefaultProducer {
 
         // create http holder objects for the request
         HttpEntity requestEntity = createRequestEntity(exchange);
-        HttpMethods methodToUse = HttpHelper.createMethod(exchange, getEndpoint(), requestEntity != null);
+        HttpMethods methodToUse = HttpMethodHelper.createMethod(exchange, getEndpoint(), requestEntity != null);
         HttpRequestBase method = methodToUse.createMethod(url);
 
         LOG.trace("Using URL: {} with method: {}", url, method);

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProtocolHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProtocolHeaderFilterStrategy.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProtocolHeaderFilterStrategy.java
deleted file mode 100644
index e7ae36d..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProtocolHeaderFilterStrategy.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.http4;
-
-import org.apache.camel.impl.DefaultHeaderFilterStrategy;
-
-
-public class HttpProtocolHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
-    
-    public HttpProtocolHeaderFilterStrategy() {
-        initialize();  
-    }
-
-    // Just add the http headers here 
-    protected void initialize() {
-        getInFilter().add("host");
-        
-        getInFilter().add("content-encoding");
-        getInFilter().add("content-language");
-        getInFilter().add("content-location");
-        getInFilter().add("content-md5");
-        getInFilter().add("content-length");
-        getInFilter().add("content-type");
-        getInFilter().add("content-range");
-        
-        getInFilter().add("dav");
-        getInFilter().add("depth");
-        getInFilter().add("destination");
-        getInFilter().add("etag");
-        getInFilter().add("expect");
-        getInFilter().add("expires");
-        getInFilter().add("from");
-        getInFilter().add("if");
-        getInFilter().add("if-match");
-        getInFilter().add("if-modified-since");
-        getInFilter().add("if-none-match");
-        getInFilter().add("if-range");
-        getInFilter().add("if-unmodified-since");
-        getInFilter().add("last-modified");
-        getInFilter().add("location");
-        getInFilter().add("lock-token");
-        getInFilter().add("max-forwards");
-        getInFilter().add("overwrite");
-        getInFilter().add("pragma");
-        getInFilter().add("proxy-authenticate");
-        getInFilter().add("proxy-authorization");
-        getInFilter().add("range");
-        getInFilter().add("referer");
-        getInFilter().add("retry-after");
-        getInFilter().add("server");
-        getInFilter().add("status-uri");
-        getInFilter().add("te");
-        getInFilter().add("timeout");
-      
-        getInFilter().add("user-agent");
-        getInFilter().add("vary");
-  
-        getInFilter().add("www-authenticate");
-        
-        // Add the filter for the Generic Message header
-        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
-        getInFilter().add("cache-control");
-        getInFilter().add("connection");
-        getInFilter().add("date");
-        getInFilter().add("pragma");
-        getInFilter().add("trailer");
-        getInFilter().add("transfer-encoding");
-        getInFilter().add("upgrade");
-        getInFilter().add("via");
-        getInFilter().add("warning");
-               
-        setLowerCase(true);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java
deleted file mode 100644
index 4d132dd..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpServletUrlRewrite.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.http4;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.Producer;
-
-/**
- * Extended {@link UrlRewrite} which leverages {@link HttpServletRequest}
- * during the rewrite process.
- * <p/>
- * For example the camel-urlrewrite component supports
- * {@link HttpServletUrlRewrite} implementations.
- */
-public interface HttpServletUrlRewrite extends UrlRewrite {
-
-    /**
-     * Rewrite the url.
-     *
-     * @param url  the absolute url (eg with scheme://host:port/path?query)
-     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
-     *                    endpoint from the given producer.
-     * @param producer the producer to use the rewritten url
-     * @param request  the http servlet request
-     * @return the rewritten url, or <tt>null</tt> to use the original url
-     * @throws Exception is thrown if error rewriting the url
-     */
-    String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception;
-
-}


[20/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java
deleted file mode 100644
index e5c4be4..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/UrlRewrite.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.http4;
-
-import org.apache.camel.Producer;
-
-/**
- * Allows to plugin custom strategy for rewriting url.
- * <p/>
- * This allows for example to proxy http services and plugin a url rewrite
- * strategy such as the <a href="http://camel.apache.org/urlrewrite">url-rewrite</a> component.
- */
-public interface UrlRewrite {
-
-    /**
-     * Rewrite the url.
-     *
-     * @param url  the absolute url (eg with scheme://host:port/path?query)
-     * @param relativeUrl optional relative url, if bridging endpoints, which then would be without the base path from the
-     *                    endpoint from the given producer.
-     * @param producer the producer to use the rewritten url
-     * @return the rewritten url, or <tt>null</tt> to use the original url
-     * @throws Exception is thrown if error rewriting the url
-     */
-    String rewrite(String url, String relativeUrl, Producer producer) throws Exception;
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
deleted file mode 100644
index c85e975..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/CamelFileDataSource.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.http4.helper;
-
-import java.io.File;
-
-import javax.activation.FileDataSource;
-import javax.activation.FileTypeMap;
-
-public class CamelFileDataSource extends FileDataSource {
-    private final String fileName;
-    private FileTypeMap typeMap;
-
-    public CamelFileDataSource(File file, String fileName) {
-        super(file);
-        this.fileName = fileName;
-    }
-    
-    public String getContentType() {
-        if (typeMap == null) {
-            return FileTypeMap.getDefaultFileTypeMap().getContentType(fileName);
-        } else {
-            return typeMap.getContentType(fileName);
-        }
-    }
-    
-    public void setFileTypeMap(FileTypeMap map) {
-        typeMap = map;
-    }
-    
-    public String getName() {
-        if (fileName != null) {
-            return fileName;
-        } else {
-            return super.getName();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
deleted file mode 100644
index d1996bc..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
+++ /dev/null
@@ -1,498 +0,0 @@
-/**
- * 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.http4.helper;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.Producer;
-import org.apache.camel.RuntimeExchangeException;
-import org.apache.camel.component.http4.HttpConstants;
-import org.apache.camel.component.http4.HttpConverter;
-import org.apache.camel.component.http4.HttpEndpoint;
-import org.apache.camel.component.http4.HttpMessage;
-import org.apache.camel.component.http4.HttpMethods;
-import org.apache.camel.component.http4.HttpServletUrlRewrite;
-import org.apache.camel.converter.stream.CachedOutputStream;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.util.CamelObjectInputStream;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.URISupport;
-import org.apache.camel.util.UnsafeUriCharactersEncoder;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class HttpHelper {
-
-    private static final Logger LOG = LoggerFactory.getLogger(HttpHelper.class);
-
-    private HttpHelper() {
-        // Helper class
-    }
-
-    public static void setCharsetFromContentType(String contentType, Exchange exchange) {
-        if (contentType != null) {
-            // find the charset and set it to the Exchange
-            int index = contentType.indexOf("charset=");
-            if (index > 0) {
-                String charset = contentType.substring(index + 8);
-                exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(charset));
-            }
-        }
-    }
-
-    /**
-     * Writes the given object as response body to the servlet response
-     * <p/>
-     * The content type will be set to {@link HttpConstants#CONTENT_TYPE_JAVA_SERIALIZED_OBJECT}
-     *
-     * @param response servlet response
-     * @param target   object to write
-     * @throws IOException is thrown if error writing
-     */
-    public static void writeObjectToServletResponse(ServletResponse response, Object target) throws IOException {
-        response.setContentType(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
-        writeObjectToStream(response.getOutputStream(), target);
-    }
-
-    /**
-     * Writes the given object as response body to the output stream
-     *
-     * @param stream output stream
-     * @param target object to write
-     * @throws IOException is thrown if error writing
-     */
-    public static void writeObjectToStream(OutputStream stream, Object target) throws IOException {
-        ObjectOutputStream oos = new ObjectOutputStream(stream);
-        oos.writeObject(target);
-        oos.flush();
-        IOHelper.close(oos);
-    }
-
-    /**
-     * Deserializes the input stream to a Java object
-     *
-     * @param is input stream for the Java object
-     * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
-     * @throws ClassNotFoundException is thrown if class not found
-     * @throws IOException can be thrown
-     * @deprecated Camel 3.0 
-     * Please use the one which has the parameter of camel context
-     */
-    @Deprecated
-    public static Object deserializeJavaObjectFromStream(InputStream is) throws ClassNotFoundException, IOException {
-        return deserializeJavaObjectFromStream(is, null);
-    }
-    
-    /**
-     * Deserializes the input stream to a Java object
-     *
-     * @param is input stream for the Java object
-     * @param context the camel context which could help us to apply the customer classloader
-     * @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
-     * @throws ClassNotFoundException is thrown if class not found
-     * @throws IOException can be thrown
-     */
-    public static Object deserializeJavaObjectFromStream(InputStream is, CamelContext context) throws ClassNotFoundException, IOException {
-        if (is == null) {
-            return null;
-        }
-
-        Object answer = null;
-        ObjectInputStream ois = new CamelObjectInputStream(is, context);
-        try {
-            answer = ois.readObject();
-        } finally {
-            IOHelper.close(ois);
-        }
-
-        return answer;
-    }
-
-    /**
-     * Reads the request body from the given http servlet request.
-     *
-     * @param request  http servlet request
-     * @param exchange the exchange
-     * @return the request body, can be <tt>null</tt> if no body
-     * @throws IOException is thrown if error reading request body
-     */
-    public static Object readRequestBodyFromServletRequest(HttpServletRequest request, Exchange exchange) throws IOException {
-        InputStream is = HttpConverter.toInputStream(request, exchange);
-        return readRequestBodyFromInputStream(is, exchange);
-    }
-    
-    /**
-     * Reads the request body from the given input stream.
-     *
-     * @param is       the input stream
-     * @param exchange the exchange
-     * @return the request body, can be <tt>null</tt> if no body
-     * @throws IOException is thrown if error reading request body
-     */
-    public static Object readRequestBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
-        if (is == null) {
-            return null;
-        }
-        
-        boolean disableStreamCaching = false;
-        // Just take the consideration of the setting of Camel Context StreamCaching
-        if (exchange.getContext() instanceof DefaultCamelContext) { 
-            DefaultCamelContext context = (DefaultCamelContext) exchange.getContext();
-            disableStreamCaching = !context.isStreamCaching();
-        }
-        if (disableStreamCaching) {
-            return is;
-        } else {
-            CachedOutputStream cos = new CachedOutputStream(exchange);
-            IOHelper.copyAndCloseInput(is, cos);
-            return cos.newStreamCache();
-        }
-    }
-
-    /**
-     * Reads the response body from the given input stream.
-     *
-     * @param is       the input stream
-     * @param exchange the exchange
-     * @return the response body, can be <tt>null</tt> if no body
-     * @throws IOException is thrown if error reading response body
-     */
-    public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
-        if (is == null) {
-            return null;
-        }
-        
-        // convert the input stream to StreamCache if the stream cache is not disabled
-        if (exchange.getProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.FALSE, Boolean.class)) {
-            return is;
-        } else {
-            CachedOutputStream cos = new CachedOutputStream(exchange);
-            IOHelper.copyAndCloseInput(is, cos);
-            return cos.newStreamCache();
-        }
-    }
-
-    /**
-     * 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().toASCIIString();
-        }
-
-        // resolve placeholders in uri
-        try {
-            uri = exchange.getContext().resolvePropertyPlaceholders(uri);
-        } catch (Exception e) {
-            throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uri, exchange, e);
-        }
-
-        // append HTTP_PATH to HTTP_URI if it is provided in the header
-        String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
-        // NOW the HTTP_PATH is just related path, we don't need to trim it
-        if (path != null) {
-            if (path.startsWith("/")) {
-                path = path.substring(1);
-            }
-            if (path.length() > 0) {
-                // make sure that there is exactly one "/" between HTTP_URI and
-                // HTTP_PATH
-                if (!uri.endsWith("/")) {
-                    uri = uri + "/";
-                }
-                uri = uri.concat(path);
-            }
-        }
-
-        // ensure uri is encoded to be valid
-        uri = UnsafeUriCharactersEncoder.encodeHttpURI(uri);
-
-        return uri;
-    }
-
-    /**
-     * Creates the URI to invoke.
-     *
-     * @param exchange the exchange
-     * @param url      the url to invoke
-     * @param endpoint the endpoint
-     * @return the URI to invoke
-     */
-    public static URI createURI(Exchange exchange, String url, HttpEndpoint endpoint) throws URISyntaxException {
-        URI uri = new URI(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 = endpoint.getHttpUri().getRawQuery();
-        }
-        // We should user the query string from the HTTP_URI header
-        if (queryString == null) {
-            queryString = uri.getQuery();
-        }
-        if (queryString != null) {
-            // need to encode query string
-            queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
-            uri = URISupport.createURIWithQuery(uri, queryString);
-        }
-        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
-     * @throws URISyntaxException 
-     */
-    public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
-        // 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);
-        // We need also check the HTTP_URI header query part
-        String uriString = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
-        // resolve placeholders in uriString
-        try {
-            uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
-        } catch (Exception e) {
-            throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
-        }
-        if (uriString != null) {
-            URI uri = new URI(uriString);
-            queryString = uri.getQuery();
-        }
-        if (queryString == null) {
-            queryString = endpoint.getHttpUri().getRawQuery();
-        }
-
-        // 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;
-    }
-
-    public static HttpVersion parserHttpVersion(String s) throws ProtocolException {
-        int major;
-        int minor;
-        if (s == null) {
-            throw new IllegalArgumentException("String may not be null");
-        }
-        if (!s.startsWith("HTTP/")) {
-            throw new ProtocolException("Invalid HTTP version string: " + s);
-        }
-        int i1 = "HTTP/".length();
-        int i2 = s.indexOf(".", i1);
-        if (i2 == -1) {
-            throw new ProtocolException("Invalid HTTP version number: " + s);
-        }
-        try {
-            major = Integer.parseInt(s.substring(i1, i2));
-        } catch (NumberFormatException e) {
-            throw new ProtocolException("Invalid HTTP major version number: " + s);
-        }
-        i1 = i2 + 1;
-        i2 = s.length();
-        try {
-            minor = Integer.parseInt(s.substring(i1, i2));
-        } catch (NumberFormatException e) {
-            throw new ProtocolException("Invalid HTTP minor version number: " + s);
-        }
-        return new HttpVersion(major, minor);
-    }
-
-    public static boolean isSecureConnection(String uri) {
-        return uri.startsWith("https");
-    }
-
-    /**
-     * Appends the key/value to the headers.
-     * <p/>
-     * This implementation supports keys with multiple values. In such situations the value
-     * will be a {@link java.util.List} that contains the multiple values.
-     *
-     * @param headers  headers
-     * @param key      the key
-     * @param value    the value
-     */
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    public static void appendHeader(Map<String, Object> headers, String key, Object value) {
-        if (headers.containsKey(key)) {
-            Object existing = headers.get(key);
-            List<Object> list;
-            if (existing instanceof List) {
-                list = (List) existing;
-            } else {
-                list = new ArrayList<Object>();
-                list.add(existing);
-            }
-            list.add(value);
-            value = list;
-        }
-
-        headers.put(key, value);
-    }
-
-    /**
-     * Extracts the parameter value.
-     * <p/>
-     * This implementation supports HTTP multi value parameters which
-     * is based on the syntax of <tt>[value1, value2, value3]</tt> by returning
-     * a {@link List} containing the values.
-     * <p/>
-     * If the value is not a HTTP mulit value the value is returned as is.
-     *
-     * @param value the parameter value
-     * @return the extracted parameter value, see more details in javadoc.
-     */
-    public static Object extractHttpParameterValue(String value) {
-        if (value == null || ObjectHelper.isEmpty(value)) {
-            return value;
-        }
-
-        // trim value before checking for multiple parameters
-        String trimmed = value.trim();
-
-        if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
-            // remove the [ ] markers
-            trimmed = trimmed.substring(1, trimmed.length() - 1);
-            List<String> list = new ArrayList<String>();
-            String[] values = trimmed.split(",");
-            for (String s : values) {
-                list.add(s.trim());
-            }
-            return list;
-        }
-
-        return value;
-    }
-
-    /**
-     * Processes any custom {@link org.apache.camel.component.http4.UrlRewrite}.
-     *
-     * @param exchange    the exchange
-     * @param url         the url
-     * @param endpoint    the http endpoint
-     * @param producer    the producer
-     * @return            the rewritten url, or <tt>null</tt> to use original url
-     * @throws Exception is thrown if any error during rewriting url
-     */
-    public static String urlRewrite(Exchange exchange, String url, HttpEndpoint endpoint, Producer producer) throws Exception {
-        String answer = null;
-
-        String relativeUrl;
-        if (endpoint.getUrlRewrite() != null) {
-            // we should use the relative path if possible
-            String baseUrl;
-            relativeUrl = endpoint.getHttpUri().toASCIIString();
-            if (url.startsWith(relativeUrl)) {
-                baseUrl = url.substring(0, relativeUrl.length());
-                relativeUrl = url.substring(relativeUrl.length());
-            } else {
-                baseUrl = null;
-                relativeUrl = url;
-            }
-            // mark it as null if its empty
-            if (ObjectHelper.isEmpty(relativeUrl)) {
-                relativeUrl = null;
-            }
-
-            String newUrl;
-            if (endpoint.getUrlRewrite() instanceof HttpServletUrlRewrite) {
-                // its servlet based, so we need the servlet request
-                HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
-                if (request == null) {
-                    HttpMessage msg = exchange.getIn(HttpMessage.class);
-                    if (msg != null) {
-                        request = msg.getRequest();
-                    }
-                }
-                if (request == null) {
-                    throw new IllegalArgumentException("UrlRewrite " + endpoint.getUrlRewrite() + " requires the message body to be a"
-                            + "HttpServletRequest instance, but was: " + ObjectHelper.className(exchange.getIn().getBody()));
-                }
-                // we need to adapt the context-path to be the path from the endpoint, if it came from a http based endpoint
-                // as eg camel-jetty have hardcoded context-path as / for all its servlets/endpoints
-                // we have the actual context-path stored as a header with the key CamelServletContextPath
-                String contextPath = exchange.getIn().getHeader("CamelServletContextPath", String.class);
-                request = new UrlRewriteHttpServletRequestAdapter(request, contextPath);
-                newUrl = ((HttpServletUrlRewrite) endpoint.getUrlRewrite()).rewrite(url, relativeUrl, producer, request);
-            } else {
-                newUrl = endpoint.getUrlRewrite().rewrite(url, relativeUrl, producer);
-            }
-
-            if (ObjectHelper.isNotEmpty(newUrl) && !newUrl.equals(url)) {
-                // we got a new url back, that can either be a new absolute url
-                // or a new relative url
-                if (newUrl.startsWith("http:") || newUrl.startsWith("https:")) {
-                    answer = newUrl;
-                } else if (baseUrl != null) {
-                    // avoid double // when adding the urls
-                    if (baseUrl.endsWith("/") && newUrl.startsWith("/")) {
-                        answer = baseUrl + newUrl.substring(1);
-                    } else {
-                        answer = baseUrl + newUrl;
-                    }
-                } else {
-                    // use the new url as is
-                    answer = newUrl;
-                }
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Using url rewrite to rewrite from url {} to {} -> {}",
-                            new Object[]{relativeUrl != null ? relativeUrl : url, newUrl, answer});
-                }
-            }
-        }
-
-        return answer;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/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
new file mode 100644
index 0000000..ac37192
--- /dev/null
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java
@@ -0,0 +1,82 @@
+/**
+ * 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.http4.helper;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeExchangeException;
+import org.apache.camel.component.http4.HttpEndpoint;
+import org.apache.camel.component.http4.HttpMethods;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class HttpMethodHelper {
+
+    private static final Logger LOG = LoggerFactory.getLogger(HttpMethodHelper.class);
+
+    private HttpMethodHelper() {
+        // Helper class
+    }
+
+    /**
+     * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
+     *
+     * @param exchange the exchange
+     * @return the created method
+     * @throws URISyntaxException 
+     */
+    @Deprecated
+    public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
+        // 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);
+        // We need also check the HTTP_URI header query part
+        String uriString = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
+        // resolve placeholders in uriString
+        try {
+            uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
+        } catch (Exception e) {
+            throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
+        }
+        if (uriString != null) {
+            URI uri = new URI(uriString);
+            queryString = uri.getQuery();
+        }
+        if (queryString == null) {
+            queryString = endpoint.getHttpUri().getRawQuery();
+        }
+
+        // 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;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java
deleted file mode 100644
index e4c5765..0000000
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/UrlRewriteHttpServletRequestAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.http4.helper;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
-/**
- * Special adapter when {@link org.apache.camel.component.http4.HttpServletUrlRewrite} is in use,
- * and the route started from came-jetty/camel-serlvet.
- * <p/>
- * This adapter ensures that we can control the context-path returned from the
- * {@link javax.servlet.http.HttpServletRequest#getContextPath()} method.
- * This allows us to ensure the context-path is based on the endpoint path, as the
- * camel-jetty/camel-servlet server implementation uses the root ("/") context-path
- * for all the servlets/endpoints.
- */
-public final class UrlRewriteHttpServletRequestAdapter extends HttpServletRequestWrapper {
-
-    private final String contextPath;
-
-    /**
-     * Creates this adapter
-     * @param delegate    the real http servlet request to delegate.
-     * @param contextPath use to override and return this context-path
-     */
-    public UrlRewriteHttpServletRequestAdapter(HttpServletRequest delegate, String contextPath) {
-        super(delegate);
-        this.contextPath = contextPath;
-    }
-
-    public String getContextPath() {
-        return contextPath != null ? contextPath : super.getContextPath();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter b/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
index de0d742..bbb63c3 100644
--- a/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
+++ b/components/camel-http4/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
@@ -15,5 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.camel.component.http4.HttpConverter
 org.apache.camel.component.http4.HttpEntityConverter

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java
index ef5e3a8..6d52b54 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/GoogleUrlRewrite.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http4;
 
 import org.apache.camel.Producer;
+import org.apache.camel.http.common.UrlRewrite;
 
 // START SNIPPET: e1
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java
index 7ddf4b1..3af54f7 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java
@@ -17,6 +17,8 @@
 package org.apache.camel.component.http4;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.http.common.DefaultHttpBinding;
+import org.apache.camel.http.common.HttpHeaderFilterStrategy;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
@@ -57,15 +59,15 @@ public class HttpEndpointOptionsNotChangeComponentTest extends CamelTestSupport
     public void testDoNotMessWithComponent() throws Exception {
         // get default
         HttpEndpoint end = context.getEndpoint("http4://www.google.com", HttpEndpoint.class);
-        assertIsInstanceOf(MyBinding.class, end.getHttpBinding());
+        assertIsInstanceOf(MyBinding.class, end.getBinding());
 
         // use a endpoint specific binding
         HttpEndpoint end2 = context.getEndpoint("http4://www.google.com?httpBinding=#other", HttpEndpoint.class);
-        assertIsInstanceOf(MyOtherBinding.class, end2.getHttpBinding());
+        assertIsInstanceOf(MyOtherBinding.class, end2.getBinding());
 
         // and the default option has not been messed with
         HttpEndpoint end3 = context.getEndpoint("http4://www.google.com", HttpEndpoint.class);
-        assertIsInstanceOf(MyBinding.class, end3.getHttpBinding());
+        assertIsInstanceOf(MyBinding.class, end3.getBinding());
         
         // test the headerFilterStrategy
         HttpEndpoint end4 = context.getEndpoint("http4://www.google.com?headerFilterStrategy=#myStrategy", HttpEndpoint.class);

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpHeaderFilterStrategyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpHeaderFilterStrategyTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpHeaderFilterStrategyTest.java
index 0c69b2a..05ca837 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpHeaderFilterStrategyTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpHeaderFilterStrategyTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http4;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.http.common.HttpHeaderFilterStrategy;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.test.junit4.CamelTestSupport;

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpRedirectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpRedirectTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpRedirectTest.java
index ffb8f84..6a40340 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpRedirectTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpRedirectTest.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.http4.handler.BasicValidationHandler;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.http.HttpException;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java
index 8b323b9..c750a4d 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http4;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.http.common.DefaultHttpBinding;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.http.impl.client.HttpClientBuilder;
@@ -53,8 +54,8 @@ public class HttpReferenceParameterTest extends CamelTestSupport {
 
     @Test
     public void testHttpBindingRef() {
-        assertSame(testBinding, endpoint1.getHttpBinding());
-        assertSame(testBinding, endpoint2.getHttpBinding());
+        assertSame(testBinding, endpoint1.getBinding());
+        assertSame(testBinding, endpoint2.getBinding());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpThrowExceptionOnFailureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpThrowExceptionOnFailureTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpThrowExceptionOnFailureTest.java
index 1ec73f5..00d9530 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpThrowExceptionOnFailureTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpThrowExceptionOnFailureTest.java
@@ -22,6 +22,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.component.http4.handler.BasicValidationHandler;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.http.HttpStatus;
 import org.apache.http.impl.bootstrap.HttpServer;
 import org.apache.http.impl.bootstrap.ServerBootstrap;

http://git-wip-us.apache.org/repos/asf/camel/blob/be77f1a0/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
index 08d97f4..be9168a 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
@@ -27,6 +27,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.http4.HttpEndpoint;
 import org.apache.camel.component.http4.HttpMethods;
+import org.apache.camel.http.common.HttpHelper;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.junit.Test;
@@ -113,7 +114,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodAlwaysUseUserChoosenMethod() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
+        HttpMethods method = HttpMethodHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", HttpMethods.POST),
                 createHttpEndpoint(true, "http://www.google.com/search"),
                 false);
@@ -123,7 +124,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodUseGETIfQueryIsProvidedInHeader() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
+        HttpMethods method = HttpMethodHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", null),
                 createHttpEndpoint(true, "http://www.google.com/search"),
                 false);
@@ -133,7 +134,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodUseGETIfQueryIsProvidedInEndpointURI() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
+        HttpMethods method = HttpMethodHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search?q=test"),
                 false);
@@ -143,7 +144,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodUseGETIfNoneQueryOrPayloadIsProvided() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
+        HttpMethods method = HttpMethodHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search"),
                 false);
@@ -153,7 +154,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodUsePOSTIfNoneQueryButPayloadIsProvided() throws URISyntaxException {
-        HttpMethods method = HttpHelper.createMethod(
+        HttpMethods method = HttpMethodHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search"),
                 true);


[10/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: d1f6348bddb471d6ca656c834fcb86690249e04c
Parents: 617b196
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 10:10:59 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:32 2015 +0200

----------------------------------------------------------------------
 components/camel-undertow/pom.xml               |  9 ++--
 .../undertow/DefaultUndertowHttpBinding.java    |  5 +-
 .../component/undertow/UndertowComponent.java   | 40 ++--------------
 .../undertow/UndertowHeaderFilterStrategy.java  | 49 ++++++++++++++++++++
 .../undertow/UndertowPrefixMatchingTest.java    |  2 +-
 5 files changed, 60 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-undertow/pom.xml b/components/camel-undertow/pom.xml
index 960a2fe..4f56a50 100644
--- a/components/camel-undertow/pom.xml
+++ b/components/camel-undertow/pom.xml
@@ -42,10 +42,6 @@
       <artifactId>camel-core</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-http</artifactId>
-    </dependency>
-    <dependency>
       <groupId>io.undertow</groupId>
       <artifactId>undertow-core</artifactId>
       <version>${undertow-version}</version>
@@ -63,6 +59,11 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
index 1be1700..e1d6c7e 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
@@ -36,7 +36,6 @@ import io.undertow.util.MimeMappings;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.TypeConverter;
-import org.apache.camel.component.http.HttpHeaderFilterStrategy;
 import org.apache.camel.impl.DefaultMessage;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.ExchangeHelper;
@@ -48,7 +47,7 @@ import org.xnio.Pooled;
 
 /**
  * DefaultUndertowHttpBinding represent binding used by default, if user doesn't provide any.
- * By default {@link HttpHeaderFilterStrategy} is also used.
+ * By default {@link UndertowHeaderFilterStrategy} is also used.
  */
 public class DefaultUndertowHttpBinding implements UndertowHttpBinding {
 
@@ -58,7 +57,7 @@ public class DefaultUndertowHttpBinding implements UndertowHttpBinding {
     private HeaderFilterStrategy headerFilterStrategy;
 
     public DefaultUndertowHttpBinding() {
-        this.headerFilterStrategy = new HttpHeaderFilterStrategy();
+        this.headerFilterStrategy = new UndertowHeaderFilterStrategy();
     }
 
     public DefaultUndertowHttpBinding(HeaderFilterStrategy headerFilterStrategy) {

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
index 8d08000..e1ffb30 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java
@@ -28,12 +28,9 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
-import org.apache.camel.component.http.HttpBinding;
-import org.apache.camel.component.http.HttpClientConfigurer;
-import org.apache.camel.component.http.HttpComponent;
-import org.apache.camel.component.http.HttpConfiguration;
 import org.apache.camel.component.undertow.handlers.HttpCamelHandler;
 import org.apache.camel.component.undertow.handlers.NotFoundHandler;
+import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RestConsumerFactory;
@@ -41,20 +38,20 @@ import org.apache.camel.util.FileUtil;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.camel.util.jsse.SSLContextParameters;
-import org.apache.commons.httpclient.HttpConnectionManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Represents the component that manages {@link UndertowEndpoint}.
  */
-public class UndertowComponent extends HttpComponent implements RestConsumerFactory {
+public class UndertowComponent extends UriEndpointComponent implements RestConsumerFactory {
     private static final Logger LOG = LoggerFactory.getLogger(UndertowEndpoint.class);
 
     private UndertowHttpBinding undertowHttpBinding;
     private Map<Integer, UndertowRegistry> serversRegistry = new HashMap<Integer, UndertowRegistry>();
 
     public UndertowComponent() {
+        super(UndertowEndpoint.class);
         this.undertowHttpBinding = new DefaultUndertowHttpBinding();
     }
 
@@ -233,22 +230,6 @@ public class UndertowComponent extends HttpComponent implements RestConsumerFact
         undertowRegistry.setServer(newServer);
     }
 
-    /**
-     * To use the custom HttpClientConfigurer to perform configuration of the HttpClient that will be used.
-     */
-    @Override
-    public void setHttpClientConfigurer(HttpClientConfigurer httpClientConfigurer) {
-        super.setHttpClientConfigurer(httpClientConfigurer);
-    }
-
-    /**
-     * To use a custom HttpConnectionManager to manage connections
-     */
-    @Override
-    public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager) {
-        super.setHttpConnectionManager(httpConnectionManager);
-    }
-
     public UndertowHttpBinding getUndertowHttpBinding() {
         return undertowHttpBinding;
     }
@@ -260,19 +241,4 @@ public class UndertowComponent extends HttpComponent implements RestConsumerFact
         this.undertowHttpBinding = undertowHttpBinding;
     }
 
-    /**
-     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-     */
-    @Override
-    public void setHttpBinding(HttpBinding httpBinding) {
-        super.setHttpBinding(httpBinding);
-    }
-
-    /**
-     * To use the shared HttpConfiguration as base configuration.
-     */
-    @Override
-    public void setHttpConfiguration(HttpConfiguration httpConfiguration) {
-        super.setHttpConfiguration(httpConfiguration);
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
new file mode 100644
index 0000000..b16824e
--- /dev/null
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowHeaderFilterStrategy.java
@@ -0,0 +1,49 @@
+/**
+ * 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.undertow;
+
+import org.apache.camel.impl.DefaultHeaderFilterStrategy;
+
+public class UndertowHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
+    
+    public UndertowHeaderFilterStrategy() {
+        initialize();  
+    }
+
+    protected void initialize() {
+        getOutFilter().add("content-length");
+        getOutFilter().add("content-type");
+        getOutFilter().add("host");
+        // Add the filter for the Generic Message header
+        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
+        getOutFilter().add("cache-control");
+        getOutFilter().add("connection");
+        getOutFilter().add("date");
+        getOutFilter().add("pragma");
+        getOutFilter().add("trailer");
+        getOutFilter().add("transfer-encoding");
+        getOutFilter().add("upgrade");
+        getOutFilter().add("via");
+        getOutFilter().add("warning");
+        
+        setLowerCase(true);
+        
+        // filter headers begin with "Camel" or "org.apache.camel"
+        // must ignore case for Http based transports
+        setOutFilterPattern("(?i)(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d1f6348b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
index 34f1b62..dd227d8 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/UndertowPrefixMatchingTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.undertow;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;


[12/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: ac1f1afefd76f52cf053fe30ff6ece66b48e2cd0
Parents: 04ec33a
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 11:26:54 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:33 2015 +0200

----------------------------------------------------------------------
 components/camel-cxf/pom.xml                             | 11 +++++++++--
 .../component/cxf/AbstractCXFGreeterRouterTest.java      |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ac1f1afe/components/camel-cxf/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/pom.xml b/components/camel-cxf/pom.xml
index fab4458..1147054 100644
--- a/components/camel-cxf/pom.xml
+++ b/components/camel-cxf/pom.xml
@@ -168,7 +168,14 @@
       <artifactId>camel-test-spring</artifactId>
       <scope>test</scope>
     </dependency>
-    
+
+    <!-- http client tests -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
+      <scope>test</scope>
+    </dependency>
+
     <!-- test for the cxf jms transport -->
     <dependency>
        <groupId>org.apache.activemq</groupId>
@@ -306,7 +313,7 @@
         <configuration>
           <childDelegation>false</childDelegation>
           <forkCount>1</forkCount>
-	  <reuseForks>true</reuseForks>
+	        <reuseForks>true</reuseForks>
           <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
           <reportFormat>brief</reportFormat>
           <useFile>false</useFile>

http://git-wip-us.apache.org/repos/asf/camel/blob/ac1f1afe/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java
index 8bdec90..457e9fb 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/AbstractCXFGreeterRouterTest.java
@@ -21,7 +21,7 @@ import javax.xml.ws.Service;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.IOHelper;


[24/24] camel git commit: require java 8 for testing

Posted by da...@apache.org.
require java 8 for testing


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

Branch: refs/heads/master
Commit: 5b63cf5a3d4098fc9afa3cd1295d5b845f660dd4
Parents: 2417f34
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 14:56:52 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:36 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/itest/karaf/CamelVertxTest.java   | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5b63cf5a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelVertxTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelVertxTest.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelVertxTest.java
index 875697b..72dd6ba 100644
--- a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelVertxTest.java
+++ b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelVertxTest.java
@@ -22,8 +22,6 @@ import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 
-import static org.junit.Assume.assumeTrue;
-
 @RunWith(PaxExam.class)
 public class CamelVertxTest extends AbstractFeatureTest {
 
@@ -31,10 +29,11 @@ public class CamelVertxTest extends AbstractFeatureTest {
 
     @Test
     public void test() throws Exception {
-//        Vert.x can be deployed only to Java 7 JVM
+        // vertx requires Java 1.8
         String javaVersion = System.getProperty("java.version");
-        assumeTrue(javaVersion.startsWith("1.7"));
-        testComponent(COMPONENT);
+        if (javaVersion.startsWith("1.8")) {
+            testComponent(COMPONENT);
+        }
     }
 
     @Configuration


[03/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 600063abdeb2d3030a414b3215625f009770dd58
Parents: b48be21
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 09:09:34 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:30 2015 +0200

----------------------------------------------------------------------
 .../component/http/HttpCommonComponent.java     |   4 +-
 .../component/http/HttpCommonEndpoint.java      |  42 +--
 .../camel/component/http/HttpEndpoint.java      | 343 +------------------
 3 files changed, 24 insertions(+), 365 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/600063ab/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
index 8443963..23b4455 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.http;
 
-import org.apache.camel.Endpoint;
 import org.apache.camel.impl.HeaderFilterStrategyComponent;
 
 public abstract class HttpCommonComponent extends HeaderFilterStrategyComponent {
@@ -24,8 +23,7 @@ public abstract class HttpCommonComponent extends HeaderFilterStrategyComponent
     protected HttpBinding httpBinding;
     protected HttpConfiguration httpConfiguration;
 
-    // TODO: HttpCommonEndpoint
-    public HttpCommonComponent(Class<? extends Endpoint> endpointClass) {
+    public HttpCommonComponent(Class<? extends HttpCommonEndpoint> endpointClass) {
         super(endpointClass);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/600063ab/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
index 1c40e38..ae2e39e 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
@@ -32,30 +32,30 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
 
     // Note: all options must be documented with description in annotations so extended components can access the documentation
 
-    private static final Logger LOG = LoggerFactory.getLogger(HttpEndpoint.class);
+    private static final Logger LOG = LoggerFactory.getLogger(HttpCommonEndpoint.class);
 
-    private HttpCommonComponent component;
-    private UrlRewrite urlRewrite;
+    HttpCommonComponent component;
+    UrlRewrite urlRewrite;
 
     @UriPath(label = "producer", description = "The url of the HTTP endpoint to call.") @Metadata(required = "true")
-    private URI httpUri;
+    URI httpUri;
     @UriParam(description = "To use a custom HeaderFilterStrategy to filter header to and from Camel message.")
-    private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
+    HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
     @UriParam(description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
-    private HttpBinding binding;
+    HttpBinding binding;
     @UriParam(label = "producer", defaultValue = "true",
             description = "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.")
-    private boolean throwExceptionOnFailure = true;
+    boolean throwExceptionOnFailure = true;
     @UriParam(label = "producer",
             description = "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.")
-    private boolean bridgeEndpoint;
+    boolean bridgeEndpoint;
     @UriParam(label = "consumer",
             description = "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.")
-    private boolean matchOnUriPrefix;
+    boolean matchOnUriPrefix;
     @UriParam(defaultValue = "true", description = "If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response")
-    private boolean chunked = true;
+    boolean chunked = true;
     @UriParam(label = "consumer",
             description = "Determines whether or not the raw input stream from Jetty is cached or not"
                     + " (Camel will read the stream into a in memory/overflow to file, Stream caching) cache."
@@ -66,36 +66,36 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements Head
                     + " if this option is false to support reading the stream multiple times."
                     + " If you use Jetty 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.")
-    private boolean disableStreamCache;
+    boolean disableStreamCache;
     @UriParam(label = "producer", description = "The proxy host name")
-    private String proxyHost;
+    String proxyHost;
     @UriParam(label = "producer", description = "The proxy port number")
-    private int proxyPort;
+    int proxyPort;
     @UriParam(label = "producer", enums = "Basic,Digest,NTLM", description = "Authentication method for proxy, either as Basic, Digest or NTLM.")
-    private String authMethodPriority;
+    String authMethodPriority;
     @UriParam(description = "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.")
-    private boolean transferException;
+    boolean transferException;
     @UriParam(label = "consumer",
             description = "Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.")
-    private boolean traceEnabled;
+    boolean traceEnabled;
     @UriParam(label = "consumer",
             description = "Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. Multiple methods can be specified separated by comma.")
-    private String httpMethodRestrict;
+    String httpMethodRestrict;
     @UriParam(label = "consumer",
             description = "To use a custom buffer size on the javax.servlet.ServletResponse.")
-    private Integer responseBufferSize;
+    Integer responseBufferSize;
     @UriParam(label = "producer",
             description = "If this option is true, The http producer won't read response body and cache the input stream")
-    private boolean ignoreResponseBody;
+    boolean ignoreResponseBody;
     @UriParam(label = "producer", defaultValue = "true",
             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).")
-    private boolean copyHeaders = true;
+    boolean copyHeaders = true;
     @UriParam(label = "consumer",
             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.")
-    private boolean eagerCheckContentAvailable;
+    boolean eagerCheckContentAvailable;
 
     public HttpCommonEndpoint() {
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/600063ab/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
index a31ec23..23b1a20 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
@@ -26,13 +26,7 @@ import org.apache.camel.Consumer;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
-import org.apache.camel.impl.DefaultEndpoint;
-import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.spi.HeaderFilterStrategyAware;
-import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpConnectionManager;
@@ -47,77 +41,15 @@ import org.slf4j.LoggerFactory;
  * @version 
  */
 @UriEndpoint(scheme = "http,https", title = "HTTP,HTTPS", syntax = "http:httpUri", producerOnly = true, label = "http")
-public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware {
+public class HttpEndpoint extends HttpCommonEndpoint {
 
     // Note: all options must be documented with description in annotations so extended components can access the documentation
 
     private static final Logger LOG = LoggerFactory.getLogger(HttpEndpoint.class);
 
-    private HttpComponent component;
     private HttpClientParams clientParams;
     private HttpClientConfigurer httpClientConfigurer;
     private HttpConnectionManager httpConnectionManager;
-    private UrlRewrite urlRewrite;
-
-    @UriPath(label = "producer", description = "The url of the HTTP endpoint to call.") @Metadata(required = "true")
-    private URI httpUri;
-    @UriParam(description = "To use a custom HeaderFilterStrategy to filter header to and from Camel message.")
-    private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
-    @UriParam(description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
-    private HttpBinding binding;
-    @UriParam(label = "producer", defaultValue = "true",
-            description = "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.")
-    private boolean throwExceptionOnFailure = true;
-    @UriParam(label = "producer",
-            description = "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.")
-    private boolean bridgeEndpoint;
-    @UriParam(label = "consumer",
-            description = "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.")
-    private boolean matchOnUriPrefix;
-    @UriParam(defaultValue = "true", description = "If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response")
-    private boolean chunked = true;
-    @UriParam(label = "consumer",
-            description = "Determines whether or not the raw input stream from Jetty 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 Jetty 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 Jetty 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.")
-    private boolean disableStreamCache;
-    @UriParam(label = "producer", description = "The proxy host name")
-    private String proxyHost;
-    @UriParam(label = "producer", description = "The proxy port number")
-    private int proxyPort;
-    @UriParam(label = "producer", enums = "Basic,Digest,NTLM", description = "Authentication method for proxy, either as Basic, Digest or NTLM.")
-    private String authMethodPriority;
-    @UriParam(description = "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.")
-    private boolean transferException;
-    @UriParam(label = "consumer",
-            description = "Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.")
-    private boolean traceEnabled;
-    @UriParam(label = "consumer",
-            description = "Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. Multiple methods can be specified separated by comma.")
-    private String httpMethodRestrict;
-    @UriParam(label = "consumer",
-            description = "To use a custom buffer size on the javax.servlet.ServletResponse.")
-    private Integer responseBufferSize;
-    @UriParam(label = "producer",
-            description = "If this option is true, The http producer won't read response body and cache the input stream")
-    private boolean ignoreResponseBody;
-    @UriParam(label = "producer", defaultValue = "true",
-            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).")
-    private boolean copyHeaders = true;
-    @UriParam(label = "consumer",
-            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.")
-    private boolean eagerCheckContentAvailable;
 
     public HttpEndpoint() {
     }
@@ -137,9 +69,8 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
 
     public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, HttpClientParams clientParams,
                         HttpConnectionManager httpConnectionManager, HttpClientConfigurer clientConfigurer) throws URISyntaxException {
-        super(endPointURI, component);
+        super(endPointURI, component, httpURI);
         this.component = component;
-        this.httpUri = httpURI;
         this.clientParams = clientParams;
         this.httpClientConfigurer = clientConfigurer;
         this.httpConnectionManager = httpConnectionManager;
@@ -209,24 +140,6 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         return answer;
     }
 
-    public void connect(HttpConsumer consumer) throws Exception {
-        component.connect(consumer);
-    }
-
-    public void disconnect(HttpConsumer consumer) throws Exception {
-        component.disconnect(consumer);
-    }
-
-    public boolean isLenientProperties() {
-        // true to allow dynamic URI options to be configured and passed to external system for eg. the HttpProducer
-        return true;
-    }
-
-    public boolean isSingleton() {
-        return true;
-    }
-
-
     // Properties
     //-------------------------------------------------------------------------
 
@@ -260,55 +173,6 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         this.httpClientConfigurer = httpClientConfigurer;
     }
 
-    public HttpBinding getBinding() {
-        if (binding == null) {
-            // create a new binding and use the options from this endpoint
-            binding = new DefaultHttpBinding();
-            binding.setHeaderFilterStrategy(getHeaderFilterStrategy());
-            binding.setTransferException(isTransferException());
-            binding.setEagerCheckContentAvailable(isEagerCheckContentAvailable());
-        }
-        return binding;
-    }
-
-    /**
-     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-     */
-    public void setBinding(HttpBinding binding) {
-        this.binding = binding;
-    }
-
-    public String getPath() {
-        //if the path is empty, we just return the default path here
-        return httpUri.getPath().length() == 0 ? "/" : httpUri.getPath();
-    }
-
-    public int getPort() {
-        if (httpUri.getPort() == -1) {
-            if ("https".equals(getProtocol())) {
-                return 443;
-            } else {
-                return 80;
-            }
-        }
-        return httpUri.getPort();
-    }
-
-    public String getProtocol() {
-        return httpUri.getScheme();
-    }
-
-    public URI getHttpUri() {
-        return httpUri;
-    }
-
-    /**
-     * The url of the HTTP endpoint to call.
-     */
-    public void setHttpUri(URI httpUri) {
-        this.httpUri = httpUri;
-    }
-
     public HttpConnectionManager getHttpConnectionManager() {
         return httpConnectionManager;
     }
@@ -320,207 +184,4 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         this.httpConnectionManager = httpConnectionManager;
     }
 
-    public HeaderFilterStrategy getHeaderFilterStrategy() {
-        return headerFilterStrategy;
-    }
-
-    /**
-     * To use a custom HeaderFilterStrategy to filter header to and from Camel message.
-     */
-    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
-        this.headerFilterStrategy = headerFilterStrategy;
-    }
-
-    public boolean isThrowExceptionOnFailure() {
-        return throwExceptionOnFailure;
-    }
-
-    /**
-     * 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.
-     */
-    public void setThrowExceptionOnFailure(boolean throwExceptionOnFailure) {
-        this.throwExceptionOnFailure = throwExceptionOnFailure;
-    }
-
-    public boolean isBridgeEndpoint() {
-        return bridgeEndpoint;
-    }
-
-    /**
-     * 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.
-     */
-    public void setBridgeEndpoint(boolean bridge) {
-        this.bridgeEndpoint = bridge;
-    }
-
-    public boolean isMatchOnUriPrefix() {
-        return matchOnUriPrefix;
-    }
-
-    /**
-     * Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.
-     * <p/>
-     * See more details at: http://camel.apache.org/how-do-i-let-jetty-match-wildcards.html
-     */
-    public void setMatchOnUriPrefix(boolean match) {
-        this.matchOnUriPrefix = match;
-    }
-
-    public boolean isDisableStreamCache() {
-        return this.disableStreamCache;
-    }
-
-    /**
-     * Determines whether or not the raw input stream from Jetty 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 Jetty 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 Jetty 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.
-     */
-    public void setDisableStreamCache(boolean disable) {
-        this.disableStreamCache = disable;
-    }
-
-    public boolean isChunked() {
-        return this.chunked;
-    }
-
-    /**
-     * If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response
-     */
-    public void setChunked(boolean chunked) {
-        this.chunked = chunked;
-    }
-
-    public String getProxyHost() {
-        return proxyHost;
-    }
-
-    /**
-     * The proxy host name
-     */
-    public void setProxyHost(String proxyHost) {
-        this.proxyHost = proxyHost;
-    }
-
-    public int getProxyPort() {
-        return proxyPort;
-    }
-
-    /**
-     * The proxy port number
-     */
-    public void setProxyPort(int proxyPort) {
-        this.proxyPort = proxyPort;
-    }
-
-    public String getAuthMethodPriority() {
-        return authMethodPriority;
-    }
-
-    /**
-     * Authentication method for proxy, either as Basic, Digest or NTLM.
-     */
-    public void setAuthMethodPriority(String authMethodPriority) {
-        this.authMethodPriority = authMethodPriority;
-    }
-
-    public boolean isTransferException() {
-        return transferException;
-    }
-
-    /**
-     * 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.
-     */
-    public void setTransferException(boolean transferException) {
-        this.transferException = transferException;
-    }
-
-    public boolean isTraceEnabled() {
-        return this.traceEnabled;
-    }
-
-    /**
-     * Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.
-     */
-    public void setTraceEnabled(boolean traceEnabled) {
-        this.traceEnabled = traceEnabled;
-    }
-
-    public String getHttpMethodRestrict() {
-        return httpMethodRestrict;
-    }
-
-    /**
-     * Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc.
-     * Multiple methods can be specified separated by comma.
-     */
-    public void setHttpMethodRestrict(String httpMethodRestrict) {
-        this.httpMethodRestrict = httpMethodRestrict;
-    }
-
-    public UrlRewrite getUrlRewrite() {
-        return 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
-     */
-    public void setUrlRewrite(UrlRewrite urlRewrite) {
-        this.urlRewrite = urlRewrite;
-    }
-
-    public Integer getResponseBufferSize() {
-        return responseBufferSize;
-    }
-
-    /**
-     * To use a custom buffer size on the javax.servlet.ServletResponse.
-     */
-    public void setResponseBufferSize(Integer responseBufferSize) {
-        this.responseBufferSize = responseBufferSize;
-    }
-
-    public boolean isIgnoreResponseBody() {
-        return ignoreResponseBody;
-    }
-
-    /**
-     * If this option is true, The http producer won't read response body and cache the input stream.
-     */
-    public void setIgnoreResponseBody(boolean ignoreResponseBody) {
-        this.ignoreResponseBody = ignoreResponseBody;
-    }
-
-    /**
-     * 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).
-     */
-    public boolean isCopyHeaders() {
-        return copyHeaders;
-    }
-
-    public void setCopyHeaders(boolean copyHeaders) {
-        this.copyHeaders = copyHeaders;
-    }
-
-    public boolean isEagerCheckContentAvailable() {
-        return eagerCheckContentAvailable;
-    }
-
-    /**
-     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
-     * This can be turned on in case HTTP clients do not send streamed data.
-     */
-    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
-        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
-    }
 }


[07/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: f685f36170832bfe20dab6ea49a1bd5c5ca049d1
Parents: e191504
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 09:49:15 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:31 2015 +0200

----------------------------------------------------------------------
 components/camel-http-common/pom.xml            |   7 +-
 .../services/org/apache/camel/TypeConverter     |  18 +
 .../camel/component/http/CamelServlet.java      | 248 ---------
 .../component/http/DefaultHttpBinding.java      | 498 -------------------
 .../camel/component/http/HttpBinding.java       | 162 ------
 .../component/http/HttpCommonComponent.java     |  75 ---
 .../component/http/HttpCommonEndpoint.java      | 383 --------------
 .../camel/component/http/HttpComponent.java     |  45 +-
 .../camel/component/http/HttpConfiguration.java | 146 ------
 .../camel/component/http/HttpConstants.java     |  29 --
 .../camel/component/http/HttpConsumer.java      |  83 ----
 .../camel/component/http/HttpConverter.java     | 100 ----
 .../camel/component/http/HttpEndpoint.java      |  14 +-
 .../http/HttpHeaderFilterStrategy.java          |  52 --
 .../camel/component/http/HttpMessage.java       |  81 ---
 .../http/HttpOperationFailedException.java      |  75 ---
 .../component/http/HttpPollingConsumer.java     |   4 +-
 .../camel/component/http/HttpProducer.java      |   8 +-
 .../http/HttpProtocolHeaderFilterStrategy.java  |  88 ----
 .../HttpServletResolveConsumerStrategy.java     |  50 --
 .../component/http/HttpServletUrlRewrite.java   |  45 --
 ...xtParametersSecureProtocolSocketFactory.java |   3 +-
 .../http/ServletResolveConsumerStrategy.java    |  37 --
 .../apache/camel/component/http/UrlRewrite.java |  41 --
 .../http/helper/CamelFileDataSource.java        |  53 --
 .../camel/component/http/helper/HttpHelper.java | 461 -----------------
 .../http/helper/HttpMethodsHelper.java          |  52 ++
 .../UrlRewriteHttpServletRequestAdapter.java    |  50 --
 .../services/org/apache/camel/TypeConverter     |   1 -
 .../camel/component/http/GoogleUrlRewrite.java  |   1 +
 .../http/HttpAuthMethodPriorityTest.java        |   3 +-
 .../http/HttpConnectionManagerSettingTest.java  |   1 +
 ...tpEndpointOptionsNotChangeComponentTest.java |   2 +
 .../camel/component/http/HttpGetTest.java       |   1 -
 .../http/HttpHeaderFilterStrategyTest.java      |   1 +
 .../component/http/HttpPostWithBodyTest.java    |   1 +
 .../http/HttpProducerSelectMethodTest.java      |   1 +
 .../component/http/HttpProxyAuthBasicTest.java  |   3 +-
 .../component/http/HttpProxyAuthDigestTest.java |   3 +-
 .../component/http/HttpProxyAuthNTLMTest.java   |   3 +-
 .../camel/component/http/HttpProxyTest.java     |   1 +
 .../http/HttpQueryGoogleProxyTest.java          |   3 +-
 .../http/HttpReferenceParameterTest.java        |   1 +
 .../component/http/helper/HttpHelperTest.java   |  41 +-
 .../http/helper/HttpMethodsHelperTest.java      |  99 ++++
 45 files changed, 242 insertions(+), 2832 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http-common/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-http-common/pom.xml b/components/camel-http-common/pom.xml
index 87b166e..4736089 100644
--- a/components/camel-http-common/pom.xml
+++ b/components/camel-http-common/pom.xml
@@ -33,7 +33,7 @@
     <camel.osgi.import.before.defaults>
       javax.servlet.*;version="${servlet-version-range}"
     </camel.osgi.import.before.defaults>
-    <camel.osgi.export.pkg>org.apache.camel.http.*</camel.osgi.export.pkg>
+    <camel.osgi.export.pkg>org.apache.camel.http.common.*</camel.osgi.export.pkg>
   </properties>
 
   <dependencies>
@@ -47,11 +47,6 @@
       <artifactId>geronimo-servlet_3.0_spec</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>commons-codec</groupId>
-      <artifactId>commons-codec</artifactId>
-    </dependency>
-
     <!-- testing -->
     <dependency>
       <groupId>org.apache.camel</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http-common/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/resources/META-INF/services/org/apache/camel/TypeConverter b/components/camel-http-common/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
new file mode 100644
index 0000000..adacd8d
--- /dev/null
+++ b/components/camel-http-common/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
@@ -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.http.common.HttpConverter

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
deleted file mode 100644
index b6cece8..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/**
- * 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.util.Collections;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.component.http.helper.HttpHelper;
-import org.apache.camel.impl.DefaultExchange;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @version 
- */
-public class CamelServlet extends HttpServlet {
-    private static final long serialVersionUID = -7061982839117697829L;
-    protected final Logger log = LoggerFactory.getLogger(getClass());
-    
-    /**
-     *  We have to define this explicitly so the name can be set as we can not always be
-     *  sure that it is already set via the init method
-     */
-    private String servletName;
-
-    private ServletResolveConsumerStrategy servletResolveConsumerStrategy = new HttpServletResolveConsumerStrategy();
-    private final ConcurrentMap<String, HttpConsumer> consumers = new ConcurrentHashMap<String, HttpConsumer>();
-   
-    @Override
-    public void init(ServletConfig config) throws ServletException {
-        super.init(config);
-        this.servletName = config.getServletName();
-    }
-
-    @Override
-    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        log.trace("Service: {}", request);
-
-        // Is there a consumer registered for the request.
-        HttpConsumer consumer = resolve(request);
-        if (consumer == null) {
-            log.debug("No consumer to service request {}", request);
-            response.sendError(HttpServletResponse.SC_NOT_FOUND);
-            return;
-        }       
-        
-        // are we suspended?
-        if (consumer.isSuspended()) {
-            log.debug("Consumer suspended, cannot service request {}", request);
-            response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
-            return;
-        }
-
-        // if its an OPTIONS request then return which method is allowed
-        if ("OPTIONS".equals(request.getMethod())) {
-            String s;
-            if (consumer.getEndpoint().getHttpMethodRestrict() != null) {
-                s = "OPTIONS," + consumer.getEndpoint().getHttpMethodRestrict();
-            } else {
-                // allow them all
-                s = "GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,CONNECT,PATCH";
-            }
-            response.addHeader("Allow", s);
-            response.setStatus(HttpServletResponse.SC_OK);
-            return;
-        }
-        
-        if (consumer.getEndpoint().getHttpMethodRestrict() != null 
-            && !consumer.getEndpoint().getHttpMethodRestrict().contains(request.getMethod())) {
-            response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
-            return;
-        }
-
-        if ("TRACE".equals(request.getMethod()) && !consumer.isTraceEnabled()) {
-            response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
-            return;
-        }
-        
-        // create exchange and set data on it
-        Exchange exchange = new DefaultExchange(consumer.getEndpoint(), ExchangePattern.InOut);
-
-        if (consumer.getEndpoint().isBridgeEndpoint()) {
-            exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE);
-            exchange.setProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE);
-        }
-        if (consumer.getEndpoint().isDisableStreamCache()) {
-            exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE);
-        }
-
-        // we override the classloader before building the HttpMessage just in case the binding
-        // does some class resolution
-        ClassLoader oldTccl = overrideTccl(exchange);
-        HttpHelper.setCharsetFromContentType(request.getContentType(), exchange);
-        exchange.setIn(new HttpMessage(exchange, request, response));
-        // set context path as header
-        String contextPath = consumer.getEndpoint().getPath();
-        exchange.getIn().setHeader("CamelServletContextPath", contextPath);
-
-        String httpPath = (String)exchange.getIn().getHeader(Exchange.HTTP_PATH);
-        // here we just remove the CamelServletContextPath part from the HTTP_PATH
-        if (contextPath != null
-            && httpPath.startsWith(contextPath)) {
-            exchange.getIn().setHeader(Exchange.HTTP_PATH,
-                    httpPath.substring(contextPath.length()));
-        }
-
-        // we want to handle the UoW
-        try {
-            consumer.createUoW(exchange);
-        } catch (Exception e) {
-            log.error("Error processing request", e);
-            throw new ServletException(e);
-        }
-
-        try {
-            if (log.isTraceEnabled()) {
-                log.trace("Processing request for exchangeId: {}", exchange.getExchangeId());
-            }
-            // process the exchange
-            consumer.getProcessor().process(exchange);
-        } catch (Exception e) {
-            exchange.setException(e);
-        }
-
-        try {
-            // now lets output to the response
-            if (log.isTraceEnabled()) {
-                log.trace("Writing response for exchangeId: {}", exchange.getExchangeId());
-            }
-            Integer bs = consumer.getEndpoint().getResponseBufferSize();
-            if (bs != null) {
-                log.trace("Using response buffer size: {}", bs);
-                response.setBufferSize(bs);
-            }
-            consumer.getBinding().writeResponse(exchange, response);
-        } catch (IOException e) {
-            log.error("Error processing request", e);
-            throw e;
-        } catch (Exception e) {
-            log.error("Error processing request", e);
-            throw new ServletException(e);
-        } finally {
-            consumer.doneUoW(exchange);
-            restoreTccl(exchange, oldTccl);
-        }
-    }
-
-    /**
-     * @deprecated use {@link ServletResolveConsumerStrategy#resolve(javax.servlet.http.HttpServletRequest, java.util.Map)}
-     */
-    @Deprecated
-    protected HttpConsumer resolve(HttpServletRequest request) {
-        return getServletResolveConsumerStrategy().resolve(request, getConsumers());
-    }
-
-    public void connect(HttpConsumer consumer) {
-        log.debug("Connecting consumer: {}", consumer);
-        consumers.put(consumer.getEndpoint().getEndpointUri(), consumer);
-    }
-
-    public void disconnect(HttpConsumer consumer) {
-        log.debug("Disconnecting consumer: {}", consumer);
-        consumers.remove(consumer.getEndpoint().getEndpointUri());
-    }
-
-    public String getServletName() {
-        return servletName;
-    }
-
-    public void setServletName(String servletName) {
-        this.servletName = servletName;
-    }
-
-    public ServletResolveConsumerStrategy getServletResolveConsumerStrategy() {
-        return servletResolveConsumerStrategy;
-    }
-
-    public void setServletResolveConsumerStrategy(ServletResolveConsumerStrategy servletResolveConsumerStrategy) {
-        this.servletResolveConsumerStrategy = servletResolveConsumerStrategy;
-    }
-
-    public Map<String, HttpConsumer> getConsumers() {
-        return Collections.unmodifiableMap(consumers);
-    }
-
-    /**
-     * Override the Thread Context ClassLoader if need be.
-     *
-     * @param exchange
-     * @return old classloader if overridden; otherwise returns null
-     */
-    protected ClassLoader overrideTccl(final Exchange exchange) {
-        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
-        ClassLoader appCtxCl = exchange.getContext().getApplicationContextClassLoader();
-        if (oldClassLoader == null || appCtxCl == null) {
-            return null;
-        }
-        
-        if (!oldClassLoader.equals(appCtxCl)) {
-            Thread.currentThread().setContextClassLoader(appCtxCl);
-            if (log.isTraceEnabled()) {
-                log.trace("Overrode TCCL for exchangeId {} to {} on thread {}", 
-                        new Object[] {exchange.getExchangeId(), appCtxCl, Thread.currentThread().getName()});
-            }
-            return oldClassLoader;
-        }
-        return null;
-    }
-
-    /**
-     * Restore the Thread Context ClassLoader if the old TCCL is not null.
-     */
-    protected void restoreTccl(final Exchange exchange, ClassLoader oldTccl) {
-        if (oldTccl == null) {
-            return;
-        }
-        Thread.currentThread().setContextClassLoader(oldTccl);
-        if (log.isTraceEnabled()) {
-            log.trace("Restored TCCL for exchangeId {} to {} on thread {}", 
-                    new String[] {exchange.getExchangeId(), oldTccl.toString(), Thread.currentThread().getName()});
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
deleted file mode 100644
index ee5519f..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
+++ /dev/null
@@ -1,498 +0,0 @@
-/**
- * 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.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.net.URLDecoder;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Map;
-import javax.activation.DataHandler;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.InvalidPayloadException;
-import org.apache.camel.Message;
-import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.StreamCache;
-import org.apache.camel.component.http.helper.CamelFileDataSource;
-import org.apache.camel.component.http.helper.HttpHelper;
-import org.apache.camel.converter.stream.CachedOutputStream;
-import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.util.GZIPHelper;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.MessageHelper;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Binding between {@link HttpMessage} and {@link HttpServletResponse}.
- * <p/>
- * Uses by default the {@link org.apache.camel.component.http.HttpHeaderFilterStrategy}
- *
- * @version 
- */
-public class DefaultHttpBinding implements HttpBinding {
-
-    private static final Logger LOG = LoggerFactory.getLogger(DefaultHttpBinding.class);
-    private boolean useReaderForPayload;
-    private boolean eagerCheckContentAvailable;
-    private boolean transferException;
-    private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
-
-    public DefaultHttpBinding() {
-    }
-
-    @Deprecated
-    public DefaultHttpBinding(HeaderFilterStrategy headerFilterStrategy) {
-        this.headerFilterStrategy = headerFilterStrategy;
-    }
-
-    @Deprecated
-    public DefaultHttpBinding(HttpEndpoint endpoint) {
-        this.headerFilterStrategy = endpoint.getHeaderFilterStrategy();
-        this.transferException = endpoint.isTransferException();
-    }
-
-    public void readRequest(HttpServletRequest request, HttpMessage message) {
-        LOG.trace("readRequest {}", request);
-        
-        // lets force a parse of the body and headers
-        message.getBody();
-        // populate the headers from the request
-        Map<String, Object> headers = message.getHeaders();
-        
-        //apply the headerFilterStrategy
-        Enumeration<?> names = request.getHeaderNames();
-        while (names.hasMoreElements()) {
-            String name = (String)names.nextElement();
-            String value = request.getHeader(name);
-            // use http helper to extract parameter value as it may contain multiple values
-            Object extracted = HttpHelper.extractHttpParameterValue(value);
-            // mapping the content-type
-            if (name.toLowerCase().equals("content-type")) {
-                name = Exchange.CONTENT_TYPE;
-            }
-            if (headerFilterStrategy != null
-                && !headerFilterStrategy.applyFilterToExternalHeaders(name, extracted, message.getExchange())) {
-                HttpHelper.appendHeader(headers, name, extracted);
-            }
-        }
-                
-        if (request.getCharacterEncoding() != null) {
-            headers.put(Exchange.HTTP_CHARACTER_ENCODING, request.getCharacterEncoding());
-            message.getExchange().setProperty(Exchange.CHARSET_NAME, request.getCharacterEncoding());
-        }
-
-        try {
-            populateRequestParameters(request, message);
-        } catch (Exception e) {
-            throw new RuntimeCamelException("Cannot read request parameters due " + e.getMessage(), e);
-        }
-        
-        Object body = message.getBody();
-        // reset the stream cache if the body is the instance of StreamCache
-        if (body instanceof StreamCache) {
-            ((StreamCache)body).reset();
-        }
-
-        // store the method and query and other info in headers as String types
-        headers.put(Exchange.HTTP_METHOD, request.getMethod());
-        headers.put(Exchange.HTTP_QUERY, request.getQueryString());
-        headers.put(Exchange.HTTP_URL, request.getRequestURL().toString());
-        headers.put(Exchange.HTTP_URI, request.getRequestURI());
-        headers.put(Exchange.HTTP_PATH, request.getPathInfo());
-        headers.put(Exchange.CONTENT_TYPE, request.getContentType());
-
-        if (LOG.isTraceEnabled()) {
-            LOG.trace("HTTP method {}", request.getMethod());
-            LOG.trace("HTTP query {}", request.getQueryString());
-            LOG.trace("HTTP url {}", request.getRequestURL());
-            LOG.trace("HTTP uri {}", request.getRequestURI());
-            LOG.trace("HTTP path {}", request.getPathInfo());
-            LOG.trace("HTTP content-type {}", request.getContentType());
-        }
-
-        // if content type is serialized java object, then de-serialize it to a Java object
-        if (request.getContentType() != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(request.getContentType())) {
-            try {
-                InputStream is = message.getExchange().getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, body);
-                Object object = HttpHelper.deserializeJavaObjectFromStream(is, message.getExchange().getContext());
-                if (object != null) {
-                    message.setBody(object);
-                }
-            } catch (Exception e) {
-                throw new RuntimeCamelException("Cannot deserialize body to Java object", e);
-            }
-        }
-        
-        populateAttachments(request, message);
-    }
-
-    protected void populateRequestParameters(HttpServletRequest request, HttpMessage message) throws Exception {
-        //we populate the http request parameters without checking the request method
-        Map<String, Object> headers = message.getHeaders();
-        Enumeration<?> names = request.getParameterNames();
-        while (names.hasMoreElements()) {
-            String name = (String)names.nextElement();
-            // there may be multiple values for the same name
-            String[] values = request.getParameterValues(name);
-            LOG.trace("HTTP parameter {} = {}", name, values);
-
-            if (values != null) {
-                for (String value : values) {
-                    if (headerFilterStrategy != null
-                        && !headerFilterStrategy.applyFilterToExternalHeaders(name, value, message.getExchange())) {
-                        HttpHelper.appendHeader(headers, name, value);
-                    }
-                }
-            }
-        }
-
-        LOG.trace("HTTP method {} with Content-Type {}", request.getMethod(), request.getContentType());
-        Boolean flag = message.getHeader(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.class);
-        boolean skipWwwFormUrlEncoding =  flag != null ? flag : false; 
-        if (request.getMethod().equals("POST") && request.getContentType() != null
-                && request.getContentType().startsWith(HttpConstants.CONTENT_TYPE_WWW_FORM_URLENCODED)
-                && !skipWwwFormUrlEncoding) {
-            String charset = request.getCharacterEncoding();
-            if (charset == null) {
-                charset = "UTF-8";
-            }
-            // Push POST form params into the headers to retain compatibility with DefaultHttpBinding
-            String body = message.getBody(String.class);
-            if (ObjectHelper.isNotEmpty(body)) {
-                for (String param : body.split("&")) {
-                    String[] pair = param.split("=", 2);
-                    if (pair.length == 2) {
-                        String name = URLDecoder.decode(pair[0], charset);
-                        String value = URLDecoder.decode(pair[1], charset);
-                        if (headerFilterStrategy != null
-                                && !headerFilterStrategy.applyFilterToExternalHeaders(name, value, message.getExchange())) {
-                            HttpHelper.appendHeader(headers, name, value);
-                        }
-                    } else {
-                        throw new IllegalArgumentException("Invalid parameter, expected to be a pair but was " + param);
-                    }
-                }
-            }
-        }
-    }
-    
-    protected void populateAttachments(HttpServletRequest request, HttpMessage message) {
-        // check if there is multipart files, if so will put it into DataHandler
-        Enumeration<?> names = request.getAttributeNames();
-        while (names.hasMoreElements()) {
-            String name = (String) names.nextElement();
-            Object object = request.getAttribute(name);
-            LOG.trace("HTTP attachment {} = {}", name, object);
-            if (object instanceof File) {
-                String fileName = request.getParameter(name);
-                message.addAttachment(fileName, new DataHandler(new CamelFileDataSource((File)object, fileName)));
-            }
-        }
-    }
-
-    public void writeResponse(Exchange exchange, HttpServletResponse response) throws IOException {
-        Message target = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
-        if (exchange.isFailed()) {
-            if (exchange.getException() != null) {
-                doWriteExceptionResponse(exchange.getException(), response);
-            } else {
-                // it must be a fault, no need to check for the fault flag on the message
-                doWriteFaultResponse(target, response, exchange);
-            }
-        } else {
-            if (exchange.hasOut()) {
-                // just copy the protocol relates header if we do not have them
-                copyProtocolHeaders(exchange.getIn(), exchange.getOut());
-            }
-            doWriteResponse(target, response, exchange);
-        }
-    }
-
-    private void copyProtocolHeaders(Message request, Message response) {
-        if (request.getHeader(Exchange.CONTENT_ENCODING) != null) {
-            String contentEncoding = request.getHeader(Exchange.CONTENT_ENCODING, String.class);
-            response.setHeader(Exchange.CONTENT_ENCODING, contentEncoding);
-        }        
-        if (checkChunked(response, response.getExchange())) {
-            response.setHeader(Exchange.TRANSFER_ENCODING, "chunked");
-        }
-    }
-
-    public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException {
-        // 500 for internal server error
-        response.setStatus(500);
-
-        if (isTransferException()) {
-            // transfer the exception as a serialized java object
-            HttpHelper.writeObjectToServletResponse(response, exception);
-        } else {
-            // write stacktrace as plain text
-            response.setContentType("text/plain");
-            PrintWriter pw = response.getWriter();
-            exception.printStackTrace(pw);
-            pw.flush();
-        }
-    }
-
-    public void doWriteFaultResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
-        message.setHeader(Exchange.HTTP_RESPONSE_CODE, 500);
-        doWriteResponse(message, response, exchange);
-    }
-
-    public void doWriteResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
-        // set the status code in the response. Default is 200.
-        if (message.getHeader(Exchange.HTTP_RESPONSE_CODE) != null) {
-            int code = message.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class);
-            response.setStatus(code);
-        }
-        // set the content type in the response.
-        String contentType = MessageHelper.getContentType(message);
-        if (contentType != null) {
-            response.setContentType(contentType);
-        }
-
-        // append headers
-        // must use entrySet to ensure case of keys is preserved
-        for (Map.Entry<String, Object> entry : message.getHeaders().entrySet()) {
-            String key = entry.getKey();
-            Object value = entry.getValue();
-            // use an iterator as there can be multiple values. (must not use a delimiter)
-            final Iterator<?> it = ObjectHelper.createIterator(value, null);
-            while (it.hasNext()) {
-                String headerValue = exchange.getContext().getTypeConverter().convertTo(String.class, it.next());
-                if (headerValue != null && headerFilterStrategy != null
-                        && !headerFilterStrategy.applyFilterToCamelHeaders(key, headerValue, exchange)) {
-                    response.addHeader(key, headerValue);
-                }
-            }
-        }
-
-        // write the body.
-        if (message.getBody() != null) {
-            if (GZIPHelper.isGzip(message)) {
-                doWriteGZIPResponse(message, response, exchange);
-            } else {
-                doWriteDirectResponse(message, response, exchange);
-            }
-        }
-    }
-    
-    protected boolean isText(String contentType) {
-        if (contentType != null) {
-            String temp = contentType.toLowerCase();
-            if (temp.indexOf("text") >= 0 || temp.indexOf("html") >= 0) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    protected int copyStream(InputStream is, OutputStream os, int bufferSize) throws IOException {
-        try {
-            // copy stream, and must flush on each write as etc Jetty has better performance when
-            // flushing after writing to its servlet output stream
-            return IOHelper.copy(is, os, bufferSize, true);
-        } finally {
-            IOHelper.close(os, is);
-        }
-    }
-
-    protected void doWriteDirectResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
-        // if content type is serialized Java object, then serialize and write it to the response
-        String contentType = message.getHeader(Exchange.CONTENT_TYPE, String.class);
-        if (contentType != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) {
-            try {
-                Object object = message.getMandatoryBody(Serializable.class);
-                HttpHelper.writeObjectToServletResponse(response, object);
-                // object is written so return
-                return;
-            } catch (InvalidPayloadException e) {
-                throw new IOException(e);
-            }
-        }
-
-        // prefer streaming
-        InputStream is = null;
-        if (checkChunked(message, exchange)) {
-            is = message.getBody(InputStream.class);
-        } else {
-            // try to use input stream first, so we can copy directly
-            if (!isText(contentType)) {
-                is = exchange.getContext().getTypeConverter().tryConvertTo(InputStream.class, message.getBody());
-            }
-        }
-
-        if (is != null) {
-            ServletOutputStream os = response.getOutputStream();
-            if (!checkChunked(message, exchange)) {
-                CachedOutputStream stream = new CachedOutputStream(exchange);
-                try {
-                    // copy directly from input stream to the cached output stream to get the content length
-                    int len = copyStream(is, stream, response.getBufferSize());
-                    // we need to setup the length if message is not chucked
-                    response.setContentLength(len);
-                    OutputStream current = stream.getCurrentStream();
-                    if (current instanceof ByteArrayOutputStream) {
-                        if (LOG.isDebugEnabled()) {
-                            LOG.debug("Streaming (direct) response in non-chunked mode with content-length {}");
-                        }
-                        ByteArrayOutputStream bos = (ByteArrayOutputStream) current;
-                        bos.writeTo(os);
-                    } else {
-                        if (LOG.isDebugEnabled()) {
-                            LOG.debug("Streaming response in non-chunked mode with content-length {} and buffer size: {}", len, len);
-                        }
-                        copyStream(stream.getInputStream(), os, len);
-                    }
-                } finally {
-                    IOHelper.close(is, os);
-                }
-            } else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Streaming response in chunked mode with buffer size {}", response.getBufferSize());
-                }
-                copyStream(is, os, response.getBufferSize());
-            }
-        } else {
-            // not convertable as a stream so fallback as a String
-            String data = message.getBody(String.class);
-            if (data != null) {
-                // set content length and encoding before we write data
-                String charset = IOHelper.getCharsetName(exchange, true);
-                final int dataByteLength = data.getBytes(charset).length;
-                response.setCharacterEncoding(charset);
-                response.setContentLength(dataByteLength);
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Writing response in non-chunked mode as plain text with content-length {} and buffer size: {}", dataByteLength, response.getBufferSize());
-                }
-                try {
-                    response.getWriter().print(data);
-                } finally {
-                    response.getWriter().flush();
-                }
-            }
-        }
-    }
-
-    protected boolean checkChunked(Message message, Exchange exchange) {
-        boolean answer = true;
-        if (message.getHeader(Exchange.HTTP_CHUNKED) == null) {
-            // check the endpoint option
-            Endpoint endpoint = exchange.getFromEndpoint();
-            if (endpoint instanceof HttpEndpoint) {
-                answer = ((HttpEndpoint)endpoint).isChunked();
-            }
-        } else {
-            answer = message.getHeader(Exchange.HTTP_CHUNKED, boolean.class);
-        }
-        return answer;
-    }
-
-    protected void doWriteGZIPResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
-        byte[] bytes;
-        try {
-            bytes = message.getMandatoryBody(byte[].class);
-        } catch (InvalidPayloadException e) {
-            throw ObjectHelper.wrapRuntimeCamelException(e);
-        }
-
-        byte[] data = GZIPHelper.compressGZIP(bytes);
-        ServletOutputStream os = response.getOutputStream();
-        try {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Streaming response as GZIP in non-chunked mode with content-length {} and buffer size: {}", data.length, response.getBufferSize());
-            }
-            response.setContentLength(data.length);
-            os.write(data);
-            os.flush();
-        } finally {
-            IOHelper.close(os);
-        }
-    }
-
-    public Object parseBody(HttpMessage httpMessage) throws IOException {
-        // lets assume the body is a reader
-        HttpServletRequest request = httpMessage.getRequest();
-        // there is only a body if we have a content length, or its -1 to indicate unknown length
-        int len = request.getContentLength();
-        LOG.trace("HttpServletRequest content-length: {}", len);
-        if (len == 0) {
-            return null;
-        }
-        if (isUseReaderForPayload()) {
-            // use reader to read the response body
-            return request.getReader();
-        } else {
-            // if we do not know if there is any data at all, then make sure to check the stream first
-            if (len < 0 && isEagerCheckContentAvailable()) {
-                InputStream is = request.getInputStream();
-                if (is.available() == 0) {
-                    // no data so return null
-                    return null;
-                }
-            }
-            // read the response body from servlet request
-            return HttpHelper.readRequestBodyFromServletRequest(request, httpMessage.getExchange());
-        }
-    }
-
-    public boolean isUseReaderForPayload() {
-        return useReaderForPayload;
-    }
-
-    public void setUseReaderForPayload(boolean useReaderForPayload) {
-        this.useReaderForPayload = useReaderForPayload;
-    }
-
-    public boolean isEagerCheckContentAvailable() {
-        return eagerCheckContentAvailable;
-    }
-
-    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
-        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
-    }
-
-    public boolean isTransferException() {
-        return transferException;
-    }
-
-    public void setTransferException(boolean transferException) {
-        this.transferException = transferException;
-    }
-
-    public HeaderFilterStrategy getHeaderFilterStrategy() {
-        return headerFilterStrategy;
-    }
-
-    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
-        this.headerFilterStrategy = headerFilterStrategy;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
deleted file mode 100644
index eb6670c..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * 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 javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.spi.HeaderFilterStrategy;
-
-/**
- * A pluggable strategy for configuring the http binding so reading request and writing response
- * can be customized using the Java Servlet API.
- * <p/>
- * This is also used by the <tt>camel-jetty</tt> component in the <tt>JettyHttpConsumer</tt> class.
- *
- * @version 
- */
-public interface HttpBinding {
-
-    /**
-     * Strategy to read the given request and bindings it to the given message.
-     *
-     * @param request  the request
-     * @param message  the message to populate with data from request
-     */
-    void readRequest(HttpServletRequest request, HttpMessage message);
-
-    /**
-     * Parses the body from a {@link org.apache.camel.component.http.HttpMessage}
-     *
-     * @param httpMessage the http message
-     * @return the parsed body returned as either a {@link java.io.InputStream} or a {@link java.io.Reader}
-     * depending on the {@link #setUseReaderForPayload(boolean)} property.
-     * @throws java.io.IOException can be thrown
-     */
-    Object parseBody(HttpMessage httpMessage) throws IOException;
-
-    /**
-     * Writes the exchange to the servlet response.
-     * <p/>
-     * Default implementation will delegate to the following methods depending on the status of the exchange
-     * <ul>
-     *   <li>doWriteResponse - processing returns a OUT message </li>
-     *   <li>doWriteFaultResponse - processing returns a fault message</li>
-     *   <li>doWriteResponse - processing returns an exception and status code 500</li>
-     * </ul>
-     *
-     * @param exchange the exchange
-     * @param response the http response
-     * @throws java.io.IOException can be thrown from http response
-     */
-    void writeResponse(Exchange exchange, HttpServletResponse response) throws IOException;
-
-    /**
-     * Strategy method that writes the response to the http response stream when an exception occurred
-     *
-     * @param exception  the exception occurred
-     * @param response   the http response
-     * @throws java.io.IOException can be thrown from http response
-     */
-    void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException;
-
-    /**
-     * Strategy method that writes the response to the http response stream for a fault message
-     *
-     * @param message  the fault message
-     * @param response the http response
-     * @param exchange the exchange to provide context for header filtering
-     * @throws java.io.IOException can be thrown from http response
-     */
-    void doWriteFaultResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException;
-
-    /**
-     * Strategy method that writes the response to the http response stream for an OUT message
-     *
-     * @param message  the OUT message
-     * @param response the http response
-     * @param exchange the exchange to provide context for header filtering
-     * @throws java.io.IOException can be thrown from http response
-     */
-    void doWriteResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException;
-
-    /**
-     * Should reader by used instead of input stream.
-     *
-     * @see #setUseReaderForPayload(boolean) for more details
-     * @return <tt>true</tt> if reader should be used
-     */
-    boolean isUseReaderForPayload();
-
-    /**
-     * Should the {@link javax.servlet.http.HttpServletRequest#getReader()} be exposed as the payload of input messages in the Camel
-     * {@link org.apache.camel.Message#getBody()} or not. If false then the {@link javax.servlet.http.HttpServletRequest#getInputStream()} will be exposed.
-     * <p/>
-     * Is default <tt>false</tt>.
-     *
-     * @param useReaderForPayload whether to use reader or not
-     */
-    void setUseReaderForPayload(boolean useReaderForPayload);
-
-    /**
-     * 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 (for example using Jetty or
-     * Servlet Camel components). 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.
-     */
-    boolean isTransferException();
-
-    /**
-     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
-     * This can be turned on in case HTTP clients do not send streamed data.
-     */
-    boolean isEagerCheckContentAvailable();
-
-    /**
-     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
-     * This can be turned on in case HTTP clients do not send streamed data.
-     */
-    void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable);
-
-    /**
-     * 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 (for example using Jetty or
-     * Servlet Camel components). 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.
-     */
-    void setTransferException(boolean transferException);
-
-    /**
-     * Gets the header filter strategy
-     *
-     * @return the strategy
-     */
-    HeaderFilterStrategy getHeaderFilterStrategy();
-
-    /**
-     * Sets the header filter strategy to use.
-     * <p/>
-     * Will default use {@link org.apache.camel.component.http.HttpHeaderFilterStrategy}
-     *
-     * @param headerFilterStrategy the custom strategy
-     */
-    void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy);
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
deleted file mode 100644
index 23b4455..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonComponent.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.impl.HeaderFilterStrategyComponent;
-
-public abstract class HttpCommonComponent extends HeaderFilterStrategyComponent {
-
-    protected HttpBinding httpBinding;
-    protected HttpConfiguration httpConfiguration;
-
-    public HttpCommonComponent(Class<? extends HttpCommonEndpoint> endpointClass) {
-        super(endpointClass);
-    }
-
-    /**
-     * Connects the URL specified on the endpoint to the specified processor.
-     *
-     * @param consumer the consumer
-     * @throws Exception can be thrown
-     */
-    public void connect(HttpConsumer consumer) throws Exception {
-    }
-
-    /**
-     * Disconnects the URL specified on the endpoint from the specified processor.
-     *
-     * @param consumer the consumer
-     * @throws Exception can be thrown
-     */
-    public void disconnect(HttpConsumer consumer) throws Exception {
-    }
-
-    @Override
-    protected boolean useIntrospectionOnEndpoint() {
-        return false;
-    }
-
-    public HttpBinding getHttpBinding() {
-        return httpBinding;
-    }
-
-    /**
-     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-     */
-    public void setHttpBinding(HttpBinding httpBinding) {
-        this.httpBinding = httpBinding;
-    }
-
-    public HttpConfiguration getHttpConfiguration() {
-        return httpConfiguration;
-    }
-
-    /**
-     * To use the shared HttpConfiguration as base configuration.
-     */
-    public void setHttpConfiguration(HttpConfiguration httpConfiguration) {
-        this.httpConfiguration = httpConfiguration;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
deleted file mode 100644
index ae2e39e..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpCommonEndpoint.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/**
- * 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.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.camel.impl.DefaultEndpoint;
-import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.spi.HeaderFilterStrategyAware;
-import org.apache.camel.spi.Metadata;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.spi.UriPath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class HttpCommonEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware {
-
-    // Note: all options must be documented with description in annotations so extended components can access the documentation
-
-    private static final Logger LOG = LoggerFactory.getLogger(HttpCommonEndpoint.class);
-
-    HttpCommonComponent component;
-    UrlRewrite urlRewrite;
-
-    @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.")
-    HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
-    @UriParam(description = "To use a custom HttpBinding to control the mapping between Camel message and HttpClient.")
-    HttpBinding binding;
-    @UriParam(label = "producer", defaultValue = "true",
-            description = "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.")
-    boolean throwExceptionOnFailure = true;
-    @UriParam(label = "producer",
-            description = "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.")
-    boolean bridgeEndpoint;
-    @UriParam(label = "consumer",
-            description = "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.")
-    boolean matchOnUriPrefix;
-    @UriParam(defaultValue = "true", description = "If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response")
-    boolean chunked = true;
-    @UriParam(label = "consumer",
-            description = "Determines whether or not the raw input stream from Jetty 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 Jetty 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 Jetty 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.")
-    boolean disableStreamCache;
-    @UriParam(label = "producer", description = "The proxy host name")
-    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.")
-    String authMethodPriority;
-    @UriParam(description = "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.")
-    boolean transferException;
-    @UriParam(label = "consumer",
-            description = "Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.")
-    boolean traceEnabled;
-    @UriParam(label = "consumer",
-            description = "Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. Multiple methods can be specified separated by comma.")
-    String httpMethodRestrict;
-    @UriParam(label = "consumer",
-            description = "To use a custom buffer size on the javax.servlet.ServletResponse.")
-    Integer responseBufferSize;
-    @UriParam(label = "producer",
-            description = "If this option is true, The http producer won't read response body and cache the input stream")
-    boolean ignoreResponseBody;
-    @UriParam(label = "producer", defaultValue = "true",
-            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",
-            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;
-
-    public HttpCommonEndpoint() {
-    }
-
-    public HttpCommonEndpoint(String endPointURI, HttpCommonComponent component, URI httpURI) throws URISyntaxException {
-        super(endPointURI, component);
-        this.component = component;
-        this.httpUri = httpURI;
-    }
-
-    public void connect(HttpConsumer consumer) throws Exception {
-        component.connect(consumer);
-    }
-
-    public void disconnect(HttpConsumer consumer) throws Exception {
-        component.disconnect(consumer);
-    }
-
-    public boolean isLenientProperties() {
-        // true to allow dynamic URI options to be configured and passed to external system for eg. the HttpProducer
-        return true;
-    }
-
-    public boolean isSingleton() {
-        return true;
-    }
-
-
-    // Properties
-    //-------------------------------------------------------------------------
-
-    public HttpBinding getBinding() {
-        if (binding == null) {
-            // create a new binding and use the options from this endpoint
-            binding = new DefaultHttpBinding();
-            binding.setHeaderFilterStrategy(getHeaderFilterStrategy());
-            binding.setTransferException(isTransferException());
-            binding.setEagerCheckContentAvailable(isEagerCheckContentAvailable());
-        }
-        return binding;
-    }
-
-    /**
-     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
-     */
-    public void setBinding(HttpBinding binding) {
-        this.binding = binding;
-    }
-
-    public String getPath() {
-        //if the path is empty, we just return the default path here
-        return httpUri.getPath().length() == 0 ? "/" : httpUri.getPath();
-    }
-
-    public int getPort() {
-        if (httpUri.getPort() == -1) {
-            if ("https".equals(getProtocol())) {
-                return 443;
-            } else {
-                return 80;
-            }
-        }
-        return httpUri.getPort();
-    }
-
-    public String getProtocol() {
-        return httpUri.getScheme();
-    }
-
-    public URI getHttpUri() {
-        return httpUri;
-    }
-
-    /**
-     * The url of the HTTP endpoint to call.
-     */
-    public void setHttpUri(URI httpUri) {
-        this.httpUri = httpUri;
-    }
-
-    public HeaderFilterStrategy getHeaderFilterStrategy() {
-        return headerFilterStrategy;
-    }
-
-    /**
-     * To use a custom HeaderFilterStrategy to filter header to and from Camel message.
-     */
-    public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {
-        this.headerFilterStrategy = headerFilterStrategy;
-    }
-
-    public boolean isThrowExceptionOnFailure() {
-        return throwExceptionOnFailure;
-    }
-
-    /**
-     * 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.
-     */
-    public void setThrowExceptionOnFailure(boolean throwExceptionOnFailure) {
-        this.throwExceptionOnFailure = throwExceptionOnFailure;
-    }
-
-    public boolean isBridgeEndpoint() {
-        return bridgeEndpoint;
-    }
-
-    /**
-     * 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.
-     */
-    public void setBridgeEndpoint(boolean bridge) {
-        this.bridgeEndpoint = bridge;
-    }
-
-    public boolean isMatchOnUriPrefix() {
-        return matchOnUriPrefix;
-    }
-
-    /**
-     * Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.
-     * <p/>
-     * See more details at: http://camel.apache.org/how-do-i-let-jetty-match-wildcards.html
-     */
-    public void setMatchOnUriPrefix(boolean match) {
-        this.matchOnUriPrefix = match;
-    }
-
-    public boolean isDisableStreamCache() {
-        return this.disableStreamCache;
-    }
-
-    /**
-     * Determines whether or not the raw input stream from Jetty 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 Jetty 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 Jetty 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.
-     */
-    public void setDisableStreamCache(boolean disable) {
-        this.disableStreamCache = disable;
-    }
-
-    public boolean isChunked() {
-        return this.chunked;
-    }
-
-    /**
-     * If this option is false Jetty servlet will disable the HTTP streaming and set the content-length header on the response
-     */
-    public void setChunked(boolean chunked) {
-        this.chunked = chunked;
-    }
-
-    public String getProxyHost() {
-        return proxyHost;
-    }
-
-    /**
-     * The proxy host name
-     */
-    public void setProxyHost(String proxyHost) {
-        this.proxyHost = proxyHost;
-    }
-
-    public int getProxyPort() {
-        return proxyPort;
-    }
-
-    /**
-     * The proxy port number
-     */
-    public void setProxyPort(int proxyPort) {
-        this.proxyPort = proxyPort;
-    }
-
-    public String getAuthMethodPriority() {
-        return authMethodPriority;
-    }
-
-    /**
-     * Authentication method for proxy, either as Basic, Digest or NTLM.
-     */
-    public void setAuthMethodPriority(String authMethodPriority) {
-        this.authMethodPriority = authMethodPriority;
-    }
-
-    public boolean isTransferException() {
-        return transferException;
-    }
-
-    /**
-     * 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.
-     */
-    public void setTransferException(boolean transferException) {
-        this.transferException = transferException;
-    }
-
-    public boolean isTraceEnabled() {
-        return this.traceEnabled;
-    }
-
-    /**
-     * Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.
-     */
-    public void setTraceEnabled(boolean traceEnabled) {
-        this.traceEnabled = traceEnabled;
-    }
-
-    public String getHttpMethodRestrict() {
-        return httpMethodRestrict;
-    }
-
-    /**
-     * Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc.
-     * Multiple methods can be specified separated by comma.
-     */
-    public void setHttpMethodRestrict(String httpMethodRestrict) {
-        this.httpMethodRestrict = httpMethodRestrict;
-    }
-
-    public UrlRewrite getUrlRewrite() {
-        return 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
-     */
-    public void setUrlRewrite(UrlRewrite urlRewrite) {
-        this.urlRewrite = urlRewrite;
-    }
-
-    public Integer getResponseBufferSize() {
-        return responseBufferSize;
-    }
-
-    /**
-     * To use a custom buffer size on the javax.servlet.ServletResponse.
-     */
-    public void setResponseBufferSize(Integer responseBufferSize) {
-        this.responseBufferSize = responseBufferSize;
-    }
-
-    public boolean isIgnoreResponseBody() {
-        return ignoreResponseBody;
-    }
-
-    /**
-     * If this option is true, The http producer won't read response body and cache the input stream.
-     */
-    public void setIgnoreResponseBody(boolean ignoreResponseBody) {
-        this.ignoreResponseBody = ignoreResponseBody;
-    }
-
-    /**
-     * 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).
-     */
-    public boolean isCopyHeaders() {
-        return copyHeaders;
-    }
-
-    public void setCopyHeaders(boolean copyHeaders) {
-        this.copyHeaders = copyHeaders;
-    }
-
-    public boolean isEagerCheckContentAvailable() {
-        return eagerCheckContentAvailable;
-    }
-
-    /**
-     * Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
-     * This can be turned on in case HTTP clients do not send streamed data.
-     */
-    public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) {
-        this.eagerCheckContentAvailable = eagerCheckContentAvailable;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
index e817d55..3599c64 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
@@ -25,6 +25,10 @@ import java.util.Set;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.http.common.HttpBinding;
+import org.apache.camel.http.common.HttpCommonComponent;
+import org.apache.camel.http.common.HttpConfiguration;
+import org.apache.camel.http.common.UrlRewrite;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.CollectionHelper;
 import org.apache.camel.util.IntrospectionSupport;
@@ -74,7 +78,7 @@ public class HttpComponent extends HttpCommonComponent {
 
         // authentication can be endpoint configured
         String authUsername = getAndRemoveParameter(parameters, "authUsername", String.class);
-        AuthMethod authMethod = getAndRemoveParameter(parameters, "authMethod", AuthMethod.class);
+        String authMethod = getAndRemoveParameter(parameters, "authMethod", String.class);
         // validate that if auth username is given then the auth method is also provided
         if (authUsername != null && authMethod == null) {
             throw new IllegalArgumentException("Option authMethod must be provided to use authentication");
@@ -92,7 +96,7 @@ public class HttpComponent extends HttpCommonComponent {
 
         // proxy authentication can be endpoint configured
         String proxyAuthUsername = getAndRemoveParameter(parameters, "proxyAuthUsername", String.class);
-        AuthMethod proxyAuthMethod = getAndRemoveParameter(parameters, "proxyAuthMethod", AuthMethod.class);
+        String proxyAuthMethod = getAndRemoveParameter(parameters, "proxyAuthMethod", String.class);
         // validate that if proxy auth username is given then the proxy auth method is also provided
         if (proxyAuthUsername != null && proxyAuthMethod == null) {
             throw new IllegalArgumentException("Option proxyAuthMethod must be provided to use proxy authentication");
@@ -116,7 +120,7 @@ public class HttpComponent extends HttpCommonComponent {
      *
      * @return configurer to used
      */
-    protected HttpClientConfigurer configureAuth(HttpClientConfigurer configurer, AuthMethod authMethod, String username,
+    protected HttpClientConfigurer configureAuth(HttpClientConfigurer configurer, String authMethod, String username,
                                                  String password, String domain, String host, Set<AuthMethod> authMethods) {
 
         // no auth is in use
@@ -132,13 +136,15 @@ public class HttpComponent extends HttpCommonComponent {
         ObjectHelper.notNull(username, "authUsername");
         ObjectHelper.notNull(password, "authPassword");
 
+        AuthMethod auth = getCamelContext().getTypeConverter().convertTo(AuthMethod.class, authMethod);
+
         // add it as a auth method used
-        authMethods.add(authMethod);
+        authMethods.add(auth);
 
-        if (authMethod == AuthMethod.Basic || authMethod == AuthMethod.Digest) {
+        if (auth == AuthMethod.Basic || auth == AuthMethod.Digest) {
             return CompositeHttpConfigurer.combineConfigurers(configurer,
                     new BasicAuthenticationHttpClientConfigurer(false, username, password));
-        } else if (authMethod == AuthMethod.NTLM) {
+        } else if (auth == AuthMethod.NTLM) {
             // domain is mandatory for NTLM
             ObjectHelper.notNull(domain, "authDomain");
             return CompositeHttpConfigurer.combineConfigurers(configurer,
@@ -153,7 +159,7 @@ public class HttpComponent extends HttpCommonComponent {
      *
      * @return configurer to used
      */
-    protected HttpClientConfigurer configureProxyAuth(HttpClientConfigurer configurer, AuthMethod authMethod, String username,
+    protected HttpClientConfigurer configureProxyAuth(HttpClientConfigurer configurer, String authMethod, String username,
                                                       String password, String domain, String host, Set<AuthMethod> authMethods) {
         // no proxy auth is in use
         if (username == null && authMethod == null) {
@@ -168,13 +174,15 @@ public class HttpComponent extends HttpCommonComponent {
         ObjectHelper.notNull(username, "proxyAuthUsername");
         ObjectHelper.notNull(password, "proxyAuthPassword");
 
+        AuthMethod auth = getCamelContext().getTypeConverter().convertTo(AuthMethod.class, authMethod);
+
         // add it as a auth method used
-        authMethods.add(authMethod);
+        authMethods.add(auth);
 
-        if (authMethod == AuthMethod.Basic || authMethod == AuthMethod.Digest) {
+        if (auth == AuthMethod.Basic || auth == AuthMethod.Digest) {
             return CompositeHttpConfigurer.combineConfigurers(configurer,
                     new BasicAuthenticationHttpClientConfigurer(true, username, password));
-        } else if (authMethod == AuthMethod.NTLM) {
+        } else if (auth == AuthMethod.NTLM) {
             // domain is mandatory for NTML
             ObjectHelper.notNull(domain, "proxyAuthDomain");
             return CompositeHttpConfigurer.combineConfigurers(configurer,
@@ -312,4 +320,21 @@ public class HttpComponent extends HttpCommonComponent {
         this.httpConnectionManager = httpConnectionManager;
     }
 
+    /**
+     * To use a custom HttpBinding to control the mapping between Camel message and HttpClient.
+     */
+    @Override
+    public void setHttpBinding(HttpBinding httpBinding) {
+        // need to override and call super for component docs
+        super.setHttpBinding(httpBinding);
+    }
+
+    /**
+     * To use the shared HttpConfiguration as base configuration.
+     */
+    @Override
+    public void setHttpConfiguration(HttpConfiguration httpConfiguration) {
+        // need to override and call super for component docs
+        super.setHttpConfiguration(httpConfiguration);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConfiguration.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConfiguration.java
deleted file mode 100644
index 20725ad..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConfiguration.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * 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.Serializable;
-
-/**
- * @version 
- */
-public class HttpConfiguration implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    private AuthMethod authMethod;
-    private String authUsername;
-    private String authPassword;
-    private String authDomain;
-    private String authHost;
-
-    private AuthMethod proxyAuthMethod;
-    private String proxyAuthUsername;
-    private String proxyAuthPassword;
-    private String proxyAuthDomain;
-    private String proxyAuthHost;
-
-    private String proxyHost;
-    private int proxyPort;
-    private String authMethodPriority;
-
-    public String getAuthUsername() {
-        return authUsername;
-    }
-
-    public void setAuthUsername(String authUsername) {
-        this.authUsername = authUsername;
-    }
-
-    public String getAuthPassword() {
-        return authPassword;
-    }
-
-    public void setAuthPassword(String authPassword) {
-        this.authPassword = authPassword;
-    }
-
-    public String getAuthDomain() {
-        return authDomain;
-    }
-
-    public void setAuthDomain(String authDomain) {
-        this.authDomain = authDomain;
-    }
-
-    public String getAuthHost() {
-        return authHost;
-    }
-
-    public void setAuthHost(String authHost) {
-        this.authHost = authHost;
-    }
-
-    public String getProxyAuthUsername() {
-        return proxyAuthUsername;
-    }
-
-    public void setProxyAuthUsername(String proxyAuthUsername) {
-        this.proxyAuthUsername = proxyAuthUsername;
-    }
-
-    public String getProxyAuthPassword() {
-        return proxyAuthPassword;
-    }
-
-    public void setProxyAuthPassword(String proxyAuthPassword) {
-        this.proxyAuthPassword = proxyAuthPassword;
-    }
-
-    public String getProxyAuthDomain() {
-        return proxyAuthDomain;
-    }
-
-    public void setProxyAuthDomain(String proxyAuthDomain) {
-        this.proxyAuthDomain = proxyAuthDomain;
-    }
-
-    public String getProxyAuthHost() {
-        return proxyAuthHost;
-    }
-
-    public void setProxyAuthHost(String proxyAuthHost) {
-        this.proxyAuthHost = proxyAuthHost;
-    }
-
-    public AuthMethod getAuthMethod() {
-        return authMethod;
-    }
-
-    public void setAuthMethod(AuthMethod authMethod) {
-        this.authMethod = authMethod;
-    }
-
-    public AuthMethod getProxyAuthMethod() {
-        return proxyAuthMethod;
-    }
-
-    public void setProxyAuthMethod(AuthMethod proxyAuthMethod) {
-        this.proxyAuthMethod = proxyAuthMethod;
-    }
-
-    public String getProxyHost() {
-        return proxyHost;
-    }
-
-    public void setProxyHost(String proxyHost) {
-        this.proxyHost = proxyHost;
-    }
-
-    public int getProxyPort() {
-        return proxyPort;
-    }
-
-    public void setProxyPort(int proxyPort) {
-        this.proxyPort = proxyPort;
-    }
-
-    public String getAuthMethodPriority() {
-        return authMethodPriority;
-    }
-
-    public void setAuthMethodPriority(String authMethodPriority) {
-        this.authMethodPriority = authMethodPriority;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java
deleted file mode 100644
index d2fab26..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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;
-
-/**
- * @version 
- */
-public final class HttpConstants {
-
-    public static final String CONTENT_TYPE_JAVA_SERIALIZED_OBJECT = "application/x-java-serialized-object";
-    public static final String CONTENT_TYPE_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
-
-    private HttpConstants() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java
deleted file mode 100644
index 6d1d7d1..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * 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.Processor;
-import org.apache.camel.SuspendableService;
-import org.apache.camel.impl.DefaultConsumer;
-
-/**
- * @version 
- */
-public class HttpConsumer extends DefaultConsumer implements SuspendableService {
-    private volatile boolean suspended;
-    private boolean traceEnabled;
-
-    public HttpConsumer(HttpEndpoint endpoint, Processor processor) {
-        super(endpoint, processor);
-        if (endpoint.isTraceEnabled()) {
-            setTraceEnabled(true);
-        }
-    }
-
-    @Override
-    public HttpEndpoint getEndpoint() {
-        return (HttpEndpoint)super.getEndpoint();
-    }
-
-    public HttpBinding getBinding() {
-        return getEndpoint().getBinding();
-    }
-
-    public String getPath() {
-        return getEndpoint().getPath();
-    }
-
-    @Override
-    protected void doStart() throws Exception {
-        super.doStart();
-        getEndpoint().connect(this);
-        suspended = false;
-    }
-
-    @Override
-    protected void doStop() throws Exception {
-        suspended = false;
-        getEndpoint().disconnect(this);
-        super.doStop();
-    }
-
-    public void suspend() {
-        suspended = true;
-    }
-
-    public void resume() {
-        suspended = false;
-    }
-
-    public boolean isSuspended() {
-        return suspended;
-    }
-
-    public boolean isTraceEnabled() {
-        return this.traceEnabled;
-    }
-
-    public void setTraceEnabled(boolean traceEnabled) {
-        this.traceEnabled = traceEnabled;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
deleted file mode 100644
index 2b7138d..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * 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.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.camel.Converter;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.util.GZIPHelper;
-
-/**
- * Some converter methods making it easy to convert the body of a message to servlet types or to switch between
- * the underlying {@link ServletInputStream} or {@link BufferedReader} payloads etc.
- *
- * @version 
- */
-@Converter
-public final class HttpConverter {
-
-    private HttpConverter() {
-    }
-
-    @Converter
-    public static HttpServletRequest toServletRequest(Message message) {
-        if (message == null) {
-            return null;
-        }
-        return message.getHeader(Exchange.HTTP_SERVLET_REQUEST, HttpServletRequest.class);
-    }
-
-    @Converter
-    public static HttpServletResponse toServletResponse(Message message) {
-        if (message == null) {
-            return null;
-        }
-        return message.getHeader(Exchange.HTTP_SERVLET_RESPONSE, HttpServletResponse.class);
-    }
-
-    @Converter
-    public static ServletInputStream toServletInputStream(HttpMessage message) throws IOException {
-        HttpServletRequest request = toServletRequest(message);
-        if (request != null) {
-            return request.getInputStream();
-        }
-        return null;
-    }
-
-    @Converter
-    public static InputStream toInputStream(HttpMessage message, Exchange exchange) throws Exception {
-        return toInputStream(toServletRequest(message), exchange);
-    }
-
-    @Converter
-    public static BufferedReader toReader(HttpMessage message) throws IOException {
-        HttpServletRequest request = toServletRequest(message);
-        if (request != null) {
-            return request.getReader();
-        }
-        return null;
-    }
-
-    @Converter
-    public static InputStream toInputStream(HttpServletRequest request, Exchange exchange) throws IOException {
-        if (request == null) {
-            return null;
-        }
-        InputStream is = request.getInputStream();
-        if (is != null && is.available() <= 0) {
-            // there is no data, so we cannot uncompress etc.
-            return is;
-        }
-        if (exchange == null || !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
-            String contentEncoding = request.getHeader(Exchange.CONTENT_ENCODING);
-            return GZIPHelper.uncompressGzip(contentEncoding, is);
-        } else {
-            return is;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f685f361/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
index 23b1a20..98df503 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
@@ -26,6 +26,7 @@ import org.apache.camel.Consumer;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.http.common.HttpCommonEndpoint;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.httpclient.HttpClient;
@@ -70,7 +71,6 @@ public class HttpEndpoint extends HttpCommonEndpoint {
     public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, HttpClientParams clientParams,
                         HttpConnectionManager httpConnectionManager, HttpClientConfigurer clientConfigurer) throws URISyntaxException {
         super(endPointURI, component, httpURI);
-        this.component = component;
         this.clientParams = clientParams;
         this.httpClientConfigurer = clientConfigurer;
         this.httpConnectionManager = httpConnectionManager;
@@ -108,20 +108,20 @@ public class HttpEndpoint extends HttpCommonEndpoint {
             answer.getHostConfiguration().setProxy(host, port);
         }
 
-        if (proxyHost != null) {
-            LOG.debug("Using proxy: {}:{}", proxyHost, proxyPort);
-            answer.getHostConfiguration().setProxy(proxyHost, proxyPort);
+        if (getProxyHost() != null) {
+            LOG.debug("Using proxy: {}:{}", getProxyHost(), getProxyPort());
+            answer.getHostConfiguration().setProxy(getProxyHost(), getProxyPort());
         }
 
-        if (authMethodPriority != null) {
+        if (getAuthMethodPriority() != null) {
             List<String> authPrefs = new ArrayList<String>();
-            Iterator<?> it = getCamelContext().getTypeConverter().convertTo(Iterator.class, authMethodPriority);
+            Iterator<?> it = getCamelContext().getTypeConverter().convertTo(Iterator.class, getAuthMethodPriority());
             int i = 1;
             while (it.hasNext()) {
                 Object value = it.next();
                 AuthMethod auth = getCamelContext().getTypeConverter().convertTo(AuthMethod.class, value);
                 if (auth == null) {
-                    throw new IllegalArgumentException("Unknown authMethod: " + value + " in authMethodPriority: " + authMethodPriority);
+                    throw new IllegalArgumentException("Unknown authMethod: " + value + " in authMethodPriority: " + getAuthMethodPriority());
                 }
                 LOG.debug("Using authSchemePriority #{}: {}", i, auth);
                 authPrefs.add(auth.name());


[13/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 5480449308fb3effec52469c2fc43dd42671fd5e
Parents: 4ed9b0d
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 11:17:32 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:33 2015 +0200

----------------------------------------------------------------------
 components/camel-jetty8/pom.xml                 | 305 ++++++++++---------
 .../component/jetty8/JettyHttpEndpoint8.java    |   2 +-
 components/camel-jetty9/pom.xml                 | 262 ++++++++--------
 .../component/jetty9/AttachmentHttpBinding.java |   4 +-
 .../component/jetty9/JettyHttpEndpoint9.java    |   4 +-
 .../camel/component/jetty/BaseJettyTest.java    |   4 +-
 .../component/jetty/CustomFiltersTest.java      |   1 -
 .../camel/component/jetty/HandlerTest.java      |   2 -
 .../jetty/HttpAuthMethodPriorityTest.java       |   2 +-
 .../HttpBasicAuthComponentConfiguredTest.java   |   5 +-
 .../component/jetty/HttpBasicAuthTest.java      |   3 +-
 .../component/jetty/HttpBindingRefTest.java     |  12 +-
 .../component/jetty/HttpConverterTest.java      |   4 +-
 .../HttpOperationsFailedExceptionUriTest.java   |   2 +-
 .../jetty/HttpRedirectNoLocationTest.java       |   2 +-
 .../camel/component/jetty/HttpRedirectTest.java |   2 +-
 .../jetty/HttpRequestResponseTest.java          |   2 +-
 .../component/jetty/HttpReturnFaultTest.java    |   2 +-
 .../jetty/HttpRoundtripHeaderTest.java          |   1 -
 .../camel/component/jetty/HttpRouteTest.java    |   2 +-
 .../jetty/HttpStreamCacheFileTest.java          |   2 +-
 ...ttpsRouteWithSslConnectorPropertiesTest.java |   2 -
 .../component/jetty/JettyHandle404Test.java     |   3 +-
 .../jetty/JettyHttpBindingRefTest.java          |   2 +-
 .../jetty/JettyHttpClientOptionsTest.java       |   8 +-
 .../jetty/JettyHttpContentTypeTest.java         |   1 -
 .../jetty/JettyHttpGetWithParamTest.java        |   2 +-
 .../jetty/JettyResponseBodyWhenErrorTest.java   |   2 +-
 .../JettyRouteWithSocketPropertiesTest.java     |   1 -
 .../component/jetty/JettySuspendResumeTest.java |   4 +-
 .../camel/component/jetty/JettySuspendTest.java |   4 +-
 .../jetty/JettySuspendWhileInProgressTest.java  |   2 +-
 .../component/jetty/MultiPartFormTest.java      |   1 -
 .../MultiPartFormWithCustomFilterTest.java      |   1 -
 .../camel/component/jetty/MyErrorHandler.java   |   1 -
 .../camel/component/jetty/MyUrlRewrite.java     |   2 +-
 .../JettyAsyncContinuationTimeoutTest.java      |   2 +-
 ...ettyAsyncDefaultContinuationTimeoutTest.java |   2 +-
 .../jetty/javabody/HttpJavaBodyTest.java        |   2 +-
 .../JettyHttpProderReturnFaultTest.java         |   2 +-
 .../JettyHttpProducerGetWithParamTest.java      |   2 +-
 .../JettyHttpProducerJavaBodyTest.java          |   2 +-
 .../JettyHttpProducerRedirectTest.java          |   2 +-
 .../JettyHttpProducerSimulate404ErrorTest.java  |   2 +-
 .../JettyHttpProducerSuspendResumeTest.java     |   4 +-
 .../JettyHttpProducerSuspendTest.java           |   4 +-
 ...yHttpProducerSuspendWhileInProgressTest.java |   2 +-
 .../jetty/proxy/HttpClientProxyTest.java        |   2 +-
 48 files changed, 342 insertions(+), 347 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty8/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-jetty8/pom.xml b/components/camel-jetty8/pom.xml
index e6e04ef..7128f65 100644
--- a/components/camel-jetty8/pom.xml
+++ b/components/camel-jetty8/pom.xml
@@ -15,161 +15,168 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
 
-    <parent>
-        <groupId>org.apache.camel</groupId>
-        <artifactId>components</artifactId>
-        <version>2.16-SNAPSHOT</version>
-    </parent>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.16-SNAPSHOT</version>
+  </parent>
 
-    <artifactId>camel-jetty8</artifactId>
-    <packaging>bundle</packaging>
-    <name>Camel :: Jetty8</name>
-    <description>Camel Jetty8 support</description>
+  <artifactId>camel-jetty8</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: Jetty8</name>
+  <description>Camel Jetty8 support</description>
 
-    <properties>
-        <camel.osgi.import.before.defaults>
-            javax.servlet.*;version="${servlet-version-range}"
-        </camel.osgi.import.before.defaults>
-        <camel.osgi.export.pkg>org.apache.camel.component.jetty8</camel.osgi.export.pkg>
-        <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=jetty</camel.osgi.export.service>
-    </properties>
+  <properties>
+    <camel.osgi.import.before.defaults>
+      javax.servlet.*;version="${servlet-version-range}"
+    </camel.osgi.import.before.defaults>
+    <camel.osgi.export.pkg>org.apache.camel.component.jetty8</camel.osgi.export.pkg>
+    <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=jetty</camel.osgi.export.service>
+  </properties>
 
-    <dependencies>
+  <dependencies>
 
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-http</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-jetty-common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-servlet_3.0_spec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-server</artifactId>
-            <version>${jetty8-version}</version>
-            <exclusions>
-               <exclusion>
-                   <groupId>javax.servlet</groupId>
-                   <artifactId>servlet-api</artifactId>
-               </exclusion>
-               <exclusion>
-                   <groupId>org.eclipse.jetty.orbit</groupId>
-                   <artifactId>javax.servlet</artifactId>
-               </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-servlet</artifactId>
-            <version>${jetty8-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-security</artifactId>
-            <version>${jetty8-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-servlets</artifactId>
-            <version>${jetty8-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-client</artifactId>
-            <version>${jetty8-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-jmx</artifactId>
-            <version>${jetty8-version}</version>
-        </dependency>
-        
-        <!-- test dependencies -->
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-spring</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-spring</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-test</artifactId>
-            <optional>true</optional>
-            <scope>test</scope>
-        </dependency>
-        <!-- for testing rest-dsl -->
-        <dependency>
-          <groupId>org.apache.camel</groupId>
-          <artifactId>camel-jackson</artifactId>
-          <scope>test</scope>
-        </dependency>
-        <dependency>
-          <groupId>org.apache.camel</groupId>
-          <artifactId>camel-jaxb</artifactId>
-          <scope>test</scope>
-        </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jetty-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-servlet_3.0_spec</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-server</artifactId>
+      <version>${jetty8-version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.servlet</groupId>
+          <artifactId>servlet-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.eclipse.jetty.orbit</groupId>
+          <artifactId>javax.servlet</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+      <version>${jetty8-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-security</artifactId>
+      <version>${jetty8-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlets</artifactId>
+      <version>${jetty8-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-client</artifactId>
+      <version>${jetty8-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-jmx</artifactId>
+      <version>${jetty8-version}</version>
+    </dependency>
 
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-test</artifactId>
+      <optional>true</optional>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <!-- for testing rest-dsl -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jackson</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jaxb</artifactId>
+      <scope>test</scope>
+    </dependency>
 
-    <build>
-    	<testSourceDirectory>target/generated/src/test/java</testSourceDirectory>
-        <plugins>
-            
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-antrun-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>generate-test-sources</id>
-                        <phase>generate-test-sources</phase>
-                        <configuration>
-                            <target>
-                                <copy todir="target/generated/src/test/java">
-                                    <fileset dir="../camel-jetty9/src/test/java" />
-                                </copy>                            </target>
-                        </configuration>
-                        <goals>
-                            <goal>run</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <!-- use per test fork mode to avoid side effects -->
-            <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-          	    <forkCount>1</forkCount>
-                <reuseForks>false</reuseForks>
-                <forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <testSourceDirectory>target/generated/src/test/java</testSourceDirectory>
+    <plugins>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-test-sources</id>
+            <phase>generate-test-sources</phase>
+            <configuration>
+              <target>
+                <copy todir="target/generated/src/test/java">
+                  <fileset dir="../camel-jetty9/src/test/java"/>
+                </copy>
+              </target>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- use per test fork mode to avoid side effects -->
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkCount>1</forkCount>
+          <reuseForks>false</reuseForks>
+          <forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty8/src/main/java/org/apache/camel/component/jetty8/JettyHttpEndpoint8.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty8/src/main/java/org/apache/camel/component/jetty8/JettyHttpEndpoint8.java b/components/camel-jetty8/src/main/java/org/apache/camel/component/jetty8/JettyHttpEndpoint8.java
index 2efd975..59f8637 100644
--- a/components/camel-jetty8/src/main/java/org/apache/camel/component/jetty8/JettyHttpEndpoint8.java
+++ b/components/camel-jetty8/src/main/java/org/apache/camel/component/jetty8/JettyHttpEndpoint8.java
@@ -19,10 +19,10 @@ package org.apache.camel.component.jetty8;
 import java.net.URI;
 import java.net.URISyntaxException;
 
-import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.jetty.JettyContentExchange;
 import org.apache.camel.component.jetty.JettyHttpComponent;
 import org.apache.camel.component.jetty.JettyHttpEndpoint;
+import org.apache.camel.http.common.HttpConsumer;
 import org.apache.camel.spi.UriEndpoint;
 
 @UriEndpoint(scheme = "jetty", extendsScheme = "http", title = "Jetty",

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/pom.xml b/components/camel-jetty9/pom.xml
index 6985708..426b8e5 100644
--- a/components/camel-jetty9/pom.xml
+++ b/components/camel-jetty9/pom.xml
@@ -15,141 +15,147 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
 
-    <parent>
-        <groupId>org.apache.camel</groupId>
-        <artifactId>components</artifactId>
-        <version>2.16-SNAPSHOT</version>
-    </parent>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.16-SNAPSHOT</version>
+  </parent>
 
-    <artifactId>camel-jetty9</artifactId>
-    <packaging>bundle</packaging>
-    <name>Camel :: Jetty</name>
-    <description>Camel Jetty support</description>
+  <artifactId>camel-jetty9</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: Jetty</name>
+  <description>Camel Jetty support</description>
 
-    <properties>
-        <camel.osgi.import.before.defaults>
-            javax.servlet.*;version="${servlet-version-range}"
-        </camel.osgi.import.before.defaults>
-        <camel.osgi.export.pkg>org.apache.camel.component.jetty9</camel.osgi.export.pkg>
-        <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=jetty</camel.osgi.export.service>
-        <jetty-version>${jetty9-version}</jetty-version>
-    </properties>
+  <properties>
+    <camel.osgi.import.before.defaults>
+      javax.servlet.*;version="${servlet-version-range}"
+    </camel.osgi.import.before.defaults>
+    <camel.osgi.export.pkg>org.apache.camel.component.jetty9</camel.osgi.export.pkg>
+    <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=jetty</camel.osgi.export.service>
+    <jetty-version>${jetty9-version}</jetty-version>
+  </properties>
 
-    <dependencies>
+  <dependencies>
 
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-http</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-jetty-common</artifactId> 
-        </dependency>
-        <dependency>        
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-servlet_3.0_spec</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-server</artifactId>
-            <version>${jetty9-version}</version>
-            <exclusions>
-               <exclusion>
-                   <groupId>javax.servlet</groupId>
-                   <artifactId>servlet-api</artifactId>
-               </exclusion>
-               <exclusion>
-                   <groupId>org.eclipse.jetty.orbit</groupId>
-                   <artifactId>javax.servlet</artifactId>
-               </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-servlet</artifactId>
-            <version>${jetty9-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-security</artifactId>
-            <version>${jetty9-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-servlets</artifactId>
-            <version>${jetty9-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-client</artifactId>
-            <version>${jetty9-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-jmx</artifactId>
-            <version>${jetty9-version}</version>
-        </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jetty-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-servlet_3.0_spec</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-server</artifactId>
+      <version>${jetty9-version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.servlet</groupId>
+          <artifactId>servlet-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.eclipse.jetty.orbit</groupId>
+          <artifactId>javax.servlet</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlet</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-security</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-servlets</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-client</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-jmx</artifactId>
+      <version>${jetty9-version}</version>
+    </dependency>
 
-        <!-- test dependencies -->
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-spring</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-spring</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-test</artifactId>
-            <optional>true</optional>
-            <scope>test</scope>
-        </dependency>
-        <!-- for testing rest-dsl -->
-        <dependency>
-          <groupId>org.apache.camel</groupId>
-          <artifactId>camel-jackson</artifactId>
-          <scope>test</scope>
-        </dependency>
-        <dependency>
-          <groupId>org.apache.camel</groupId>
-          <artifactId>camel-jaxb</artifactId>
-          <scope>test</scope>
-        </dependency>
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-test</artifactId>
+      <optional>true</optional>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <!-- for testing rest-dsl -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jackson</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jaxb</artifactId>
+      <scope>test</scope>
+    </dependency>
 
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
 
-    <build>
-        <plugins>
-            <!-- use per test fork mode to avoid side effects -->
-            <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-          	    <forkCount>1</forkCount>
-	  	    <reuseForks>false</reuseForks>
-                    <forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+  <build>
+    <plugins>
+      <!-- use per test fork mode to avoid side effects -->
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkCount>1</forkCount>
+          <reuseForks>false</reuseForks>
+          <forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/AttachmentHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/AttachmentHttpBinding.java b/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/AttachmentHttpBinding.java
index a7d8167..f798714 100644
--- a/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/AttachmentHttpBinding.java
+++ b/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/AttachmentHttpBinding.java
@@ -26,8 +26,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.Part;
 
 import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.http.DefaultHttpBinding;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.http.common.DefaultHttpBinding;
+import org.apache.camel.http.common.HttpMessage;
 import org.eclipse.jetty.util.MultiPartInputStreamParser;
 
 final class AttachmentHttpBinding extends DefaultHttpBinding {

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java b/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
index 342353e..724a736 100644
--- a/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
+++ b/components/camel-jetty9/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
@@ -19,11 +19,11 @@ package org.apache.camel.component.jetty9;
 import java.net.URI;
 import java.net.URISyntaxException;
 
-import org.apache.camel.component.http.HttpBinding;
-import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.jetty.JettyContentExchange;
 import org.apache.camel.component.jetty.JettyHttpComponent;
 import org.apache.camel.component.jetty.JettyHttpEndpoint;
+import org.apache.camel.http.common.HttpBinding;
+import org.apache.camel.http.common.HttpConsumer;
 import org.apache.camel.spi.UriEndpoint;
 
 @UriEndpoint(scheme = "jetty", extendsScheme = "http", title = "Jetty 9",

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
index aeb196f..b4ea46b 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
@@ -20,9 +20,9 @@ import java.util.Properties;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.component.http.DefaultHttpBinding;
-import org.apache.camel.component.http.HttpHeaderFilterStrategy;
 import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.http.common.DefaultHttpBinding;
+import org.apache.camel.http.common.HttpHeaderFilterStrategy;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java
index 463151b..c60eaa9 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/CustomFiltersTest.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.jetty;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HandlerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HandlerTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HandlerTest.java
index 7ff661f..48d5198 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HandlerTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HandlerTest.java
@@ -25,9 +25,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.util.IOHelper;
-
 import org.eclipse.jetty.server.handler.StatisticsHandler;
-
 import org.junit.Test;
 
 public class HandlerTest extends BaseJettyTest {

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAuthMethodPriorityTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAuthMethodPriorityTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAuthMethodPriorityTest.java
index ec1a616..713e786 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAuthMethodPriorityTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpAuthMethodPriorityTest.java
@@ -26,7 +26,7 @@ import org.apache.camel.FailedToCreateProducerException;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.impl.JndiRegistry;
 import org.eclipse.jetty.security.ConstraintMapping;
 import org.eclipse.jetty.security.ConstraintSecurityHandler;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
index 18fccfc..524d82e 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthComponentConfiguredTest.java
@@ -24,9 +24,8 @@ import javax.servlet.http.HttpServletRequest;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.AuthMethod;
 import org.apache.camel.component.http.HttpComponent;
-import org.apache.camel.component.http.HttpConfiguration;
+import org.apache.camel.http.common.HttpConfiguration;
 import org.apache.camel.impl.JndiRegistry;
 import org.eclipse.jetty.security.ConstraintMapping;
 import org.eclipse.jetty.security.ConstraintSecurityHandler;
@@ -82,7 +81,7 @@ public class HttpBasicAuthComponentConfiguredTest extends BaseJettyTest {
             @Override
             public void configure() throws Exception {
                 HttpConfiguration config = new HttpConfiguration();
-                config.setAuthMethod(AuthMethod.Basic);
+                config.setAuthMethod("Basic");
                 config.setAuthUsername("donald");
                 config.setAuthPassword("duck");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java
index 2aebd95..c51cc97 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBasicAuthTest.java
@@ -19,14 +19,13 @@ package org.apache.camel.component.jetty;
 import java.io.IOException;
 import java.security.Principal;
 import java.util.Arrays;
-
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.impl.JndiRegistry;
 import org.eclipse.jetty.security.ConstraintMapping;
 import org.eclipse.jetty.security.ConstraintSecurityHandler;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingRefTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingRefTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingRefTest.java
index 22aa8ea..d44d8f8 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingRefTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingRefTest.java
@@ -22,8 +22,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.DefaultHttpBinding;
-import org.apache.camel.component.http.HttpEndpoint;
+import org.apache.camel.http.common.DefaultHttpBinding;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
@@ -47,9 +46,8 @@ public class HttpBindingRefTest extends BaseJettyTest {
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
-        HttpEndpoint ep = new HttpEndpoint();
-        jndi.bind("default", new DefaultHttpBinding(ep));
-        jndi.bind("myownbinder", new MyHttpBinding(ep));
+        jndi.bind("default", new DefaultHttpBinding());
+        jndi.bind("myownbinder", new MyHttpBinding());
         return jndi;
     }
 
@@ -73,9 +71,7 @@ public class HttpBindingRefTest extends BaseJettyTest {
 
     // START SNIPPET: e1
     public class MyHttpBinding extends DefaultHttpBinding {
-        public MyHttpBinding(HttpEndpoint ep) {
-            super(ep);
-        }
+
         @Override
         public void doWriteExceptionResponse(Throwable exception, HttpServletResponse response) throws IOException {
             // we override the doWriteExceptionResponse as we only want to alter the binding how exceptions is

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java
index eef0641..e62433b 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpConverterTest.java
@@ -24,8 +24,8 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConverter;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.http.common.HttpConverter;
+import org.apache.camel.http.common.HttpMessage;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpOperationsFailedExceptionUriTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpOperationsFailedExceptionUriTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpOperationsFailedExceptionUriTest.java
index cc48438..c74aa9c 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpOperationsFailedExceptionUriTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpOperationsFailedExceptionUriTest.java
@@ -20,7 +20,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectNoLocationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectNoLocationTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectNoLocationTest.java
index b37b448..c556e8c 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectNoLocationTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectNoLocationTest.java
@@ -20,7 +20,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java
index cd26dae..c0f206c 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRedirectTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRequestResponseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRequestResponseTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRequestResponseTest.java
index 7c962c2..1d79f76 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRequestResponseTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRequestResponseTest.java
@@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.http.common.HttpMessage;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
index 86f2e85..cb53690 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpReturnFaultTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jetty;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java
index 16a9201..c125bc6 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRoundtripHeaderTest.java
@@ -30,7 +30,6 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultHeaderFilterStrategy;
 import org.apache.camel.util.IOHelper;
-
 import org.junit.Test;
 
 public class HttpRoundtripHeaderTest extends BaseJettyTest {

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
index b21455d..e28989c 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpRouteTest.java
@@ -29,9 +29,9 @@ 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.http.HttpMessage;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.stream.InputStreamCache;
+import org.apache.camel.http.common.HttpMessage;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.httpclient.methods.GetMethod;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java
index 3c63f6a..76c9de5 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpStreamCacheFileTest.java
@@ -22,8 +22,8 @@ import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.converter.stream.CachedOutputStream;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.util.ObjectHelper;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
index b85bd61..6c11866 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
@@ -18,8 +18,6 @@ package org.apache.camel.component.jetty;
 
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHandle404Test.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHandle404Test.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHandle404Test.java
index 12282de..7c5740c 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHandle404Test.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHandle404Test.java
@@ -16,12 +16,11 @@
  */
 package org.apache.camel.component.jetty;
 
-import org.apache.camel.Component;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java
index 54e6989..5d6151b 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpBindingRefTest.java
@@ -23,7 +23,7 @@ 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.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
index 387cdeb..5fc2d6f 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
@@ -17,8 +17,8 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpEndpoint;
 import org.apache.camel.component.http.HttpProducer;
+import org.apache.camel.http.common.HttpCommonEndpoint;
 import org.eclipse.jetty.client.HttpClient;
 import org.junit.Test;
 
@@ -30,7 +30,7 @@ public class JettyHttpClientOptionsTest extends BaseJettyTest {
     @Test
     public void testCustomHttpBinding() throws Exception {
         // assert jetty was configured with our timeout
-        HttpEndpoint jettyEndpoint = context.getEndpoint("http://localhost:{{port}}/myapp/myservice?httpClient.soTimeout=5555", HttpEndpoint.class);
+        HttpCommonEndpoint jettyEndpoint = context.getEndpoint("http://localhost:{{port}}/myapp/myservice?httpClient.soTimeout=5555", HttpCommonEndpoint.class);
         assertNotNull("Jetty endpoint should not be null ", jettyEndpoint);
         HttpProducer producer = (HttpProducer)jettyEndpoint.createProducer();
         assertEquals("Get the wrong http client parameter", 5555, producer.getHttpClient().getParams().getSoTimeout());
@@ -43,7 +43,7 @@ public class JettyHttpClientOptionsTest extends BaseJettyTest {
     @Test
     public void testProxySettingOfJettyHttpClient() throws Exception {
         // setup the Proxy setting through the URI
-        HttpEndpoint jettyEndpoint = context.getEndpoint("jetty://http://localhost:{{port}}/proxy/setting?proxyHost=192.168.0.1&proxyPort=9090", HttpEndpoint.class);
+        HttpCommonEndpoint jettyEndpoint = context.getEndpoint("jetty://http://localhost:{{port}}/proxy/setting?proxyHost=192.168.0.1&proxyPort=9090", HttpCommonEndpoint.class);
         assertNotNull("Jetty endpoint should not be null ", jettyEndpoint);
         JettyHttpProducer producer = (JettyHttpProducer)jettyEndpoint.createProducer();
         assertProxyAddress(producer.getClient(), "192.168.0.1", 9090);
@@ -51,7 +51,7 @@ public class JettyHttpClientOptionsTest extends BaseJettyTest {
         // setup the context properties
         context.getProperties().put("http.proxyHost", "192.168.0.2");
         context.getProperties().put("http.proxyPort", "8080");
-        jettyEndpoint = context.getEndpoint("jetty://http://localhost:{{port}}/proxy2/setting", HttpEndpoint.class);
+        jettyEndpoint = context.getEndpoint("jetty://http://localhost:{{port}}/proxy2/setting", HttpCommonEndpoint.class);
         producer = (JettyHttpProducer)jettyEndpoint.createProducer();
         assertProxyAddress(producer.getClient(), "192.168.0.2", 8080);
         context.getProperties().clear();

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java
index f03afac..45fe7e5 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpContentTypeTest.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.jetty;
 import java.nio.charset.Charset;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpGetWithParamTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpGetWithParamTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpGetWithParamTest.java
index c2aeecb..eb9d9c1 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpGetWithParamTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyHttpGetWithParamTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.jetty;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpMessage;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.http.common.HttpMessage;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
index 1fec3a6..97be71a 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
@@ -20,7 +20,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyRouteWithSocketPropertiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyRouteWithSocketPropertiesTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyRouteWithSocketPropertiesTest.java
index 86ef152..67d5212 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyRouteWithSocketPropertiesTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettyRouteWithSocketPropertiesTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.jetty;
 
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.camel.Exchange;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java
index 31e05cc..5a2015d 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendResumeTest.java
@@ -17,8 +17,8 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java
index 3935c71..df74096 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendTest.java
@@ -17,8 +17,8 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java
index cacbe95..3170962 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/JettySuspendWhileInProgressTest.java
@@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
index 7c81101..6b3e87f 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
@@ -17,7 +17,6 @@
 package org.apache.camel.component.jetty;
 
 import java.io.File;
-
 import javax.activation.DataHandler;
 
 import org.apache.camel.Exchange;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
index 846f8df..eef3b20 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MultiPartFormWithCustomFilterTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.jetty;
 
 import java.io.File;
 import java.io.IOException;
-
 import javax.activation.DataHandler;
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java
index 917ae35..a85936e 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyErrorHandler.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.jetty;
 
 import java.io.IOException;
 import java.io.Writer;
-
 import javax.servlet.http.HttpServletRequest;
 
 import org.eclipse.jetty.server.handler.ErrorHandler;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
index 8ca31d4..4fe26b4 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/MyUrlRewrite.java
@@ -17,7 +17,7 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.Producer;
-import org.apache.camel.component.http.UrlRewrite;
+import org.apache.camel.http.common.UrlRewrite;
 
 /**
  *

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java
index 91c7535..3ae3aff 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncContinuationTimeoutTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.jetty.async;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.util.StopWatch;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java
index c85d716..d608ce5 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/async/JettyAsyncDefaultContinuationTimeoutTest.java
@@ -20,8 +20,8 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.util.StopWatch;
 import org.junit.Ignore;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java
index b55d938..9d9ca1b 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.jetty.javabody;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConstants;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpConstants;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java
index 628cd5b..21d83bb 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProderReturnFaultTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.jetty.jettyproducer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerGetWithParamTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerGetWithParamTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerGetWithParamTest.java
index cc421c9..712ea29 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerGetWithParamTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerGetWithParamTest.java
@@ -19,9 +19,9 @@ package org.apache.camel.component.jetty.jettyproducer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpMessage;
 import org.apache.camel.component.jetty.BaseJettyTest;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.http.common.HttpMessage;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerJavaBodyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerJavaBodyTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerJavaBodyTest.java
index 9f17c31..6fa1c39 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerJavaBodyTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerJavaBodyTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.jetty.jettyproducer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConstants;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpConstants;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java
index 0c8379b..f70a927 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerRedirectTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java
index bdda6df..9ce8b65 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSimulate404ErrorTest.java
@@ -19,8 +19,8 @@ package org.apache.camel.component.jetty.jettyproducer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendResumeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendResumeTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendResumeTest.java
index 0aa9e44..6be606d 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendResumeTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendResumeTest.java
@@ -17,9 +17,9 @@
 package org.apache.camel.component.jetty.jettyproducer;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendTest.java
index dc67337..3ae9dda 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendTest.java
@@ -17,9 +17,9 @@
 package org.apache.camel.component.jetty.jettyproducer;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendWhileInProgressTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendWhileInProgressTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendWhileInProgressTest.java
index 3edec66..41e0e04 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendWhileInProgressTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerSuspendWhileInProgressTest.java
@@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Ignore;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/54804493/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/proxy/HttpClientProxyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/proxy/HttpClientProxyTest.java b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/proxy/HttpClientProxyTest.java
index e2e245f..283f865 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/proxy/HttpClientProxyTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/proxy/HttpClientProxyTest.java
@@ -21,8 +21,8 @@ import java.lang.reflect.UndeclaredThrowableException;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.ProxyBuilder;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jetty.BaseJettyTest;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 /**


[23/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 2417f3427eaed3e6157360179c754ab3cd9a5e7d
Parents: 2b89da0
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 14:48:20 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:36 2015 +0200

----------------------------------------------------------------------
 platforms/karaf/features/src/main/resources/features.xml | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2417f342/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index 94cbdf0..b26d74e 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -715,6 +715,7 @@
     <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient/${commons-httpclient-bundle-version}</bundle>
     <bundle dependency='true'>mvn:commons-codec/commons-codec/${commons-codec-version}</bundle>
     <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-servlet_3.0_spec/${geronimo-servlet-spec-version}</bundle>
+    <bundle>mvn:org.apache.camel/camel-http-common/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-http/${project.version}</bundle>
   </feature>
   <feature name='camel-http4' version='${project.version}' resolver='(obr)' start-level='50'>
@@ -722,6 +723,7 @@
     <bundle dependency='true'>mvn:org.apache.httpcomponents/httpcore-osgi/${httpcore4-version}</bundle>
     <bundle dependency='true'>mvn:org.apache.httpcomponents/httpclient-osgi/${httpclient4-version}</bundle>
     <bundle dependency='true'>mvn:org.apache.geronimo.specs/geronimo-servlet_3.0_spec/${geronimo-servlet-spec-version}</bundle>
+    <bundle>mvn:org.apache.camel/camel-http-common/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-http4/${project.version}</bundle>
   </feature>
   <feature name='camel-ibatis' version='${project.version}' resolver='(obr)' start-level='50'>
@@ -797,7 +799,7 @@
   <feature name='camel-jetty' version='${project.version}' resolver='(obr)' start-level='50'>
     <feature>jetty</feature>
     <feature version='${project.version}'>camel-core</feature>
-    <feature version='${project.version}'>camel-http</feature>
+    <bundle>mvn:org.apache.camel/camel-http-common/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-jetty-common/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-jetty8/${project.version}</bundle>
   </feature>
@@ -805,7 +807,7 @@
     <details>camel-jetty9 intend to work with jetty9, so this feature only works in the karaf container which support jetty9, e.g. karaf 4.x</details>
     <feature>jetty</feature>
     <feature version='${project.version}'>camel-core</feature>
-    <feature version='${project.version}'>camel-http</feature>
+    <bundle>mvn:org.apache.camel/camel-http-common/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-jetty-common/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-jetty9/${project.version}</bundle>
   </feature>
@@ -1295,7 +1297,7 @@
   <feature name='camel-servlet' version='${project.version}' resolver='(obr)' start-level='50'>
     <details> camel-servlet need to access the http OSGi services </details>
     <feature>http</feature>
-    <feature version='${project.version}'>camel-http</feature>
+    <bundle>mvn:org.apache.camel/camel-http-common/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-servlet/${project.version}</bundle>
   </feature>
   <feature name='camel-servletlistener' version='${project.version}' resolver='(obr)' start-level='50'>


[16/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 9f3779dddb7cec760ada3f449c6b002592bb8d3e
Parents: 6392719
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 12:05:02 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:34 2015 +0200

----------------------------------------------------------------------
 .../urlrewrite/http4/Http4UrlRewriteLoadBalanceFailoverTest.java  | 3 ++-
 .../http4/Http4UrlRewriteLoadBalanceRoundRobinTest.java           | 3 ++-
 .../component/urlrewrite/http4/Http4UrlRewriteModFileTest.java    | 3 ++-
 .../camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java  | 3 ++-
 .../component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java  | 3 ++-
 .../camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java | 3 ++-
 .../camel/component/urlrewrite/http4/Http4UrlRewriteTest.java     | 3 ++-
 7 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9f3779dd/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceFailoverTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceFailoverTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceFailoverTest.java
index 041245a..db40e03 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceFailoverTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceFailoverTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
@@ -30,7 +31,7 @@ public class Http4UrlRewriteLoadBalanceFailoverTest extends BaseUrlRewriteTest {
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
+        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
         myRewrite.setConfigFile("example/urlrewrite2.xml");
 
         jndi.bind("myRewrite", myRewrite);

http://git-wip-us.apache.org/repos/asf/camel/blob/9f3779dd/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceRoundRobinTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceRoundRobinTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceRoundRobinTest.java
index e82a78c..866ac2f 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceRoundRobinTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteLoadBalanceRoundRobinTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
@@ -30,7 +31,7 @@ public class Http4UrlRewriteLoadBalanceRoundRobinTest extends BaseUrlRewriteTest
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
+        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
         myRewrite.setConfigFile("example/urlrewrite2.xml");
 
         jndi.bind("myRewrite", myRewrite);

http://git-wip-us.apache.org/repos/asf/camel/blob/9f3779dd/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java
index 25fe2a6..83b191d 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModFileTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
@@ -30,7 +31,7 @@ public class Http4UrlRewriteModFileTest extends BaseUrlRewriteTest {
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
+        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
         myRewrite.setModRewriteConfFile("example/modrewrite.cfg");
 
         jndi.bind("myRewrite", myRewrite);

http://git-wip-us.apache.org/repos/asf/camel/blob/9f3779dd/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java
index 9794ed5..ca6dfd8 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteModTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
@@ -31,7 +32,7 @@ public class Http4UrlRewriteModTest extends BaseUrlRewriteTest {
         JndiRegistry jndi = super.createRegistry();
 
         // START SNIPPET: e1
-        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
+        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
         myRewrite.setModRewriteConfText("RewriteRule page/([^/\\.]+)/?$ index.php?page=$1 [L]");
         // END SNIPPET: e1
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9f3779dd/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java
index 6eb2f82..253b090 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingQueryTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
@@ -30,7 +31,7 @@ public class Http4UrlRewritePingQueryTest extends BaseUrlRewriteTest {
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
+        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
         myRewrite.setConfigFile("example/urlrewrite-ping.xml");
         myRewrite.setUseQueryString(true);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9f3779dd/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java
index 7d62395..2e00540 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewritePingTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
@@ -30,7 +31,7 @@ public class Http4UrlRewritePingTest extends BaseUrlRewriteTest {
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
+        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
         myRewrite.setConfigFile("example/urlrewrite-ping.xml");
         myRewrite.setUseQueryString(false);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9f3779dd/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java
index c9c303a..f974040 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewriteTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http4;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
@@ -30,7 +31,7 @@ public class Http4UrlRewriteTest extends BaseUrlRewriteTest {
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry jndi = super.createRegistry();
 
-        Http4UrlRewrite myRewrite = new Http4UrlRewrite();
+        HttpUrlRewrite myRewrite = new HttpUrlRewrite();
         myRewrite.setConfigFile("example/urlrewrite2.xml");
 
         jndi.bind("myRewrite", myRewrite);


[05/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 617b1965e9f84db996e8a1ca2cc47d77e86a09ee
Parents: f685f36
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 10:01:38 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:31 2015 +0200

----------------------------------------------------------------------
 components/camel-servlet/pom.xml                | 49 ++++++++++----------
 .../servlet/CamelHttpTransportServlet.java      |  4 +-
 .../component/servlet/DefaultHttpRegistry.java  |  4 +-
 .../camel/component/servlet/HttpRegistry.java   |  4 +-
 .../component/servlet/ServletComponent.java     | 33 ++++---------
 .../component/servlet/ServletConsumer.java      |  5 +-
 .../component/servlet/ServletEndpoint.java      | 12 ++---
 .../servlet/ServletRestHttpBinding.java         |  4 +-
 ...rvletRestServletResolveConsumerStrategy.java |  6 +--
 .../servlet/ServletTransferExceptionTest.java   |  4 +-
 components/camel-urlrewrite/pom.xml             | 23 +++++----
 .../component/urlrewrite/HttpUrlRewrite.java    | 39 ++++++++++++++++
 .../urlrewrite/http/HttpUrlRewrite.java         | 40 ----------------
 .../urlrewrite/http4/Http4UrlRewrite.java       | 40 ----------------
 .../HttpUrlRewriteLoadBalanceFailoverTest.java  |  1 +
 ...HttpUrlRewriteLoadBalanceRoundRobinTest.java |  1 +
 .../http/HttpUrlRewriteModFileTest.java         |  1 +
 .../urlrewrite/http/HttpUrlRewriteModTest.java  |  1 +
 .../http/HttpUrlRewritePingQueryTest.java       |  1 +
 .../urlrewrite/http/HttpUrlRewritePingTest.java |  1 +
 .../urlrewrite/http/HttpUrlRewriteTest.java     |  1 +
 .../JettyUrlRewriteLoadBalanceFailoverTest.java |  2 +-
 ...ettyUrlRewriteLoadBalanceRoundRobinTest.java |  2 +-
 .../jetty/JettyUrlRewriteModTest.java           |  2 +-
 .../urlrewrite/jetty/JettyUrlRewriteTest.java   |  2 +-
 25 files changed, 114 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-servlet/pom.xml b/components/camel-servlet/pom.xml
index baaa194..680d36a 100644
--- a/components/camel-servlet/pom.xml
+++ b/components/camel-servlet/pom.xml
@@ -15,20 +15,21 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.16-SNAPSHOT</version>
+  </parent>
 
-    <parent>
-        <groupId>org.apache.camel</groupId>
-        <artifactId>components</artifactId>
-        <version>2.16-SNAPSHOT</version>
-    </parent>
-    
   <artifactId>camel-servlet</artifactId>
   <packaging>bundle</packaging>
   <name>Camel :: Servlet</name>
   <description>Camel servlet transport support</description>
-  
+
   <properties>
     <camel.osgi.import.before.defaults>
       javax.servlet.*;version="${servlet-version-range}"
@@ -45,12 +46,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-http</artifactId>
+      <artifactId>camel-http-common</artifactId>
       <exclusions>
-         <exclusion>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-servlet_3.0_spec</artifactId>
-         </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-servlet_3.0_spec</artifactId>
+        </exclusion>
       </exclusions>
     </dependency>
     <dependency>
@@ -89,14 +90,14 @@
       <groupId>httpunit</groupId>
       <artifactId>httpunit</artifactId>
       <exclusions>
-         <exclusion>
-      	   <groupId>javax.servlet</groupId>
-           <artifactId>servlet-api</artifactId>
-         </exclusion>
+        <exclusion>
+          <groupId>javax.servlet</groupId>
+          <artifactId>servlet-api</artifactId>
+        </exclusion>
       </exclusions>
       <scope>test</scope>
     </dependency>
-     <dependency>
+    <dependency>
       <groupId>rhino</groupId>
       <artifactId>js</artifactId>
       <version>${rhino-version}</version>
@@ -119,17 +120,17 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
-  
+
   <build>
     <plugins>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <forkCount>1</forkCount>
-	  <reuseForks>false</reuseForks>
+          <reuseForks>false</reuseForks>
         </configuration>
       </plugin>
-     </plugins>
-   </build>
-    
+    </plugins>
+  </build>
+
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/CamelHttpTransportServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/CamelHttpTransportServlet.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/CamelHttpTransportServlet.java
index 733ea72..67fcc89 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/CamelHttpTransportServlet.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/CamelHttpTransportServlet.java
@@ -19,9 +19,9 @@ package org.apache.camel.component.servlet;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 
-import org.apache.camel.component.http.CamelServlet;
-import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.converter.ObjectConverter;
+import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpConsumer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/DefaultHttpRegistry.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/DefaultHttpRegistry.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/DefaultHttpRegistry.java
index b364710..8827730 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/DefaultHttpRegistry.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/DefaultHttpRegistry.java
@@ -23,8 +23,8 @@ import java.util.Map;
 import java.util.Set;
 import javax.servlet.Servlet;
 
-import org.apache.camel.component.http.CamelServlet;
-import org.apache.camel.component.http.HttpConsumer;
+import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpConsumer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/HttpRegistry.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/HttpRegistry.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/HttpRegistry.java
index 90eb3d6..980949b 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/HttpRegistry.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/HttpRegistry.java
@@ -16,8 +16,8 @@
  */
 package org.apache.camel.component.servlet;
 
-import org.apache.camel.component.http.CamelServlet;
-import org.apache.camel.component.http.HttpConsumer;
+import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpConsumer;
 
 /**
  * Keeps track of HttpConsumers and CamelServlets and 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
index e2eba06..2bbf00f 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
@@ -18,32 +18,24 @@ package org.apache.camel.component.servlet;
 
 import java.net.URI;
 import java.util.HashMap;
-import java.util.LinkedHashSet;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Set;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
-import org.apache.camel.component.http.AuthMethod;
-import org.apache.camel.component.http.HttpBinding;
-import org.apache.camel.component.http.HttpClientConfigurer;
-import org.apache.camel.component.http.HttpComponent;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpEndpoint;
+import org.apache.camel.http.common.HttpBinding;
+import org.apache.camel.http.common.HttpCommonComponent;
+import org.apache.camel.http.common.HttpConsumer;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.RestConfiguration;
 import org.apache.camel.spi.RestConsumerFactory;
 import org.apache.camel.util.FileUtil;
-import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
 
-public class ServletComponent extends HttpComponent implements RestConsumerFactory {
+public class ServletComponent extends HttpCommonComponent implements RestConsumerFactory {
 
     private String servletName = "CamelServlet";
     private HttpRegistry httpRegistry;
@@ -52,20 +44,12 @@ public class ServletComponent extends HttpComponent implements RestConsumerFacto
         super(ServletEndpoint.class);
     }
 
-    public ServletComponent(Class<? extends HttpEndpoint> endpointClass) {
+    public ServletComponent(Class<? extends ServletEndpoint> endpointClass) {
         super(endpointClass);
     }
 
-
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        HttpClientParams params = new HttpClientParams();
-        IntrospectionSupport.setProperties(params, parameters, "httpClient.");
-
-        // create the configurer to use for this endpoint
-        final Set<AuthMethod> authMethods = new LinkedHashSet<AuthMethod>();
-        HttpClientConfigurer configurer = createHttpClientConfigurer(parameters, authMethods);
-
         // must extract well known parameters before we create the endpoint
         Boolean throwExceptionOnFailure = getAndRemoveParameter(parameters, "throwExceptionOnFailure", Boolean.class);
         Boolean transferException = getAndRemoveParameter(parameters, "transferException", Boolean.class);
@@ -84,7 +68,7 @@ public class ServletComponent extends HttpComponent implements RestConsumerFacto
         // restructure uri to be based on the parameters left as we dont want to include the Camel internal options
         URI httpUri = URISupport.createRemainingURI(new URI(UnsafeUriCharactersEncoder.encodeHttpURI(uri)), parameters);
 
-        ServletEndpoint endpoint = createServletEndpoint(uri, this, httpUri, params, getHttpConnectionManager(), configurer);
+        ServletEndpoint endpoint = createServletEndpoint(uri, this, httpUri);
         endpoint.setServletName(servletName);
         if (headerFilterStrategy != null) {
             endpoint.setHeaderFilterStrategy(headerFilterStrategy);
@@ -125,9 +109,8 @@ public class ServletComponent extends HttpComponent implements RestConsumerFacto
     /**
      * Strategy to create the servlet endpoint.
      */
-    protected ServletEndpoint createServletEndpoint(String endpointUri, ServletComponent component, URI httpUri, HttpClientParams params,
-                                                    HttpConnectionManager httpConnectionManager, HttpClientConfigurer clientConfigurer) throws Exception {
-        return new ServletEndpoint(endpointUri, component, httpUri, params, httpConnectionManager, clientConfigurer);
+    protected ServletEndpoint createServletEndpoint(String endpointUri, ServletComponent component, URI httpUri) throws Exception {
+        return new ServletEndpoint(endpointUri, component, httpUri);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletConsumer.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletConsumer.java
index 32950b8..7545bd3 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletConsumer.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletConsumer.java
@@ -17,11 +17,8 @@
 package org.apache.camel.component.servlet;
 
 import org.apache.camel.Processor;
-import org.apache.camel.component.http.HttpConsumer;
+import org.apache.camel.http.common.HttpConsumer;
 
-/**
- *
- */
 public class ServletConsumer extends HttpConsumer {
 
     public ServletConsumer(ServletEndpoint endpoint, Processor processor) {

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
index e9a21aa..1e870da 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
@@ -22,17 +22,14 @@ import java.net.URISyntaxException;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
-import org.apache.camel.component.http.HttpClientConfigurer;
-import org.apache.camel.component.http.HttpEndpoint;
+import org.apache.camel.http.common.HttpCommonEndpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriPath;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
 
 @UriEndpoint(scheme = "servlet", extendsScheme = "http", title = "Servlet",
         syntax = "servlet:servletName", consumerOnly = true, consumerClass = ServletConsumer.class, label = "http")
-public class ServletEndpoint extends HttpEndpoint {
+public class ServletEndpoint extends HttpCommonEndpoint {
 
     @UriPath(label = "consumer") @Metadata(required = "true")
     private String servletName;
@@ -40,9 +37,8 @@ public class ServletEndpoint extends HttpEndpoint {
     public ServletEndpoint() {
     }
 
-    public ServletEndpoint(String endPointURI, ServletComponent component, URI httpUri, HttpClientParams params, HttpConnectionManager httpConnectionManager,
-                           HttpClientConfigurer clientConfigurer) throws URISyntaxException {
-        super(endPointURI, component, httpUri, params, httpConnectionManager, clientConfigurer);
+    public ServletEndpoint(String endPointURI, ServletComponent component, URI httpUri) throws URISyntaxException {
+        super(endPointURI, component, httpUri);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestHttpBinding.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestHttpBinding.java
index add507a..a652fba 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestHttpBinding.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestHttpBinding.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.servlet;
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.camel.component.http.DefaultHttpBinding;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.http.common.DefaultHttpBinding;
+import org.apache.camel.http.common.HttpMessage;
 
 public class ServletRestHttpBinding extends DefaultHttpBinding {
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestServletResolveConsumerStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestServletResolveConsumerStrategy.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestServletResolveConsumerStrategy.java
index 1d5730e..b7df2cd 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestServletResolveConsumerStrategy.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletRestServletResolveConsumerStrategy.java
@@ -23,11 +23,11 @@ import java.util.Locale;
 import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpServletResolveConsumerStrategy;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpServletResolveConsumerStrategy;
 
 /**
- * A {@link org.apache.camel.component.http.HttpServletResolveConsumerStrategy} that supports the Rest DSL.
+ * A {@link org.apache.camel.http.common.HttpServletResolveConsumerStrategy} that supports the Rest DSL.
  */
 public class ServletRestServletResolveConsumerStrategy extends HttpServletResolveConsumerStrategy {
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
index 8cdc67e..62a0f06 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
@@ -23,8 +23,8 @@ import com.meterware.httpunit.WebRequest;
 import com.meterware.httpunit.WebResponse;
 import com.meterware.servletunit.ServletUnitClient;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpConstants;
-import org.apache.camel.component.http.helper.HttpHelper;
+import org.apache.camel.http.common.HttpConstants;
+import org.apache.camel.http.common.HttpHelper;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/pom.xml b/components/camel-urlrewrite/pom.xml
index 804f65f..cb1cbad 100644
--- a/components/camel-urlrewrite/pom.xml
+++ b/components/camel-urlrewrite/pom.xml
@@ -15,7 +15,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
@@ -43,6 +44,10 @@
       <artifactId>camel-core</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http-common</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.tuckey</groupId>
       <artifactId>urlrewritefilter</artifactId>
       <version>${urlrewritefilter-version}</version>
@@ -53,22 +58,20 @@
       <scope>provided</scope>
     </dependency>
 
-    <!-- various Camel component that supports this url rewriter -->
+    <!-- test dependencies -->
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-http</artifactId>
-      <scope>provided</scope>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-http4</artifactId>
-      <scope>provided</scope>
+      <artifactId>camel-http</artifactId>
+      <scope>test</scope>
     </dependency>
-
-    <!-- test dependencies -->
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-test</artifactId>
+      <artifactId>camel-http4</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -95,7 +98,7 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <forkCount>1</forkCount>
-	  <reuseForks>false</reuseForks>
+          <reuseForks>false</reuseForks>
           <forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java b/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java
new file mode 100644
index 0000000..3724526
--- /dev/null
+++ b/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/HttpUrlRewrite.java
@@ -0,0 +1,39 @@
+/**
+ * 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.urlrewrite;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.camel.Producer;
+import org.apache.camel.http.common.HttpServletUrlRewrite;
+
+/**
+ * The camel-http component implementation of the {@link HttpServletUrlRewrite}.
+ */
+public class HttpUrlRewrite extends UrlRewriteFilter implements HttpServletUrlRewrite {
+
+    @Override
+    public String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception {
+        return rewrite(relativeUrl, request);
+    }
+
+    @Override
+    public String rewrite(String url, String relativeUrl, Producer producer) throws Exception {
+        // not in use
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java b/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java
deleted file mode 100644
index 45869d1..0000000
--- a/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewrite.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.urlrewrite.http;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.Producer;
-import org.apache.camel.component.http.HttpServletUrlRewrite;
-import org.apache.camel.component.urlrewrite.UrlRewriteFilter;
-
-/**
- * The camel-http component implementation of the {@link HttpServletUrlRewrite}.
- */
-public class HttpUrlRewrite extends UrlRewriteFilter implements HttpServletUrlRewrite {
-
-    @Override
-    public String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception {
-        return rewrite(relativeUrl, request);
-    }
-
-    @Override
-    public String rewrite(String url, String relativeUrl, Producer producer) throws Exception {
-        // not in use
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java b/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java
deleted file mode 100644
index 6c33b06..0000000
--- a/components/camel-urlrewrite/src/main/java/org/apache/camel/component/urlrewrite/http4/Http4UrlRewrite.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.urlrewrite.http4;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.camel.Producer;
-import org.apache.camel.component.http4.HttpServletUrlRewrite;
-import org.apache.camel.component.urlrewrite.UrlRewriteFilter;
-
-/**
- * The camel-http4 component implementation of the {@link org.apache.camel.component.http.HttpServletUrlRewrite}.
- */
-public class Http4UrlRewrite extends UrlRewriteFilter implements HttpServletUrlRewrite {
-
-    @Override
-    public String rewrite(String url, String relativeUrl, Producer producer, HttpServletRequest request) throws Exception {
-        return rewrite(relativeUrl, request);
-    }
-
-    @Override
-    public String rewrite(String url, String relativeUrl, Producer producer) throws Exception {
-        // not in use
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceFailoverTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceFailoverTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceFailoverTest.java
index c3969e0..f96071e 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceFailoverTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceFailoverTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceRoundRobinTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceRoundRobinTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceRoundRobinTest.java
index eccfc0f..e7be2f1 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceRoundRobinTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteLoadBalanceRoundRobinTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
index 6838a6a..1365418 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModFileTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
index b90e99c..0115197 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteModTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
index e162333..cb65fc6 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingQueryTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
index b113f59..93e10c8 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewritePingTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
index 9d799ba..064c049 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/http/HttpUrlRewriteTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.urlrewrite.http;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceFailoverTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceFailoverTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceFailoverTest.java
index 55513bd..d2e3ba1 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceFailoverTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceFailoverTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.urlrewrite.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.http.HttpUrlRewrite;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceRoundRobinTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceRoundRobinTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceRoundRobinTest.java
index b21216d..30959a2 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceRoundRobinTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteLoadBalanceRoundRobinTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.urlrewrite.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.http.HttpUrlRewrite;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
index 7e2a45e..b00208a 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteModTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.urlrewrite.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.http.HttpUrlRewrite;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/617b1965/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
index e8c90da..efeafaf 100644
--- a/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
+++ b/components/camel-urlrewrite/src/test/java/org/apache/camel/component/urlrewrite/jetty/JettyUrlRewriteTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.urlrewrite.jetty;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.urlrewrite.BaseUrlRewriteTest;
-import org.apache.camel.component.urlrewrite.http.HttpUrlRewrite;
+import org.apache.camel.component.urlrewrite.HttpUrlRewrite;
 import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 


[18/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: f899941ba580b6fd810c161e49e98b672645776e
Parents: 9f3779d
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 13:01:55 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:35 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java | 2 +-
 .../src/test/java/org/apache/camel/itest/http/Http4RouteTest.java  | 2 +-
 .../apache/camel/itest/jetty/JettyJmsShutdownInProgressTest.java   | 2 +-
 ...WithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java | 2 +-
 .../org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f899941b/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java
index 51b5b66..c1e6dac 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpJmsAsyncTimeoutTest.java
@@ -21,8 +21,8 @@ import javax.naming.Context;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
 import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/f899941b/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
index 713e57b..24696af 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.itest.http;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.http.common.HttpMessage;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/f899941b/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsShutdownInProgressTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsShutdownInProgressTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsShutdownInProgressTest.java
index 1dabccf..f664fb2 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsShutdownInProgressTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jetty/JettyJmsShutdownInProgressTest.java
@@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.test.AvailablePortFinder;
 import org.junit.Assert;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/f899941b/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
index 60b95f4..b5871d8 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionAndNoTransactionErrorHandlerConfiguredRoute.java
@@ -19,7 +19,7 @@ package org.apache.camel.itest.tx;
 import org.apache.camel.Exchange;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.test.AvailablePortFinder;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/f899941b/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
index 3335f8c..8e48284 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/JmsToHttpWithOnExceptionRoute.java
@@ -19,7 +19,7 @@ package org.apache.camel.itest.tx;
 import org.apache.camel.Exchange;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.test.AvailablePortFinder;
 
 /**


[11/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 4ed9b0d729b684d07810f1a36ab11773188fefc7
Parents: 6231575
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 10:33:39 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:32 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/http/common/HttpHelper.java    | 26 ++++++++++
 .../apache/camel/http/common/HttpMethods.java   | 23 +++++++++
 .../camel/component/http/HttpProducer.java      |  8 +--
 .../http/helper/HttpMethodsHelper.java          | 52 --------------------
 .../http/helper/HttpMethodsHelperTest.java      | 13 ++---
 components/camel-jetty-common/pom.xml           |  2 +-
 .../jetty/CamelContinuationServlet.java         |  8 +--
 .../jetty/DefaultJettyHttpBinding.java          | 10 ++--
 .../component/jetty/JettyContentExchange.java   |  7 ++-
 .../camel/component/jetty/JettyConverter.java   |  1 +
 .../camel/component/jetty/JettyHttpBinding.java |  6 +--
 .../component/jetty/JettyHttpComponent.java     | 20 ++++----
 .../component/jetty/JettyHttpEndpoint.java      |  7 ++-
 .../component/jetty/JettyHttpProducer.java      | 12 ++---
 .../component/jetty/JettyRestHttpBinding.java   |  8 +--
 ...JettyRestServletResolveConsumerStrategy.java |  6 +--
 16 files changed, 103 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/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 d22ee6b..e7311b0 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
@@ -426,4 +426,30 @@ public final class HttpHelper {
 
         return answer;
     }
+
+    /**
+     * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
+     *
+     * @param exchange  the exchange
+     * @return the created method
+     * @throws URISyntaxException
+     */
+    public static HttpMethods createMethod(Exchange exchange, HttpCommonEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
+        // 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 (hasPayload) {
+            // use POST if we have payload
+            answer = HttpMethods.POST;
+        } else {
+            // fallback to GET
+            answer = HttpMethods.GET;
+        }
+
+        return answer;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java
new file mode 100644
index 0000000..0bba6e9
--- /dev/null
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java
@@ -0,0 +1,23 @@
+package org.apache.camel.http.common;
+
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+public enum HttpMethods {
+
+    GET, POST, PUT, DELETE, HEAD, OPTIONS, TRACE
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
index 5d48cea..45fc4a3 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -33,7 +33,6 @@ import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.file.GenericFile;
-import org.apache.camel.component.http.helper.HttpMethodsHelper;
 import org.apache.camel.converter.stream.CachedOutputStream;
 import org.apache.camel.http.common.HttpConstants;
 import org.apache.camel.http.common.HttpHelper;
@@ -370,8 +369,9 @@ public class HttpProducer extends DefaultProducer {
 
         // create http holder objects for the request
         RequestEntity requestEntity = createRequestEntity(exchange);
-        HttpMethods methodToUse = HttpMethodsHelper.createMethod(exchange, getEndpoint(), requestEntity != null);
-        HttpMethod method = methodToUse.createMethod(url);
+        String methodName = HttpHelper.createMethod(exchange, getEndpoint(), requestEntity != null).name();
+        HttpMethods methodsToUse = HttpMethods.valueOf(methodName);
+        HttpMethod method = methodsToUse.createMethod(url);
         if (queryString != null) {
             // need to encode query string
             queryString = UnsafeUriCharactersEncoder.encode(queryString);
@@ -380,7 +380,7 @@ public class HttpProducer extends DefaultProducer {
 
         LOG.trace("Using URL: {} with method: {}", url, method);
 
-        if (methodToUse.isEntityEnclosing()) {
+        if (methodsToUse.isEntityEnclosing()) {
             ((EntityEnclosingMethod) method).setRequestEntity(requestEntity);
             if (requestEntity != null && requestEntity.getContentType() == null) {
                 LOG.debug("No Content-Type provided for URL: {} with exchange: {}", url, exchange);

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodsHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodsHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodsHelper.java
deleted file mode 100644
index 2aa04f1..0000000
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpMethodsHelper.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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.net.URISyntaxException;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.http.HttpEndpoint;
-import org.apache.camel.component.http.HttpMethods;
-
-public final class HttpMethodsHelper {
-
-    /**
-     * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
-     *
-     * @param exchange  the exchange
-     * @return the created method
-     * @throws URISyntaxException
-     */
-    public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
-        // 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 (hasPayload) {
-            // use POST if we have payload
-            answer = HttpMethods.POST;
-        } else {
-            // fallback to GET
-            answer = HttpMethods.GET;
-        }
-
-        return answer;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java
index eab55cb..e0a7b39 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/helper/HttpMethodsHelperTest.java
@@ -23,7 +23,8 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.http.HttpEndpoint;
-import org.apache.camel.component.http.HttpMethods;
+import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.HttpMethods;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.junit.Test;
@@ -34,7 +35,7 @@ public class HttpMethodsHelperTest {
 
     @Test
     public void createMethodAlwaysUseUserChoosenMethod() throws URISyntaxException {
-        HttpMethods method = HttpMethodsHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", HttpMethods.POST),
                 createHttpEndpoint(true, "http://www.google.com/search"), false);
         assertEquals(HttpMethods.POST, method);
@@ -42,7 +43,7 @@ public class HttpMethodsHelperTest {
 
     @Test
     public void createMethodUseGETIfQueryIsProvidedInHeader() throws URISyntaxException {
-        HttpMethods method = HttpMethodsHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", null),
                 createHttpEndpoint(true, "http://www.google.com/search"), false);
         assertEquals(HttpMethods.GET, method);
@@ -50,7 +51,7 @@ public class HttpMethodsHelperTest {
 
     @Test
     public void createMethodUseGETIfQueryIsProvidedInEndpointURI() throws URISyntaxException {
-        HttpMethods method = HttpMethodsHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search?q=test"), false);
         assertEquals(HttpMethods.GET, method);
@@ -58,7 +59,7 @@ public class HttpMethodsHelperTest {
 
     @Test
     public void createMethodUseGETIfNoneQueryOrPayloadIsProvided() throws URISyntaxException {
-        HttpMethods method = HttpMethodsHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search"), false);
         assertEquals(HttpMethods.GET, method);
@@ -66,7 +67,7 @@ public class HttpMethodsHelperTest {
 
     @Test
     public void createMethodUsePOSTIfNoneQueryButPayloadIsProvided() throws URISyntaxException {
-        HttpMethods method = HttpMethodsHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search"), true);
         assertEquals(HttpMethods.POST, method);

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/pom.xml b/components/camel-jetty-common/pom.xml
index 150d6e9..8580997 100644
--- a/components/camel-jetty-common/pom.xml
+++ b/components/camel-jetty-common/pom.xml
@@ -45,7 +45,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-http</artifactId>
+            <artifactId>camel-http-common</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
index 78ba6db..e8a35c1 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
@@ -27,10 +27,10 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
-import org.apache.camel.component.http.CamelServlet;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpMessage;
-import org.apache.camel.component.http.helper.HttpHelper;
+import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.HttpMessage;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jetty.continuation.Continuation;

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
index ce3cc26..47a42d8 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java
@@ -25,11 +25,11 @@ 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.HttpConstants;
-import org.apache.camel.component.http.HttpHeaderFilterStrategy;
-import org.apache.camel.component.http.HttpOperationFailedException;
-import org.apache.camel.component.http.HttpProtocolHeaderFilterStrategy;
-import org.apache.camel.component.http.helper.HttpHelper;
+import org.apache.camel.http.common.HttpConstants;
+import org.apache.camel.http.common.HttpHeaderFilterStrategy;
+import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpProtocolHeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.MessageHelper;

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java
index 94d272a..aef8935 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java
@@ -27,8 +27,8 @@ import org.apache.camel.Exchange;
 import org.eclipse.jetty.client.HttpClient;
 
 public interface JettyContentExchange {
-    void init(Exchange exchange, JettyHttpBinding jettyBinding, 
-              final HttpClient client, AsyncCallback callback);
+
+    void init(Exchange exchange, JettyHttpBinding jettyBinding, final HttpClient client, AsyncCallback callback);
 
     // Methods to prepare the request
     void setRequestContentType(String contentType);
@@ -50,8 +50,7 @@ public interface JettyContentExchange {
     void setSupportRedirect(boolean supportRedirect);
 
     /*
-     * Send using jetty HttpClient and return. The callback will be called when the response 
-     * arrives  
+     * Send using jetty HttpClient and return. The callback will be called when the response arrives
      */
     void send(HttpClient client) throws IOException;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java
index 6ed174f..6a2c6f9 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java
@@ -28,6 +28,7 @@ import org.eclipse.jetty.server.Response;
  */
 @Converter
 public final class JettyConverter {
+
     private JettyConverter() {
         //Helper class
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java
index 75e9863..795fbf2 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java
@@ -45,14 +45,14 @@ public interface JettyHttpBinding {
     /**
      * Sets the header filter strategy to use.
      * <p/>
-     * Will default use {@link org.apache.camel.component.http.HttpHeaderFilterStrategy}
+     * Will default use {@link org.apache.camel.http.common.HttpHeaderFilterStrategy}
      *
      * @param headerFilterStrategy the custom strategy
      */
     void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy);
 
     /**
-     * Whether to throw {@link org.apache.camel.component.http.HttpOperationFailedException}
+     * Whether to throw {@link org.apache.camel.http.common.HttpOperationFailedException}
      * in case of response code != 200.
      *
      * @param throwExceptionOnFailure <tt>true</tt> to throw exception
@@ -60,7 +60,7 @@ public interface JettyHttpBinding {
     void setThrowExceptionOnFailure(boolean throwExceptionOnFailure);
 
     /**
-     * Whether to throw {@link org.apache.camel.component.http.HttpOperationFailedException}
+     * Whether to throw {@link org.apache.camel.http.common.HttpOperationFailedException}
      * in case of response code != 200.
      *
      * @return <tt>true</tt> to throw exception

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index f98cee5..fa03902 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -40,12 +40,12 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.component.http.CamelServlet;
-import org.apache.camel.component.http.HttpBinding;
-import org.apache.camel.component.http.HttpComponent;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpEndpoint;
-import org.apache.camel.component.http.UrlRewrite;
+import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpBinding;
+import org.apache.camel.http.common.HttpCommonComponent;
+import org.apache.camel.http.common.HttpCommonEndpoint;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.UrlRewrite;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.ManagementAgent;
 import org.apache.camel.spi.ManagementStrategy;
@@ -91,7 +91,7 @@ import org.slf4j.LoggerFactory;
  *
  * @version 
  */
-public abstract class JettyHttpComponent extends HttpComponent implements RestConsumerFactory {
+public abstract class JettyHttpComponent extends HttpCommonComponent implements RestConsumerFactory {
     public static final String TMP_DIR = "CamelJettyTempDir";
     
     protected static final HashMap<String, ConnectorRef> CONNECTORS = new HashMap<String, ConnectorRef>();
@@ -407,7 +407,7 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
         context.getServletHandler().addFilterWithMapping(filterHolder, pathSpec, 0);
     }
 
-    private void enableMultipartFilter(HttpEndpoint endpoint, Server server, String connectorKey) throws Exception {
+    private void enableMultipartFilter(HttpCommonEndpoint endpoint, Server server, String connectorKey) throws Exception {
         ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
         CamelContext camelContext = this.getCamelContext();
         FilterHolder filterHolder = new FilterHolder();
@@ -445,7 +445,7 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
     @Override
     public void disconnect(HttpConsumer consumer) throws Exception {
         // If the connector is not needed anymore then stop it
-        HttpEndpoint endpoint = consumer.getEndpoint();
+        HttpCommonEndpoint endpoint = consumer.getEndpoint();
         String connectorKey = getConnectorKey(endpoint);
         
         synchronized (CONNECTORS) {
@@ -468,7 +468,7 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
         }
     }
     
-    private String getConnectorKey(HttpEndpoint endpoint) {
+    private String getConnectorKey(HttpCommonEndpoint endpoint) {
         return endpoint.getProtocol() + ":" + endpoint.getHttpUri().getHost() + ":" + endpoint.getPort();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
index 12d944c..994c7fa 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
@@ -21,15 +21,14 @@ import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import javax.servlet.Filter;
 
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.ResolveEndpointFailedException;
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpEndpoint;
+import org.apache.camel.http.common.HttpCommonEndpoint;
+import org.apache.camel.http.common.HttpConsumer;
 import org.apache.camel.impl.SynchronousDelegateProducer;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.util.IntrospectionSupport;
@@ -40,7 +39,7 @@ import org.eclipse.jetty.server.Handler;
 /**
  * @version 
  */
-public abstract class JettyHttpEndpoint extends HttpEndpoint {
+public abstract class JettyHttpEndpoint extends HttpCommonEndpoint {
 
     private List<Handler> handlers;
     private HttpClient client;

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
index 6eda222..a609a46 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
@@ -30,9 +30,9 @@ import org.apache.camel.AsyncProcessor;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
-import org.apache.camel.component.http.HttpConstants;
-import org.apache.camel.component.http.HttpMethods;
-import org.apache.camel.component.http.helper.HttpHelper;
+import org.apache.camel.http.common.HttpConstants;
+import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.HttpMethods;
 import org.apache.camel.impl.DefaultAsyncProducer;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.ExchangeHelper;
@@ -110,13 +110,13 @@ public class JettyHttpProducer extends DefaultAsyncProducer implements AsyncProc
             url = rewriteUrl;
         }
 
-        HttpMethods methodToUse = HttpHelper.createMethod(exchange, getEndpoint(), exchange.getIn().getBody() != null);
-        String method = methodToUse.createMethod(url).getName();
+        // TODO: should not use that
+        HttpMethods method = HttpHelper.createMethod(exchange, getEndpoint(), exchange.getIn().getBody() != null);
 
         JettyContentExchange httpExchange = getEndpoint().createContentExchange();
         httpExchange.init(exchange, getBinding(), client, callback);
         httpExchange.setURL(url); // Url has to be set first
-        httpExchange.setMethod(method);
+        httpExchange.setMethod(method.name());
         
         if (getEndpoint().getHttpClientParameters() != null) {
             // For jetty 9 these parameters can not be set on the client

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestHttpBinding.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestHttpBinding.java
index 6f211f3..401b834 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestHttpBinding.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestHttpBinding.java
@@ -18,15 +18,15 @@ package org.apache.camel.component.jetty;
 
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.camel.component.http.DefaultHttpBinding;
-import org.apache.camel.component.http.HttpEndpoint;
-import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.http.common.DefaultHttpBinding;
+import org.apache.camel.http.common.HttpCommonEndpoint;
+import org.apache.camel.http.common.HttpMessage;
 
 public class JettyRestHttpBinding extends DefaultHttpBinding {
     @Deprecated
     public JettyRestHttpBinding() {
     }
-    public JettyRestHttpBinding(HttpEndpoint ep) {
+    public JettyRestHttpBinding(HttpCommonEndpoint ep) {
         super(ep);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4ed9b0d7/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
index a8c3a4f..ba8672b 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyRestServletResolveConsumerStrategy.java
@@ -23,11 +23,11 @@ import java.util.Locale;
 import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.camel.component.http.HttpConsumer;
-import org.apache.camel.component.http.HttpServletResolveConsumerStrategy;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpServletResolveConsumerStrategy;
 
 /**
- * A {@link org.apache.camel.component.http.HttpServletResolveConsumerStrategy} that supports the Rest DSL.
+ * A {@link org.apache.camel.component.common.http.HttpServletResolveConsumerStrategy} that supports the Rest DSL.
  */
 public class JettyRestServletResolveConsumerStrategy extends HttpServletResolveConsumerStrategy {
 


[15/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 6392719274fdb07eaf776c6f3d3a5f2b3fd69760
Parents: 05019f6
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 11:33:23 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:34 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/63927192/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java b/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java
index c5b3727..13c17be 100644
--- a/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java
+++ b/components/camel-spark-rest/src/test/java/org/apache/camel/component/sparkrest/CamelSparkAcceptTest.java
@@ -18,7 +18,7 @@ package org.apache.camel.component.sparkrest;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.junit.Test;
 
 public class CamelSparkAcceptTest extends BaseSparkTest {


[14/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 04ec33ad644726a863afdd492bf2c6fe5029efac
Parents: 5480449
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 11:20:34 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:33 2015 +0200

----------------------------------------------------------------------
 components/camel-restlet/pom.xml                              | 7 ++++++-
 .../restlet/RestRestletPostJsonPojoOnExceptionTest.java       | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/04ec33ad/components/camel-restlet/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-restlet/pom.xml b/components/camel-restlet/pom.xml
index 43d6def..8b76c32 100644
--- a/components/camel-restlet/pom.xml
+++ b/components/camel-restlet/pom.xml
@@ -75,7 +75,12 @@
 
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-jetty8</artifactId>
+      <artifactId>camel-jetty9</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-http</artifactId>
       <scope>test</scope>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/camel/blob/04ec33ad/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletPostJsonPojoOnExceptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletPostJsonPojoOnExceptionTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletPostJsonPojoOnExceptionTest.java
index 6584936..de02c6d 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletPostJsonPojoOnExceptionTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRestletPostJsonPojoOnExceptionTest.java
@@ -20,7 +20,7 @@ import com.fasterxml.jackson.core.JsonParseException;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.HttpOperationFailedException;
+import org.apache.camel.http.common.HttpOperationFailedException;
 import org.apache.camel.model.rest.RestBindingMode;
 import org.junit.Test;
 


[22/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 481baa6715969d1a4a90d5786774214776535d70
Parents: be77f1a
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 13:50:37 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:35 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/http/common/HttpHelper.java    | 28 ++++++++++++++++----
 .../apache/camel/http/common/HttpMethods.java   |  2 +-
 .../component/http4/helper/HttpHelperTest.java  | 12 ++++-----
 .../component/jetty/JettyHttpProducer.java      |  9 +++----
 4 files changed, 34 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/481baa67/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 2a7189a..fad8889 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
@@ -469,18 +469,36 @@ public final class HttpHelper {
      * @throws URISyntaxException
      */
     public static HttpMethods createMethod(Exchange exchange, HttpCommonEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
+        // 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);
+        // We need also check the HTTP_URI header query part
+        String uriString = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
+        // resolve placeholders in uriString
+        try {
+            uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
+        } catch (Exception e) {
+            throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
+        }
+        if (uriString != null) {
+            URI uri = new URI(uriString);
+            queryString = uri.getQuery();
+        }
+        if (queryString == null) {
+            queryString = endpoint.getHttpUri().getRawQuery();
+        }
+
         // 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 (hasPayload) {
-            // use POST if we have payload
-            answer = HttpMethods.POST;
-        } else {
-            // fallback to GET
+        } 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;

http://git-wip-us.apache.org/repos/asf/camel/blob/481baa67/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java
index 0bba6e9..5762634 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpMethods.java
@@ -18,6 +18,6 @@ package org.apache.camel.http.common;
  */
 public enum HttpMethods {
 
-    GET, POST, PUT, DELETE, HEAD, OPTIONS, TRACE
+    GET, POST, PUT, DELETE, HEAD, OPTIONS, TRACE, PATCH
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/481baa67/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
index be9168a..d74e43f 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/helper/HttpHelperTest.java
@@ -26,8 +26,8 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.component.http4.HttpEndpoint;
-import org.apache.camel.component.http4.HttpMethods;
 import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.HttpMethods;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
 import org.junit.Test;
@@ -114,7 +114,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodAlwaysUseUserChoosenMethod() throws URISyntaxException {
-        HttpMethods method = HttpMethodHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", HttpMethods.POST),
                 createHttpEndpoint(true, "http://www.google.com/search"),
                 false);
@@ -124,7 +124,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodUseGETIfQueryIsProvidedInHeader() throws URISyntaxException {
-        HttpMethods method = HttpMethodHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader("q=camel", null),
                 createHttpEndpoint(true, "http://www.google.com/search"),
                 false);
@@ -134,7 +134,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodUseGETIfQueryIsProvidedInEndpointURI() throws URISyntaxException {
-        HttpMethods method = HttpMethodHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search?q=test"),
                 false);
@@ -144,7 +144,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodUseGETIfNoneQueryOrPayloadIsProvided() throws URISyntaxException {
-        HttpMethods method = HttpMethodHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search"),
                 false);
@@ -154,7 +154,7 @@ public class HttpHelperTest {
 
     @Test
     public void createMethodUsePOSTIfNoneQueryButPayloadIsProvided() throws URISyntaxException {
-        HttpMethods method = HttpMethodHelper.createMethod(
+        HttpMethods method = HttpHelper.createMethod(
                 createExchangeWithOptionalHttpQueryAndHttpMethodHeader(null, null),
                 createHttpEndpoint(true, "http://www.google.com/search"),
                 true);

http://git-wip-us.apache.org/repos/asf/camel/blob/481baa67/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
index a609a46..e3089c3 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
@@ -110,13 +110,12 @@ public class JettyHttpProducer extends DefaultAsyncProducer implements AsyncProc
             url = rewriteUrl;
         }
 
-        // TODO: should not use that
-        HttpMethods method = HttpHelper.createMethod(exchange, getEndpoint(), exchange.getIn().getBody() != null);
+        String methodName = HttpHelper.createMethod(exchange, getEndpoint(), exchange.getIn().getBody() != null).name();
 
         JettyContentExchange httpExchange = getEndpoint().createContentExchange();
         httpExchange.init(exchange, getBinding(), client, callback);
         httpExchange.setURL(url); // Url has to be set first
-        httpExchange.setMethod(method.name());
+        httpExchange.setMethod(methodName);
         
         if (getEndpoint().getHttpClientParameters() != null) {
             // For jetty 9 these parameters can not be set on the client
@@ -127,11 +126,11 @@ public class JettyHttpProducer extends DefaultAsyncProducer implements AsyncProc
             }
             String supportRedirect = (String)getEndpoint().getHttpClientParameters().get("supportRedirect");
             if (supportRedirect != null) {
-                httpExchange.setSupportRedirect(new Boolean(supportRedirect));
+                httpExchange.setSupportRedirect(Boolean.valueOf(supportRedirect));
             }
         }
 
-        LOG.trace("Using URL: {} with method: {}", url, method);
+        LOG.trace("Using URL: {} with method: {}", url, methodName);
 
         // if there is a body to send as data
         if (exchange.getIn().getBody() != null) {


[09/24] camel git commit: camel-http-common - as a common module

Posted by da...@apache.org.
camel-http-common - as a common module


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

Branch: refs/heads/master
Commit: 6231575919406401e14ffa81427c681b2cbc6fa2
Parents: d1f6348
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Jul 23 10:14:02 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 23 15:04:32 2015 +0200

----------------------------------------------------------------------
 .../atmosphere/websocket/CamelWebSocketServlet.java     |  6 ++----
 .../component/atmosphere/websocket/WebSocketStore.java  |  7 +++++++
 .../atmosphere/websocket/WebsocketComponent.java        | 12 ++----------
 .../atmosphere/websocket/WebsocketEndpoint.java         |  8 ++------
 .../atmosphere/websocket/WebsocketHandler.java          |  2 +-
 5 files changed, 14 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/62315759/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
index 50174b4..07c9779 100644
--- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
+++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
@@ -17,13 +17,12 @@
 package org.apache.camel.component.atmosphere.websocket;
 
 import java.io.IOException;
-
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.servlet.CamelHttpTransportServlet;
+import org.apache.camel.http.common.HttpConsumer;
 
 /**
  * This servlet is used to add some websocket specific handling at the moment.
@@ -37,8 +36,7 @@ public class CamelWebSocketServlet extends CamelHttpTransportServlet {
     private static final long serialVersionUID = 1764707448550670635L;
 
     @Override
-    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
-        IOException {
+    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         log.trace("Service: {}", request);
 
         // Is there a consumer registered for the request.

http://git-wip-us.apache.org/repos/asf/camel/blob/62315759/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebSocketStore.java
----------------------------------------------------------------------
diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebSocketStore.java b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebSocketStore.java
index 17627b6..1088157 100644
--- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebSocketStore.java
+++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebSocketStore.java
@@ -25,10 +25,17 @@ import org.atmosphere.websocket.WebSocket;
  *
  */
 public interface WebSocketStore extends Service {
+
     void addWebSocket(String connectionKey, WebSocket websocket);
+
     void removeWebSocket(String connectionKey);
+
     void removeWebSocket(WebSocket websocket);
+
     String getConnectionKey(WebSocket websocket);
+
     WebSocket getWebSocket(String connectionKey);
+
     Collection<WebSocket> getAllWebSockets();
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/62315759/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketComponent.java b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketComponent.java
index b9541ac..b9d5fa2 100644
--- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketComponent.java
+++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketComponent.java
@@ -20,12 +20,8 @@ import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.camel.component.http.HttpClientConfigurer;
 import org.apache.camel.component.servlet.ServletComponent;
 import org.apache.camel.component.servlet.ServletEndpoint;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
-
 
 public class WebsocketComponent extends ServletComponent {
     private Map<String, WebSocketStore> stores;
@@ -39,12 +35,8 @@ public class WebsocketComponent extends ServletComponent {
     }
     
     @Override
-    protected ServletEndpoint createServletEndpoint(String endpointUri, ServletComponent component,
-                                                    URI httpUri, HttpClientParams params,
-                                                    HttpConnectionManager httpConnectionManager,
-                                                    HttpClientConfigurer clientConfigurer) throws Exception {
-        
-        return new WebsocketEndpoint(endpointUri, (WebsocketComponent)component, httpUri, params, httpConnectionManager, clientConfigurer);
+    protected ServletEndpoint createServletEndpoint(String endpointUri, ServletComponent component, URI httpUri) throws Exception {
+        return new WebsocketEndpoint(endpointUri, (WebsocketComponent)component, httpUri);
     }
     
     WebSocketStore getWebSocketStore(String name) {

http://git-wip-us.apache.org/repos/asf/camel/blob/62315759/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java
index 24d8dcf..d8d803c 100644
--- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java
+++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketEndpoint.java
@@ -22,14 +22,11 @@ import java.net.URISyntaxException;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
-import org.apache.camel.component.http.HttpClientConfigurer;
 import org.apache.camel.component.servlet.ServletEndpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpClientParams;
 
 /**
  *
@@ -47,9 +44,8 @@ public class WebsocketEndpoint extends ServletEndpoint {
     @UriParam
     private boolean useStreaming;
     
-    public WebsocketEndpoint(String endPointURI, WebsocketComponent component, URI httpUri, HttpClientParams params, HttpConnectionManager httpConnectionManager,
-                             HttpClientConfigurer clientConfigurer) throws URISyntaxException {
-        super(endPointURI, component, httpUri, params, httpConnectionManager, clientConfigurer);
+    public WebsocketEndpoint(String endPointURI, WebsocketComponent component, URI httpUri) throws URISyntaxException {
+        super(endPointURI, component, httpUri);
 
         //TODO find a better way of assigning the store
         int idx = endPointURI.indexOf('?');

http://git-wip-us.apache.org/repos/asf/camel/blob/62315759/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketHandler.java b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketHandler.java
index fc9e812..09d803d 100644
--- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketHandler.java
+++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/WebsocketHandler.java
@@ -35,7 +35,7 @@ public class WebsocketHandler implements WebSocketProtocol {
 
     @Override
     public void configure(AtmosphereConfig config) {
-        // TODO Auto-generated method stub
+        // noop
     }
     
     @Override