public abstract class HttpRestHandler
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.HttpObject>
Modifier and Type | Class and Description |
---|---|
protected static class |
HttpRestHandler.HttpCleanChannelFutureListener |
static class |
HttpRestHandler.METHOD |
Modifier and Type | Field and Description |
---|---|
protected RestArgument |
arguments
Arguments received
|
protected io.netty.buffer.ByteBuf |
cumulativeBody
Cumulative chunks
|
protected DbSession |
dbSession |
protected io.netty.handler.codec.http.multipart.HttpPostRequestDecoder |
decoder |
static RestConfiguration |
defaultConfiguration |
static io.netty.handler.codec.http.multipart.HttpDataFactory |
factory |
static io.netty.channel.group.ChannelGroup |
group |
protected RestMethodHandler |
handler |
protected Object |
jsonObject
JSON decoded object
|
protected io.netty.handler.codec.http.HttpRequest |
request |
protected RestArgument |
response
The only structure that might be needed is: ARGS_COOKIE (subset)
|
RestConfiguration |
restConfiguration |
HashMap<String,RestMethodHandler> |
restHashMap |
protected RootOptionsRestMethodHandler |
rootHandler |
protected io.netty.handler.codec.http.HttpResponseStatus |
status |
static String |
TempPath |
Modifier | Constructor and Description |
---|---|
protected |
HttpRestHandler(RestConfiguration config) |
Modifier and Type | Method and Description |
---|---|
protected void |
bodyChunk(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpContent chunk)
Method that get a chunk of data
|
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpObject msg) |
protected abstract void |
checkConnection(io.netty.channel.ChannelHandlerContext ctx)
To be used for instance to check correctness of connection
Note that ARG_METHOD is only set from current request. |
protected void |
clean()
Clean method
Override if needed
|
protected void |
createDecoder()
Create the decoder
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
protected void |
finalizeSend(io.netty.channel.ChannelHandlerContext ctx) |
protected void |
forceClosing(io.netty.channel.ChannelHandlerContext ctx)
To allow quick answer even if in very bad shape
|
protected Object |
getBodyJsonArgs(io.netty.buffer.ByteBuf data)
Get Body args as JSON body
|
DbSession |
getDbSession() |
protected RestMethodHandler |
getHandler()
Could be overwritten if necessary
|
io.netty.handler.codec.http.HttpRequest |
getRequest() |
io.netty.handler.codec.http.FullHttpResponse |
getResponse(io.netty.buffer.ByteBuf content) |
io.netty.handler.codec.http.HttpResponseStatus |
getStatus() |
protected void |
initialize()
Called at the beginning of every new request
Override if needed
|
static void |
initialize(String tempPath)
Initialize the Disk support
|
boolean |
isWillClose() |
protected void |
readAllHttpData()
Read all InterfaceHttpData from finished transfer
|
protected void |
readHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData data)
Read one Data
|
protected void |
readHttpDataChunkByChunk()
Read request by chunk and getting values from chunk to chunk
|
protected void |
setCookies(io.netty.handler.codec.http.FullHttpResponse httpResponse)
Method to set Cookies in httpResponse from response ObjectNode
|
void |
setStatus(io.netty.handler.codec.http.HttpResponseStatus status) |
void |
setWillClose(boolean willClose) |
acceptInboundMessage, channelRead
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
public static final io.netty.handler.codec.http.multipart.HttpDataFactory factory
public static String TempPath
public static io.netty.channel.group.ChannelGroup group
public static final RestConfiguration defaultConfiguration
public HashMap<String,RestMethodHandler> restHashMap
public final RestConfiguration restConfiguration
protected final RootOptionsRestMethodHandler rootHandler
protected io.netty.handler.codec.http.multipart.HttpPostRequestDecoder decoder
protected io.netty.handler.codec.http.HttpResponseStatus status
protected io.netty.handler.codec.http.HttpRequest request
protected RestMethodHandler handler
protected volatile DbSession dbSession
protected RestArgument arguments
protected RestArgument response
protected Object jsonObject
protected io.netty.buffer.ByteBuf cumulativeBody
protected HttpRestHandler(RestConfiguration config)
public static void initialize(String tempPath)
tempPath
- system temp directoryIOException
CryptoException
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelActive
in interface io.netty.channel.ChannelInboundHandler
channelActive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
protected void clean()
Override if needed
protected void initialize()
Override if needed
public DbSession getDbSession()
protected abstract void checkConnection(io.netty.channel.ChannelHandlerContext ctx) throws HttpInvalidAuthenticationException
ctx
- HttpInvalidAuthenticationException
protected void setCookies(io.netty.handler.codec.http.FullHttpResponse httpResponse)
httpResponse
- protected RestMethodHandler getHandler() throws HttpMethodNotAllowedRequestException, HttpForbiddenRequestException
HttpIncorrectRequestException
HttpMethodNotAllowedRequestException
HttpForbiddenRequestException
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpObject msg) throws Exception
channelRead0
in class io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.HttpObject>
Exception
protected void createDecoder() throws HttpIncorrectRequestException
HttpIncorrectRequestException
protected void readAllHttpData() throws HttpIncorrectRequestException
HttpIncorrectRequestException
protected void readHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData data) throws HttpIncorrectRequestException
data
- HttpIncorrectRequestException
protected void forceClosing(io.netty.channel.ChannelHandlerContext ctx)
ctx
- public io.netty.handler.codec.http.FullHttpResponse getResponse(io.netty.buffer.ByteBuf content)
content
- protected void bodyChunk(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpContent chunk) throws HttpIncorrectRequestException, HttpInvalidAuthenticationException, HttpNotFoundRequestException
ctx
- chunk
- HttpIncorrectRequestException
HttpInvalidAuthenticationException
HttpNotFoundRequestException
protected void finalizeSend(io.netty.channel.ChannelHandlerContext ctx)
protected Object getBodyJsonArgs(io.netty.buffer.ByteBuf data) throws HttpIncorrectRequestException
data
- HttpIncorrectRequestException
protected void readHttpDataChunkByChunk() throws HttpIncorrectRequestException
HttpIncorrectRequestException
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelInactive
in interface io.netty.channel.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public io.netty.handler.codec.http.HttpResponseStatus getStatus()
public void setStatus(io.netty.handler.codec.http.HttpResponseStatus status)
status
- the status to setpublic io.netty.handler.codec.http.HttpRequest getRequest()
public boolean isWillClose()
public void setWillClose(boolean willClose)
willClose
- the willClose to setCopyright © 2009–2020 Waarp. All rights reserved.