Wolfgang Baer wrote:
Nice to see you have removed that now useless inner Header class. This was one
of the comments I wanted to make. I worked this day on mauve testcases for this
rewrite.
These exposed two small bugs in Headers.java:
Index: gnu/java/net/protocol/http/Headers.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/net/protocol/http/Headers.java,v
retrieving revision 1.6
diff -c -p -r1.6 Headers.java
*** gnu/java/net/protocol/http/Headers.java 2 Mar 2006 00:26:57 -0000
1.6
--- gnu/java/net/protocol/http/Headers.java 2 Mar 2006 20:40:32 -0000
[...]
!
! /**
! * Get a new Map containing all the headers. The keys of the Map
! * are Strings (the header names). The values of the Map are
! * unmodifiable Lists containing Strings (the header values).
! *
! * <p>
! *
! * The returned map is modifiable. Changing it will not effect this
! * collection of Headers in any way.
! *
! * @return a Map containing all the headers.
! */
! public Map getAsMap()
{
! LinkedHashMap m = new LinkedHashMap();
! for (Iterator it = headers.iterator(); it.hasNext(); )
{
! HeaderElement e = (HeaderElement)it.next();
! String k = e.name.toLowerCase();
No lowercase here. Otherwise keys with uppercase names won't be found.
String k = e.name;
Not correct.
These Maps are only modified internally to classpath. The RFC requires
header name comparisons to be case insensitive. The only way to make
the Map work with String keys is to ensure that the keys get transformed
to a consistant case. When the Maps make their way into user code,
there is no way to know the case so the only operation that makes sense
WTR user code is iteration. You have to know a priori that they are
lower-cased. I will document this.
! ArrayList l = (ArrayList)m.get(k);
! if (l == null)
! {
! l = new ArrayList(1);
! l.add(e.value);
! m.put(k, l);
! }
! else
! l.add(e.value);
The second value must be added before. The test show
that SUN always adds the last received value for a
key first.
l.add(0, e.value);
Good catch!, I will make this change.
David Daney.