private HttpHeadersFrame createHttpHeadersFrame()

in src/main/java/com/twitter/http2/HttpStreamEncoder.java [314:338]


    private HttpHeadersFrame createHttpHeadersFrame(HttpResponse httpResponse)
            throws Exception {
        // Get the Stream-ID from the headers
        int streamId = HttpHeaders.getIntHeader(httpResponse, "X-SPDY-Stream-ID");
        httpResponse.headers().remove("X-SPDY-Stream-ID");

        // The Connection, Keep-Alive, Proxy-Connection, and Transfer-Encoding
        // headers are not valid and MUST not be sent.
        httpResponse.headers().remove(HttpHeaders.Names.CONNECTION);
        httpResponse.headers().remove("Keep-Alive");
        httpResponse.headers().remove("Proxy-Connection");
        httpResponse.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING);

        HttpHeadersFrame httpHeadersFrame = new DefaultHttpHeadersFrame(streamId);

        // Unfold the first line of the response into name/value pairs
        httpHeadersFrame.headers().set(":status", httpResponse.getStatus().code());

        // Transfer the remaining HTTP headers
        for (Map.Entry<String, String> entry : httpResponse.headers()) {
            httpHeadersFrame.headers().add(entry.getKey(), entry.getValue());
        }

        return httpHeadersFrame;
    }