package io.reactivex.netty.protocol.http.server;

import io.netty.handler.codec.http.HttpResponseStatus;

/**
* @author Nitesh Kant
*/
class DefaultErrorResponseGenerator<O> implements ErrorResponseGenerator<O> {
    @Override
    public void updateResponse(HttpServerResponse<O> response, Throwable error) {
        response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
    }
}

@@ -63,318 +63,3116 @@
 tty.
-handler.codec.http.HttpResponseStatus;%0A%0A/**%0A* @author Nitesh Kant%0A*/%0Aclass DefaultErrorResponseGenerator%3CO%3E implements ErrorResponseGenerator%3CO%3E %7B%0A    @Override%0A    public void updateResponse(HttpServerResponse%3CO%3E response, Throwable error) %7B%0A        response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR
+buffer.ByteBuf;%0Aimport io.netty.buffer.ByteBufOutputStream;%0Aimport io.netty.handler.codec.http.HttpHeaders;%0Aimport io.netty.handler.codec.http.HttpResponseStatus;%0Aimport io.netty.util.ReferenceCountUtil;%0Aimport io.reactivex.netty.RxNetty;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport rx.Observable;%0A%0Aimport java.io.PrintStream;%0Aimport java.nio.charset.Charset;%0A%0A/**%0A* @author Nitesh Kant%0A*/%0Aclass DefaultErrorResponseGenerator%3CO%3E implements ErrorResponseGenerator%3CO%3E %7B%0A%0A    private static final Logger logger = LoggerFactory.getLogger(DefaultErrorResponseGenerator.class);%0A%0A    public static final String STACKTRACE_TEMPLATE_VARIABLE = %22$%7Bstacktrace%7D%22;%0A    private static final String ERROR_HTML_TEMPLATE = %22%3C!DOCTYPE html%3E%5Cn%22 +%0A                                                      %22%3Chtml%3E%5Cn%22 +%0A                                                      %22%3Chead%3E%5Cn%22 +%0A                                                      %22    %3Ctitle%3ERxNetty Error Page.%3C/title%3E%5Cn%22 +%0A                                                      %22%3C/head%3E%5Cn%22 +%0A                                                      %22%3Cbody%3E%5Cn%22 +%0A                                                      %22    %3Ch1%3EUnexpected error occured in the server.%3C/h1%3E%5Cn%22 +%0A                                                      %22    %3Ch3%3EError%3C/h3%3E%5Cn%22 +%0A                                                      %22    %3CPRE%3E  %22 + STACKTRACE_TEMPLATE_VARIABLE + %22 %3C/PRE%3E%5Cn%22 +%0A                                                      %22%3C/body%3E%5Cn%22 +%0A                                                      %22%3C/html%3E%22;%0A%0A    @Override%0A    public void updateResponse(HttpServerResponse%3CO%3E response, Throwable error) %7B%0A        response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);%0A        response.getHeaders().set(HttpHeaders.Names.CONTENT_TYPE, %22text/html%22);%0A        ByteBuf buffer = response.getChannelHandlerContext().alloc().buffer(1024);// 1KB initial length.%0A        PrintStream printStream = null;%0A        try %7B%0A            printStream = new PrintStream(new ByteBufOutputStream(buffer));%0A            error.printStackTrace(printStream);%0A            String errorPage = ERROR_HTML_TEMPLATE.replace(STACKTRACE_TEMPLATE_VARIABLE,%0A                                                           buffer.toString(Charset.defaultCharset()));%0A            response.writeString(errorPage);%0A        %7D finally %7B%0A            ReferenceCountUtil.release(buffer);%0A            if (null != printStream) %7B%0A                try %7B%0A                    printStream.flush();%0A                    printStream.close();%0A                %7D catch (Exception e) %7B%0A                    logger.error(%22Error closing stream for generating error response stacktrace. This is harmless.%22, e);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        RxNetty.createHttpServer(8888, new RequestHandler%3CByteBuf, ByteBuf%3E() %7B%0A            @Override%0A            public Observable%3CVoid%3E handle(HttpServerRequest%3CByteBuf%3E request, HttpServerResponse%3CByteBuf%3E response) %7B%0A                throw new NullPointerException(%22doomsday%22);%0A            %7D%0A        %7D).startAndWait(
 );%0A 

Fix for issue #90