|
|
@ -34,6 +34,11 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ |
|
|
|
|
|
|
|
|
|
|
|
private static final String SERVER_VS = "LPS-0.1"; |
|
|
|
private static final String SERVER_VS = "LPS-0.1"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* http 斜杠 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static final String HTTP_SYMBOL ="/"; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { |
|
|
|
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { |
|
|
|
|
|
|
|
|
|
|
@ -76,7 +81,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ |
|
|
|
HttpResponseStatus status = HttpResponseStatus.OK; |
|
|
|
HttpResponseStatus status = HttpResponseStatus.OK; |
|
|
|
URI uri = new URI(request.getUri()); |
|
|
|
URI uri = new URI(request.getUri()); |
|
|
|
String uriPath = uri.getPath(); |
|
|
|
String uriPath = uri.getPath(); |
|
|
|
uriPath = uriPath.equals("/") ? "/index.html" : uriPath; |
|
|
|
uriPath = HTTP_SYMBOL.equals(uriPath)? "/index.html" : uriPath; |
|
|
|
String path = PAGE_FOLDER + uriPath; |
|
|
|
String path = PAGE_FOLDER + uriPath; |
|
|
|
File rfile = new File(path); |
|
|
|
File rfile = new File(path); |
|
|
|
if (rfile.isDirectory()) { |
|
|
|
if (rfile.isDirectory()) { |
|
|
|