public class NettyHttpFileHandler extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
HTTP_CACHE_SECONDS |
static String |
HTTP_DATE_FORMAT |
static String |
HTTP_DATE_GMT_TIMEZONE |
protected static MimetypesFileTypeMap |
mimeTypesMap |
| Constructor and Description |
|---|
NettyHttpFileHandler() |
| Modifier and Type | Method and Description |
|---|---|
File |
getResourceAsFile(String resourcePath) |
String |
sanitizeUri(String uri) |
void |
sendError(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpResponseStatus status) |
void |
sendFile(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.FullHttpRequest req) |
void |
sendHttpResponse(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.FullHttpRequest req,
io.netty.handler.codec.http.FullHttpResponse res) |
void |
sendNotModified(io.netty.channel.ChannelHandlerContext ctx)
When file timestamp is the same as what the browser is sending up, send a "304 Not Modified"
|
void |
sendRedirect(io.netty.channel.ChannelHandlerContext ctx,
String newUri) |
void |
setContentTypeHeader(io.netty.handler.codec.http.HttpResponse response,
String filename)
Sets the content type header for the HTTP Response
|
void |
setDateAndCacheHeaders(io.netty.handler.codec.http.HttpResponse response,
File fileToCache)
Sets the Date and Cache headers for the HTTP Response
|
void |
setDateHeader(io.netty.handler.codec.http.FullHttpResponse response)
Sets the Date header for the HTTP response
|
public static final String HTTP_DATE_FORMAT
public static final String HTTP_DATE_GMT_TIMEZONE
public static final int HTTP_CACHE_SECONDS
protected static MimetypesFileTypeMap mimeTypesMap
public void sendFile(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.FullHttpRequest req)
throws Exception
Exceptionpublic void sendRedirect(io.netty.channel.ChannelHandlerContext ctx,
String newUri)
public void sendError(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpResponseStatus status)
public void sendNotModified(io.netty.channel.ChannelHandlerContext ctx)
ctx - Contextpublic void setDateHeader(io.netty.handler.codec.http.FullHttpResponse response)
response - HTTP responsepublic void setDateAndCacheHeaders(io.netty.handler.codec.http.HttpResponse response,
File fileToCache)
response - HTTP responsefileToCache - file to extract content typepublic void setContentTypeHeader(io.netty.handler.codec.http.HttpResponse response,
String filename)
response - HTTP responsefilename - file to extract content typepublic void sendHttpResponse(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.FullHttpRequest req,
io.netty.handler.codec.http.FullHttpResponse res)
Copyright © 2021. All rights reserved.