public abstract class HttpRequestHandler
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.HttpObject>
Modifier and Type | Field and Description |
---|---|
protected String |
baseStaticPath |
protected AbstractHttpBusinessRequest |
businessRequest |
protected String |
cookieSession |
protected io.netty.handler.codec.http.multipart.HttpPostRequestDecoder |
decoder |
protected String |
errorMesg |
protected HttpPage |
httpPage |
protected HttpPageHandler |
httpPageHandler |
protected io.netty.handler.codec.http.HttpMethod |
method |
protected io.netty.handler.codec.http.HttpRequest |
request |
protected HttpSession |
session |
protected io.netty.handler.codec.http.HttpResponseStatus |
status |
protected boolean |
willClose |
Modifier | Constructor and Description |
---|---|
protected |
HttpRequestHandler(String baseStaticPath,
String cookieSession,
HttpPageHandler httpPageHandler) |
Modifier and Type | Method and Description |
---|---|
protected void |
addBusinessCookie(io.netty.handler.codec.http.FullHttpResponse response,
Set<String> cookieNames)
Method to add specific Cookies from business definition
Override if needed
|
protected abstract void |
beforeSimplePage(io.netty.channel.ChannelHandlerContext ctx)
Called before simple Page is called (Menu or HTML)
|
abstract void |
businessValidRequestAfterAllDataReceived(io.netty.channel.ChannelHandlerContext ctx)
Validate all data as they should be all received (done before the
isRequestValid)
|
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
|
protected void |
clean()
Clean method
Override if needed
|
protected void |
createNewSessionAtConnection(io.netty.channel.ChannelHandlerContext ctx)
Default session creation
|
protected void |
delete(io.netty.channel.ChannelHandlerContext ctx)
Method that get delete data
|
protected abstract void |
error(io.netty.channel.ChannelHandlerContext ctx)
Called when an error is raised.
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
protected void |
finalData(io.netty.channel.ChannelHandlerContext ctx)
Method that will use the result and send back the result
|
protected abstract void |
finalDelete(io.netty.channel.ChannelHandlerContext ctx)
Method that will use the uploaded file and prepare the result
|
protected abstract void |
finalGet(io.netty.channel.ChannelHandlerContext ctx)
Method that will use the uploaded file and send back the result
(this method must send back the answer using for instance a ChunkedInput handler and should try to call clean(), but taking into consideration that it will erase all data, so it must be ensured that all data are sent through the wire before calling it. |
protected abstract void |
finalPost(io.netty.channel.ChannelHandlerContext ctx)
Method that will use the post result and prepare the result
|
protected abstract void |
finalPostUpload(io.netty.channel.ChannelHandlerContext ctx)
Method that will use the uploaded file and prepare the result
|
protected abstract void |
finalPut(io.netty.channel.ChannelHandlerContext ctx)
Method that will use the put result and prepare the result
|
protected void |
forceClosing(io.netty.channel.ChannelHandlerContext ctx)
To allow quick answer even if in very bad shape
|
protected void |
getCookieArgs()
set values from Cookies
|
protected void |
getFile(io.netty.channel.ChannelHandlerContext ctx)
Method that get "get" data, answer has to be written in the business part
finalGet
|
protected abstract String |
getFilename() |
protected void |
getHeaderArgs()
set values from Header
|
protected String |
getNewCookieSession()
Default Session Cookie generator
|
protected io.netty.handler.codec.http.FullHttpResponse |
getResponse(io.netty.buffer.ByteBuf buf) |
protected void |
getUriArgs()
set values from URI
|
protected void |
initialize()
Called at the beginning of every new request
Override if needed
|
protected abstract boolean |
isCookieValid(io.netty.handler.codec.http.cookie.Cookie cookie)
Could be used for other method (as validation of an authent cookie)
|
protected void |
post(io.netty.channel.ChannelHandlerContext ctx)
Method that get post data
|
protected void |
postChunk(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpContent chunk)
Method that get a chunk of data
|
protected void |
prepareError(io.netty.channel.ChannelHandlerContext ctx,
String message)
Utility to prepare error
|
protected void |
readHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData data,
io.netty.channel.ChannelHandlerContext ctx)
Read one Data
|
protected void |
readHttpDataAllReceive(io.netty.channel.ChannelHandlerContext ctx)
Read all InterfaceHttpData from finished transfer
|
protected void |
readHttpDataChunkByChunk(io.netty.channel.ChannelHandlerContext ctx)
Read request by chunk and getting values from chunk to chunk
|
protected void |
setCookieEncoder(io.netty.handler.codec.http.FullHttpResponse response)
Method to set Cookies in response
|
protected boolean |
setErrorPage(io.netty.channel.ChannelHandlerContext ctx)
Instantiate the page and the businessRequest handler
|
protected void |
writeErrorPage(io.netty.channel.ChannelHandlerContext ctx)
Write an error page
|
protected void |
writeSimplePage(io.netty.channel.ChannelHandlerContext ctx)
Write a simple page from current httpPage and businessRequest
|
acceptInboundMessage, channelRead
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
protected final String baseStaticPath
protected final String cookieSession
protected final HttpPageHandler httpPageHandler
protected HttpSession session
protected io.netty.handler.codec.http.multipart.HttpPostRequestDecoder decoder
protected HttpPage httpPage
protected AbstractHttpBusinessRequest businessRequest
protected io.netty.handler.codec.http.HttpResponseStatus status
protected String errorMesg
protected io.netty.handler.codec.http.HttpRequest request
protected io.netty.handler.codec.http.HttpMethod method
protected volatile boolean willClose
protected HttpRequestHandler(String baseStaticPath, String cookieSession, HttpPageHandler httpPageHandler)
baseStaticPath
- cookieSession
- httpPageHandler
- protected void clean()
Override if needed
protected void initialize()
Override if needed
protected void getUriArgs() throws HttpIncorrectRequestException
HttpIncorrectRequestException
protected void getHeaderArgs() throws HttpIncorrectRequestException
HttpIncorrectRequestException
protected void getCookieArgs() throws HttpIncorrectRequestException
HttpIncorrectRequestException
protected abstract void checkConnection(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected abstract void error(io.netty.channel.ChannelHandlerContext ctx)
ctx
- 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 prepareError(io.netty.channel.ChannelHandlerContext ctx, String message) throws HttpIncorrectRequestException
ctx
- message
- HttpIncorrectRequestException
protected boolean setErrorPage(io.netty.channel.ChannelHandlerContext ctx)
ctx
- protected void writeErrorPage(io.netty.channel.ChannelHandlerContext ctx)
ctx
- protected void forceClosing(io.netty.channel.ChannelHandlerContext ctx)
ctx
- protected void writeSimplePage(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected abstract boolean isCookieValid(io.netty.handler.codec.http.cookie.Cookie cookie)
cookie
- protected void addBusinessCookie(io.netty.handler.codec.http.FullHttpResponse response, Set<String> cookieNames)
Override if needed
response
- cookieNames
- protected void setCookieEncoder(io.netty.handler.codec.http.FullHttpResponse response)
response
- protected io.netty.handler.codec.http.FullHttpResponse getResponse(io.netty.buffer.ByteBuf buf)
buf
- might be nullprotected abstract String getFilename()
protected abstract void beforeSimplePage(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected void finalData(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected abstract void finalDelete(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected abstract void finalGet(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected abstract void finalPostUpload(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected abstract void finalPost(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected abstract void finalPut(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
public abstract void businessValidRequestAfterAllDataReceived(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected void getFile(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected void delete(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected void post(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected void postChunk(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpContent chunk) throws HttpIncorrectRequestException
ctx
- chunk
- 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
protected void readHttpDataAllReceive(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected void readHttpDataChunkByChunk(io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
ctx
- HttpIncorrectRequestException
protected void readHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData data, io.netty.channel.ChannelHandlerContext ctx) throws HttpIncorrectRequestException
data
- ctx
- HttpIncorrectRequestException
protected String getNewCookieSession()
protected void createNewSessionAtConnection(io.netty.channel.ChannelHandlerContext ctx)
ctx
- Copyright © 2009–2020 Waarp. All rights reserved.