Return-Path: Delivered-To: apmail-camel-dev-archive@www.apache.org Received: (qmail 77896 invoked from network); 7 Aug 2009 08:06:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Aug 2009 08:06:53 -0000 Received: (qmail 56676 invoked by uid 500); 7 Aug 2009 08:07:01 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 56646 invoked by uid 500); 7 Aug 2009 08:07:01 -0000 Mailing-List: contact dev-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 dev@camel.apache.org Received: (qmail 56636 invoked by uid 500); 7 Aug 2009 08:07:00 -0000 Delivered-To: apmail-activemq-camel-dev@activemq.apache.org Received: (qmail 56633 invoked by uid 99); 7 Aug 2009 08:07:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Aug 2009 08:07:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Aug 2009 08:06:57 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 48148234C04B for ; Fri, 7 Aug 2009 01:06:36 -0700 (PDT) Message-ID: <1993729434.1249632396284.JavaMail.jira@brutus> Date: Fri, 7 Aug 2009 01:06:36 -0700 (PDT) From: "Claus Ibsen (JIRA)" To: camel-dev@activemq.apache.org Subject: [jira] Commented: (CAMEL-1886) Lookup headers from a Camel Message should be case agnostic In-Reply-To: <1858824633.1249632275707.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: ae95407df07c98740808b2ef9da0087c X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/activemq/browse/CAMEL-1886?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=53519#action_53519 ] Claus Ibsen commented on CAMEL-1886: ------------------------------------ [09:55] jstrachan i wonder if we should add a case insensitve header lookup [09:56] the mail component is kinda relying on people can spell the headers as they like [09:56] Reply-TO [09:56] reply-to [09:56] Reply-To [09:56] etc. [09:56] different providers might have different case [09:56] and we got that behavior now for camel mail [09:56] wonder if that should be extended to a core feature [09:56] eg [09:56] content-type [09:56] Content-type [09:57] Content-Type [09:57] yeah - http is the same [09:57] can be spelt different [09:57] I doubt anyone want to send 2 headers with dfferent case [09:57] Foo=me [09:57] foo=you [09:57] yeah [09:57] cool as the tuning kinda changes a bit as its a bit more lazy on headers [09:58] so if you lookup directly on the source object (MailMessage etc.) then the case can change when its later extracted to the camel message headers [09:58] so its confusing [09:58] yeah [09:58] okay i think we should add that to the camel-core so whenever you do a getHeader(name) it can lookup regardless of case [09:59] how can we do that fast, eg use some Entry object as Key instead of string? so we can do a equals/hashCode contract? [09:59] where we can control the equals to be in case sensitve [09:59] as you may want to retrieve the headers out in the original case [10:00] I guess we could always use a custom Map which just converts all keys to lower case before storing/looking up? [10:00] so we cannot just do .toLowerCase when adding a header/headers [10:00] but when you get the keys back they will be lower now? do we want that [10:00] We also got some speical camel headers: CamelFileName [10:01] easier to read when its Camel cased :) [10:01] I guess we could have 2 maps; the map which preserves case; and a lower-case-index used to lookup headers in a case insensitive way? bit icky mind you [10:01] I guess the latter could kick in if folks do a get() which doesn't find anything [10:01] so to avoid creating 2 maps, we only use the case-insensiive index when folks do get(String) and don't find anything [10:01] ah yeah try the regular map first and if null then the 2nd as lowered cased [10:02] Object getHeader(String name) { Object answer = map.get(name); if (answer == null) { answer = getLowerCaseMap().get(name.toLowerCase()) [10:02] so we create the 2nd map lazy? [10:02] yeah [10:02] ah clever [10:02] let me grab coffee and try it on the pesky mail [10:02] so its zero cost when folks never do lookups; when we just copy headers from message to message we don't bother with the lower case map [10:02] :) [10:03] and doing a map empty check as well to avoid creating the 2nd if empty [10:03] yeah [10:03] btw about 50% of the componetns now tests with tuning > Lookup headers from a Camel Message should be case agnostic > ----------------------------------------------------------- > > Key: CAMEL-1886 > URL: https://issues.apache.org/activemq/browse/CAMEL-1886 > Project: Apache Camel > Issue Type: Improvement > Components: camel-core > Affects Versions: 2.0-M3 > Reporter: Claus Ibsen > Assignee: Claus Ibsen > Fix For: 2.0.0 > > > Today the case matter so: getHeader("Foo") and getHeader("foo") is not the same. > And for some protocols the header case do not matter such as > - http > - mail > etc. > And who would in real life want to send 2 headers that are different only depending on the case > - Foo=me > - foo=you -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.