@ChannelHandler.Sharable public class StaticFileServerHandler<T extends RestfulGateway> extends LeaderRetrievalHandler<T>
This code is based on the "HttpStaticFileServerHandler" from the Netty project's HTTP server example.
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
HTTP_DATE_FORMAT
Date format for HTTP.
|
leaderRetriever, logger, responseHeaders, timeout| 构造器和说明 |
|---|
StaticFileServerHandler(GatewayRetriever<? extends T> retriever,
org.apache.flink.api.common.time.Time timeout,
File rootPath) |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
checkFileValidity(File file,
File rootPath,
org.slf4j.Logger logger)
Checks various conditions for file access.
|
void |
exceptionCaught(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
protected void |
respondAsLeader(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext channelHandlerContext,
RoutedRequest routedRequest,
T gateway) |
static void |
sendNotModified(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx)
Send the "304 Not Modified" response.
|
static void |
setContentTypeHeader(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse response,
File file)
Sets the content type header for the HTTP Response.
|
static void |
setDateAndCacheHeaders(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse response,
File fileToCache)
Sets the "date" and "cache" headers for the HTTP Response.
|
static void |
setDateHeader(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpResponse response)
Sets the "date" header for the HTTP response.
|
channelRead0acceptInboundMessage, channelReadchannelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, handlerAdded, handlerRemoved, isSharablepublic StaticFileServerHandler(GatewayRetriever<? extends T> retriever, org.apache.flink.api.common.time.Time timeout, File rootPath) throws IOException
IOExceptionprotected void respondAsLeader(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext channelHandlerContext,
RoutedRequest routedRequest,
T gateway)
throws Exception
respondAsLeader 在类中 LeaderRetrievalHandler<T extends RestfulGateway>Exceptionpublic void exceptionCaught(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
exceptionCaught 在接口中 org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerexceptionCaught 在接口中 org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerexceptionCaught 在类中 org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapterpublic static void sendNotModified(org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext ctx)
ctx - The channel context to write the response to.public static void setDateHeader(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpResponse response)
response - HTTP responsepublic static void setDateAndCacheHeaders(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse response,
File fileToCache)
response - The HTTP response object.fileToCache - File to extract the modification timestamp from.public static void setContentTypeHeader(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse response,
File file)
response - HTTP responsefile - file to extract content typepublic static void checkFileValidity(File file, File rootPath, org.slf4j.Logger logger) throws IOException, RestHandlerException
RestHandlerException, and further processing of the request must be limited to sending an
error response.Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.