pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Brind <bri...@brindy.org.uk>
Subject Re: Query handling multiple response headers with same name
Date Fri, 22 May 2009 11:44:22 GMT
Sorry, hit send too soon in the fix example below, but you get the idea.

Cheers,
Chris


2009/5/22 Christopher Brind <brindy@brindy.org.uk>

> Hi,
>
> Off the back of Sandro's email earlier I was looking at the Query class and
> notice that it uses a dictionary to store the response headers:
>
> int i = 1;
>> for (String key = connection.getHeaderFieldKey(i);
>> key != null;
>> key = connection.getHeaderFieldKey(++i)) {
>>  responseProperties.put(key, connection.getHeaderField(i));
>> }
>>
>
> However, you can have multiple headers with the same name, e.g.
>
> Set-Cookie: name=MyCookie; value=Some value
> Set-Cookie: name=AnotherCookie; value=666
> MyHeader: hello
> MyHeader: world
>
> The code above would overwrite proceeding values with the most recent one
> retrieved so the result of the above would be a map with the following:
>
> Set-Cookie: name=AnotherCookie; value=666
> MyHeader: world
>
> The obvious solution is to change
>
> public final class RequestPropertiesDictionary
>         implements Dictionary<String, String>, Iterable<String>
>
>
> To
>
> public final class RequestPropertiesDictionary
>
>         implements Dictionary<String, String[]>, Iterable<String>
>
>
> and fix the Query class to cope with an array, e.g.
>
> for (String key = connection.getHeaderFieldKey(i);
>                 key != null;
>
>                 key = connection.getHeaderFieldKey(++i)) {
>
>      String[] values = responseProperties.get(key);
>      if (null == values) {
>         values = new String[1];
>      } else {
>
>      }
>      values[values.length - 1] = connection.getHeaderField(i)
>
>                 responseProperties.put(key, );
>
> }
>
>
>
> Any thoughts?
>
> If this is valid I'll create a JIRA issue and submit a fix (it's been a
> while since I've committed anything!) and fix up anything dependent on the
> existing version of RequestPropertiesDictionary.
>
> Cheers,
> Chris
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message