* Exception handling in HttpRequestHandler
* HttpRequestHandler prints the protocol version now
This commit is contained in:
parent
1262c45ab3
commit
1e568be9cb
@ -32,6 +32,7 @@ import org.jboss.netty.channel.ChannelFuture;
|
|||||||
import org.jboss.netty.channel.ChannelFutureListener;
|
import org.jboss.netty.channel.ChannelFutureListener;
|
||||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||||
import org.jboss.netty.channel.ChannelPipelineCoverage;
|
import org.jboss.netty.channel.ChannelPipelineCoverage;
|
||||||
|
import org.jboss.netty.channel.ExceptionEvent;
|
||||||
import org.jboss.netty.channel.MessageEvent;
|
import org.jboss.netty.channel.MessageEvent;
|
||||||
import org.jboss.netty.channel.SimpleChannelHandler;
|
import org.jboss.netty.channel.SimpleChannelHandler;
|
||||||
import org.jboss.netty.handler.codec.http.Cookie;
|
import org.jboss.netty.handler.codec.http.Cookie;
|
||||||
@ -64,8 +65,10 @@ public class HttpRequestHandler extends SimpleChannelHandler {
|
|||||||
responseContent.append("WELCOME TO THE WILD WILD WEB SERVER\r\n");
|
responseContent.append("WELCOME TO THE WILD WILD WEB SERVER\r\n");
|
||||||
responseContent.append("===================================\r\n");
|
responseContent.append("===================================\r\n");
|
||||||
|
|
||||||
|
responseContent.append("VERSION: " + request.getProtocolVersion().getText() + "\r\n");
|
||||||
|
|
||||||
if (request.containsHeader(HttpHeaders.Names.HOST)) {
|
if (request.containsHeader(HttpHeaders.Names.HOST)) {
|
||||||
responseContent.append("HOST: " + request.getHeader(HttpHeaders.Names.HOST) + "\r\n");
|
responseContent.append("HOSTNAME: " + request.getHeader(HttpHeaders.Names.HOST) + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
responseContent.append("REQUEST_URI: " + request.getUri() + "\r\n\r\n");
|
responseContent.append("REQUEST_URI: " + request.getUri() + "\r\n\r\n");
|
||||||
@ -152,4 +155,11 @@ public class HttpRequestHandler extends SimpleChannelHandler {
|
|||||||
future.addListener(ChannelFutureListener.CLOSE);
|
future.addListener(ChannelFutureListener.CLOSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
|
||||||
|
throws Exception {
|
||||||
|
e.getCause().printStackTrace();
|
||||||
|
e.getChannel().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user