use of com.feeyo.net.http.handler.ResourceFileDownloadGetHandler in project feeyo-hlsserver by variflight.
the class HttpServerRequestHandler method processHttpRequest.
private void processHttpRequest(ChannelHandlerContext ctx, MessageEvent e) {
HttpRequest request = (DefaultHttpRequest) e.getMessage();
String uri = request.getUri();
IRequestHandler requestHandler = getHandler(request);
if (requestHandler != null) {
boolean isFilted = requestHandler.isFilted();
if (isFilted && !processFilter(ctx, e, requestHandler)) {
IRequestHandler.Type type = requestHandler.getType();
if (type == IRequestHandler.Type.VM) {
sendRedirect(ctx, "/v1/view/login");
} else {
HttpResponse response = buildDefaultResponse("", HttpResponseStatus.UNAUTHORIZED);
sendResponse(ctx, response);
}
return;
}
} else {
// path 路由不成功, 检测是否是静态文件下载
int lastDot = uri.lastIndexOf('.');
if (lastDot != -1) {
String extension = uri.substring(lastDot + 1).toLowerCase();
if (extension != null && extension.length() < 6) {
requestHandler = new ResourceFileDownloadGetHandler();
}
}
}
if (requestHandler != null) {
try {
requestHandler.execute(ctx, e);
} catch (Exception e1) {
LOGGER.error("http handler err:", e1);
HttpResponse response = buildErrorResponse("internal error");
sendResponse(ctx, response);
}
} else {
HttpResponse response = buildDefaultResponse("", HttpResponseStatus.NOT_FOUND);
sendResponse(ctx, response);
}
}
Aggregations