Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E2940DE1E for ; Thu, 6 Sep 2012 22:28:07 +0000 (UTC) Received: (qmail 78192 invoked by uid 500); 6 Sep 2012 22:28:07 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 78147 invoked by uid 500); 6 Sep 2012 22:28:07 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 78139 invoked by uid 99); 6 Sep 2012 22:28:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2012 22:28:07 +0000 Date: Fri, 7 Sep 2012 09:28:07 +1100 (NCT) From: "Amit Patel (JIRA)" To: issues@camel.apache.org Message-ID: <1203958721.47033.1346970487541.JavaMail.jiratomcat@arcas> Subject: [jira] [Created] (CAMEL-5575) Add new HttpEndpoint Option "httpHeaderFilterStrategy" on Http4 component MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Amit Patel created CAMEL-5575: --------------------------------- Summary: Add new HttpEndpoint Option "httpHeaderFilterStrategy" on Http4 component Key: CAMEL-5575 URL: https://issues.apache.org/jira/browse/CAMEL-5575 Project: Camel Issue Type: New Feature Components: camel-http Reporter: Amit Patel Priority: Critical Fix For: 2.10.1 Attachments: HttpComponent.java Our third-party application accepts Date as Http header, but HttpHeaderFilterStrategy.java filters the date. To support out third-party application I want new feature to add Custom http filter on a Http4 Endpoint. I made the following changes on HttpComponent createEndpoint method to support custom http filter as opetion qq on Http4 Endpoint. @Override protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { String addressUri = uri; if (!uri.startsWith("http4:") && !uri.startsWith("https4:")) { addressUri = remaining; } Map httpClientParameters = new HashMap(parameters); // http client can be configured from URI options HttpParams clientParams = configureHttpParams(parameters); // validate that we could resolve all httpClient. parameters as this component is lenient validateParameters(uri, parameters, "httpClient."); HttpBinding httpBinding = resolveAndRemoveReferenceParameter(parameters, "httpBindingRef", HttpBinding.class); if (httpBinding == null) { httpBinding = resolveAndRemoveReferenceParameter(parameters, "httpBinding", HttpBinding.class); } HttpHeaderFilterStrategy httpHeaderFilterStrategy = resolveAndRemoveReferenceParameter( parameters, "httpHeaderFilterStrategy", HttpHeaderFilterStrategy.class); if (httpHeaderFilterStrategy == null) { httpHeaderFilterStrategy = resolveAndRemoveReferenceParameter( parameters, "httpHeaderFilterStrategy", HttpHeaderFilterStrategy.class); } HttpClientConfigurer httpClientConfigurer = resolveAndRemoveReferenceParameter(parameters, "httpClientConfigurerRef", HttpClientConfigurer.class); if (httpClientConfigurer == null) { httpClientConfigurer = resolveAndRemoveReferenceParameter(parameters, "httpClientConfigurer", HttpClientConfigurer.class); } HttpContext httpContext = resolveAndRemoveReferenceParameter(parameters, "httpContextRef", HttpContext.class); if (httpContext == null) { httpContext = resolveAndRemoveReferenceParameter(parameters, "httpContext", HttpContext.class); } X509HostnameVerifier x509HostnameVerifier = resolveAndRemoveReferenceParameter(parameters, "x509HostnameVerifier", X509HostnameVerifier.class); if (x509HostnameVerifier == null) { x509HostnameVerifier = getX509HostnameVerifier(); } SSLContextParameters sslContextParameters = resolveAndRemoveReferenceParameter(parameters, "sslContextParametersRef", SSLContextParameters.class); if (sslContextParameters == null) { sslContextParameters = getSslContextParameters(); } boolean secure = HttpHelper.isSecureConnection(uri); // create the configurer to use for this endpoint HttpClientConfigurer configurer = createHttpClientConfigurer(parameters, secure); URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), httpClientParameters); // create the endpoint and set the http uri to be null HttpEndpoint endpoint = new HttpEndpoint(endpointUri.toString(), this, clientParams, clientConnectionManager, configurer); // configure the endpoint setProperties(endpoint, parameters); // The httpUri should be start with http or https String httpUriAddress = addressUri; if (addressUri.startsWith("http4")) { httpUriAddress = "http" + addressUri.substring(5); } if (addressUri.startsWith("https4")) { httpUriAddress = "https" + addressUri.substring(6); } // restructure uri to be based on the parameters left as we dont want to include the Camel internal options // build up the http uri URI httpUri = URISupport.createRemainingURI(new URI(httpUriAddress), parameters); // validate http uri that end-user did not duplicate the http part that can be a common error String part = httpUri.getSchemeSpecificPart(); if (part != null) { part = part.toLowerCase(); if (part.startsWith("//http//") || part.startsWith("//https//") || part.startsWith("//http://") || part.startsWith("//https://")) { throw new ResolveEndpointFailedException(uri, "The uri part is not configured correctly. You have duplicated the http(s) protocol."); } } endpoint.setHttpUri(httpUri); if (httpHeaderFilterStrategy != null) { endpoint.setHeaderFilterStrategy(httpHeaderFilterStrategy); } else { setEndpointHeaderFilterStrategy(endpoint); } endpoint.setBinding(getHttpBinding()); if (httpBinding != null) { endpoint.setHttpBinding(httpBinding); } if (httpClientConfigurer != null) { endpoint.setHttpClientConfigurer(httpClientConfigurer); } endpoint.setHttpContext(getHttpContext()); if (httpContext != null) { endpoint.setHttpContext(httpContext); } // register port on schema registry int port = getPort(httpUri); registerPort(secure, x509HostnameVerifier, port, sslContextParameters); return endpoint; } private static int getPort(URI uri) { int port = uri.getPort(); if (port < 0) { if ("http4".equals(uri.getScheme()) || "http".equals(uri.getScheme())) { port = 80; } else if ("https4".equals(uri.getScheme()) || "https".equals(uri.getScheme())) { port = 443; } else { throw new IllegalArgumentException("Unknown scheme, cannot determine port number for uri: " + uri); } } return port; } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira