abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: Error (?) in AstractResponseContext.addHeaders() - the cause of my previous issue
Date Thu, 22 Nov 2007 21:30:58 GMT
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
> 
> 

Mime
View raw message