private StreamedHttpResponse createHttpResponse()

in src/main/java/com/twitter/http2/HttpStreamDecoder.java [234:269]


    private StreamedHttpResponse createHttpResponse(HttpHeadersFrame httpHeadersFrame)
            throws Exception {
        // Create the first line of the request from the name/value pairs
        HttpResponseStatus status = HttpResponseStatus.valueOf(Integer.parseInt(
                httpHeadersFrame.headers().get(":status")));

        httpHeadersFrame.headers().remove(":status");

        StreamedHttpResponse response = new StreamedHttpResponse(HttpVersion.HTTP_1_1, status);
        for (Map.Entry<String, String> e : httpHeadersFrame.headers()) {
            String name = e.getKey();
            String value = e.getValue();
            if (name.charAt(0) != ':') {
                response.headers().add(name, value);
            }
        }

        // Set the Stream-ID as a header
        response.headers().set("X-SPDY-Stream-ID", httpHeadersFrame.getStreamId());

        // The Connection and Keep-Alive headers are no longer valid
        HttpHeaders.setKeepAlive(response, true);

        // Transfer-Encoding header is not valid
        response.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING);
        response.headers().remove(HttpHeaders.Names.TRAILER);

        if (httpHeadersFrame.isLast()) {
            response.getContent().close();
            response.setDecoderResult(DecoderResult.SUCCESS);
        } else {
            response.setDecoderResult(DecoderResult.UNFINISHED);
        }

        return response;
    }