[ 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] <davsclaus> jstrachan i wonder if we should add a case insensitve header lookup [09:56] <davsclaus> the mail component is kinda relying on people can spell the headers as they like [09:56] <davsclaus> Reply-TO [09:56] <davsclaus> reply-to [09:56] <davsclaus> Reply-To [09:56] <davsclaus> etc. [09:56] <davsclaus> different providers might have different case [09:56] <davsclaus> and we got that behavior now for camel mail [09:56] <davsclaus> wonder if that should be extended to a core feature [09:56] <davsclaus> eg [09:56] <davsclaus> content-type [09:56] <davsclaus> Content-type [09:57] <davsclaus> Content-Type [09:57] <jstrachan> yeah - http is the same [09:57] <davsclaus> can be spelt different [09:57] <davsclaus> I doubt anyone want to send 2 headers with dfferent case [09:57] <davsclaus> Foo=me [09:57] <davsclaus> foo=you [09:57] <jstrachan> yeah [09:57] <davsclaus> cool as the tuning kinda changes a bit as its a bit more lazy on headers [09:58] <davsclaus> 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] <davsclaus> so its confusing [09:58] <jstrachan> yeah [09:58] <davsclaus> 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] <davsclaus> 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] <davsclaus> where we can control the equals to be in case sensitve [09:59] <davsclaus> as you may want to retrieve the headers out in the original case [10:00] <jstrachan> I guess we could always use a custom Map which just converts all keys to lower case before storing/looking up? [10:00] <davsclaus> so we cannot just do .toLowerCase when adding a header/headers [10:00] <davsclaus> but when you get the keys back they will be lower now? do we want that [10:00] <davsclaus> We also got some speical camel headers: CamelFileName [10:01] <davsclaus> easier to read when its Camel cased :) [10:01] <jstrachan> 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] <jstrachan> I guess the latter could kick in if folks do a get() which doesn't find anything [10:01] <jstrachan> 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] <davsclaus> ah yeah try the regular map first and if null then the 2nd as lowered cased [10:02] <jstrachan> Object getHeader(String name) { Object answer = map.get(name); if (answer == null) { answer = getLowerCaseMap().get(name.toLowerCase()) [10:02] <davsclaus> so we create the 2nd map lazy? [10:02] <jstrachan> yeah [10:02] <davsclaus> ah clever [10:02] <davsclaus> let me grab coffee and try it on the pesky mail [10:02] <jstrachan> 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] <jstrachan> :) [10:03] <davsclaus> and doing a map empty check as well to avoid creating the 2nd if empty [10:03] <jstrachan> yeah [10:03] <davsclaus> 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.