[ jetty-Bugs-1297901 ] ProxyHandler header propagation bug

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[ jetty-Bugs-1297901 ] ProxyHandler header propagation bug

Bugs item #1297901, was opened at 2005-09-21 16:21
Message generated for change (Settings changed) made by gregwilkins
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Other
Group: None
>Status: Closed
Resolution: Wont Fix
Priority: 5
Submitted By: Aaron Hamid (aaron)
Assigned to: Greg Wilkins (gregwilkins)
Summary: ProxyHandler header propagation bug

Initial Comment:
ProxyHandler has a bug when writing headers back to the
client.  It uses code like:

int h=0;
String hdr=connection.getHeaderFieldKey(h);
String val=connection.getHeaderField(h);
while(hdr!=null || val!=null)
    if (hdr!=null && val!=null &&

However, at least in JDK 1.5 getHeaderField(h) returns
null for the 0th field.  Since a null header field key
is used as a loop termination condition, I suspect the
headers are not being written back to the client.

The loop should either use a different condition for
the loop (e.g., connection.getHeaderFields().size()) or
use the connection.getHeaderFields() map instead.

(Using the map may lose the field order, depending on
what type of map is used internally by the
URLConnection implementation (e.g. LinkedHashMap would
preserve order), but that is the first thing I
implemented.  Probably using
connection.getHeaderFields().size() in combination with
getHeaderFieldKey/getHeaderField is better.)

Patch that fixes this bug attached.


Comment By: Greg Wilkins (gregwilkins)
Date: 2005-10-01 07:58

Logged In: YES

The loop will only terminate if both the key and the value
are null.   So I think the loop is correct.

I could use the size of the header fields, but that would
break portability for older JVMs.

So thanks for your interest and patch, but I'm pretty sure
the code is OK - unless a null header AND a null value can
be returned before the last header.


You can respond by visiting:

This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
jetty-discuss mailing list
[hidden email]