/*
 * Copyright 2010 Ning, Inc.
 *
 * Ning licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package com.ning.http.client.providers;

import com.ning.http.client.AsyncHttpProvider;
import com.ning.http.client.Headers;
import com.ning.http.client.HttpResponseHeaders;
import com.ning.http.url.Url;
import org.jboss.netty.handler.codec.http.HttpChunkTrailer;
import org.jboss.netty.handler.codec.http.HttpResponse;

/**
 * A class that represent the HTTP headers.
 */
public class ResponseHeaders extends HttpResponseHeaders<HttpResponse> {

    private final HttpChunkTrailer trailingHeaders;

    public ResponseHeaders(Url url, HttpResponse response, AsyncHttpProvider<HttpResponse>  provider) {
        super(url, response, provider, false);
        this.trailingHeaders = null;

    }

    public ResponseHeaders(Url url,HttpResponse response, AsyncHttpProvider<HttpResponse>  provider, HttpChunkTrailer traillingHeaders) {
        super(url, response, provider, true);
        this.trailingHeaders = traillingHeaders;
    }

    /**
     * Return the HTTP header
     * @return an {@link com.ning.http.client.Headers}
     */
    public Headers getHeaders() {
        Headers h = new Headers();
        for (String s : response.getHeaderNames()) {
            h.add(s, response.getHeader(s));
        }

        if (trailingHeaders != null && trailingHeaders.getHeaderNames().size() > 0) {
            for (final String s : trailingHeaders.getHeaderNames()) {
                h.add(s, trailingHeaders.getHeader(s));
            }
        }

        return Headers.unmodifiableHeaders(h);
    }

}
@@ -777,32 +777,70 @@
 esponseHeaders;%0A
+import com.ning.http.collection.Pair;%0A
 import com.ning.
@@ -1820,24 +1820,36 @@
         
-h.add(s,
+for (String header :
  respons
@@ -1851,37 +1851,87 @@
 sponse.getHeader
+s
 (s))
-;
+ %7B%0A                h.add(s, header);%0A            %7D
 %0A        %7D%0A%0A    
@@ -2102,32 +2102,37 @@
     
-h.add(s, trailingH
+for (String h
 eader
-s
+ : response
 .get
@@ -2141,13 +2141,71 @@
 ader
+s
 (s))
-;
+ %7B%0A                    h.add(s, header);%0A                %7D
 %0A   

Make multiple response headers go through.