camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roman Kalukiewicz <roman.kalukiew...@gmail.com>
Subject Re: [DISCUSS] - Camel 2.0 - Case insensitive headers on Camel Message
Date Mon, 10 Aug 2009 12:51:18 GMT
2009/8/10 Claus Ibsen <claus.ibsen@gmail.com>:
> On Mon, Aug 10, 2009 at 2:02 PM, James Strachan<james.strachan@gmail.com> wrote:
>> 2009/8/10 Roman Kalukiewicz <roman.kalukiewicz@gmail.com>:
>>> Just few general comments on the topic here:
>>>
>>> 1) My impression is that we are trying to solve problem that doesn't
>>> exist. No one would expect that getting "foo" header should retrieve
>>> what was put under "FOO" key. If we want to have guarantee that it
>>> works properly people should use constants for it. It is the way that
>>> Java world solves those problems
>>> 2) If we create CaseInsenstiveMap class we will fail to obey Map
>>> contract. Let's take a look at Map.containsKey() method's contract in
>>> javadoc. And my impression is that we want to treat headers as a Map,
>>> don't we?
>>>
>>> In protocols that has case-insensitive headers (like http) I believe
>>> component should take care of it by (for example) setting headers
>>> using lowercase keys only (for example) and it should be clearly
>>> stated in component's documentation, as in Camel components are
>>> responsible for handling protocol-specific features.
>>
>> I think camel should preserve what its given by default though. e.g.
>> passing requests from HTTP or email into Camel shouldn't rename
>> headers IMHO
>>
>
> And this is exactly what it does now. If a header is stored as "Foo"
> then it stays that way.
> However you can also look it up using "foo".

OK - sounds good. What I don't like is that headers would be strange
Map implementation.
What I would prefer is special Map view on the standard headers, where
keys are lower-cased. And it should be read-only.
If it is not read-only we violate Map contract and strange things
start to happen like

map.put(foo, value1)
map.size() == 1
map.containsKey(foo) == true
map.containsKey(FOO) == true // I guess it will return true
map.keys().contains(FOO) == false // as keys() are lowercase I guess.
Or maybe special case-insensitive Set?
map.put(FOO, value2)
map.size() == 1

The thing that might be discussed is if header() in DSL should use
case sensitive or insensitive map.
Another thing to discuss is if we would like to add
getCaseInsensitiveHeader(s)() method to the message that would return
such map. But once again - having read-write headers not conforming to
standard Map contract is a bad idea I think.

Roman

Mime
View raw message