@@ -0,0 +1,2260 @@
+/**%0A * This file is part of the Gribbit Web Framework.%0A * %0A *     https://github.com/lukehutch/gribbit%0A * %0A * @author Luke Hutchison%0A * %0A * --%0A * %0A * @license Apache 2.0 %0A * %0A * Copyright 2015 Luke Hutchison%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *     http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage gribbit.http.response;%0A%0Aimport gribbit.http.request.Request;%0Aimport io.netty.channel.ChannelHandlerContext;%0Aimport io.netty.handler.codec.http.HttpChunkedInput;%0Aimport io.netty.handler.codec.http.HttpResponseStatus;%0Aimport io.netty.handler.codec.http.LastHttpContent;%0Aimport io.netty.handler.stream.ChunkedStream;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0A/**%0A * Chunked (streamed) response.%0A */%0Apublic class InputStreamResponse extends GeneralResponse %7B%0A    protected InputStream contentStream;%0A%0A    public InputStreamResponse(Request request, HttpResponseStatus status, InputStream content,%0A            String contentType) %7B%0A        super(request, status, contentType);%0A        this.contentStream = content;%0A    %7D%0A%0A    public InputStreamResponse(Request request, InputStream content, String contentType) %7B%0A        this(request, HttpResponseStatus.OK, content, contentType);%0A    %7D%0A    %0A    @Override%0A    public void writeResponse(ChannelHandlerContext ctx) %7B%0A        isChunked = true;%0A        sendHeaders(ctx);%0A%0A        if (!request.isHEADRequest()) %7B%0A            ctx.writeAndFlush(new HttpChunkedInput(new ChunkedStream(contentStream, 8192)));%0A        %7D%0A        ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);%0A    %7D%0A%0A    @Override%0A    public void close() %7B%0A        if (contentStream != null) %7B%0A            try %7B%0A                contentStream.close();%0A            %7D catch (IOException e) %7B%0A            %7D%0A            contentStream = null;%0A        %7D%0A    %7D%0A%7D%0A

Add class