You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@abdera.apache.org by Neale Upstone <ne...@nealeupstone.com> on 2007/11/22 22:06:44 UTC

Error (?) in AstractResponseContext.addHeaders() - the cause of my previous issue

This is surely, not correct...


  public void addHeader(String name, Object value) {
    Map<String,List<Object>> headers = getHeaders();
    List<Object> values = new ArrayList<Object>();
    if (values == null) {
      values = new ArrayList<Object>();
      headers.put(name, values);
    }
    values.add(value);
  }

I'd suggest that the it should read:

  List<Object> values = headers.get(name); as the 3rd line...


In fact, this would probably explain my previous problem of headers not 
being returned, as headers never gets anything written to it.

Cheers,

Neale


Re: Error (?) in AstractResponseContext.addHeaders() - the cause of my previous issue

Posted by James M Snell <ja...@gmail.com>.
This has been fixed in the trunk...

  public void addHeader(String name, Object value) {
    addHeaders(name, new Object[] {value});
  }

  public void addHeaders(String name, Object... vals) {
    Map<String,Object[]> headers = getHeaders();
    Object[] values = headers.get(name);
    List<Object> l = null;
    if (values == null) {
      l = new ArrayList<Object>();
    } else {
      l = Arrays.asList(values);
    }
    for (Object value : vals) {
      l.add(value);
    }
    headers.put(name, l.toArray(new Object[l.size()]));
  }

- James

Neale Upstone wrote:
> 
> This is surely, not correct...
> 
> 
>  public void addHeader(String name, Object value) {
>    Map<String,List<Object>> headers = getHeaders();
>    List<Object> values = new ArrayList<Object>();
>    if (values == null) {
>      values = new ArrayList<Object>();
>      headers.put(name, values);
>    }
>    values.add(value);
>  }
> 
> I'd suggest that the it should read:
> 
>  List<Object> values = headers.get(name); as the 3rd line...
> 
> 
> In fact, this would probably explain my previous problem of headers not
> being returned, as headers never gets anything written to it.
> 
> Cheers,
> 
> Neale
> 
>