public interface RequestHandle extends Request
Request and provides the guiding to handle the coming request.
When the RequestHandle is coming, current Request may have not been ended, which means the request
line and the request headers is coming and decoded as a instance of RequestHandle but the body(if present)
and trailing headers(if present) have not been received, and next you may want to handle them via onData(Consumer), onTrailer(Consumer), onEnd(Function)...
!Note: This class is not designed as thread-safe, please handing requests in current thread(probably the EventLoop),
because it is in unfinished state before calling onEnd(Function) method, so you can use the Request.aggregated() and Request.multipart() in onEnd(Function) or use it after Request.isEnded() returns true
| 限定符和类型 | 方法和说明 |
|---|---|
RequestHandle |
aggregate(boolean aggregate)
Request.aggregated() could be used after request is ended, which means you can get a completed request such as
using the Request.aggregated() in handle onEnd(Function). |
RequestHandle |
multipart(boolean expect)
Request.multipart() could be used after request is ended, which means you can get a completed request that
multipart contents have already been decoded such as using the Request.aggregated() in handle onEnd(Function). |
RequestHandle |
onData(Consumer<io.netty.buffer.ByteBuf> h)
Sets a handler to handle the coming http body.
|
RequestHandle |
onEnd(Function<io.netty.util.concurrent.Promise<Void>,io.netty.util.concurrent.Future<Void>> h)
Sets a handler to handle this request when current request has been decoded completely.
|
RequestHandle |
onError(Consumer<Throwable> h)
Sets a handler to handle unexpected error.
|
RequestHandle |
onTrailer(Consumer<esa.commons.http.HttpHeaders> h)
Sets a handler to handle the coming tailing headers.
|
cookies, getCookie, getParam, getParams, headers, localAddress, method, paramMap, path, query, rawMethod, remoteAddress, scheme, tcpSourceAddress, uri, versionRequestHandle onData(Consumer<io.netty.buffer.ByteBuf> h)
The handle set would not be called if there's no http body data.
h - handlerRequestHandle onTrailer(Consumer<esa.commons.http.HttpHeaders> h)
The handle set would not be called if there's no tailing headers.
h - handlerRequestHandle aggregate(boolean aggregate)
Request.aggregated() could be used after request is ended, which means you can get a completed request such as
using the Request.aggregated() in handle onEnd(Function).aggregate - whether request aggregation is expectedRequestHandle multipart(boolean expect)
Request.multipart() could be used after request is ended, which means you can get a completed request that
multipart contents have already been decoded such as using the Request.aggregated() in handle onEnd(Function). It would be useful if there's large upload files in this request.expect - whether multipart is expectedRequestHandle onEnd(Function<io.netty.util.concurrent.Promise<Void>,io.netty.util.concurrent.Future<Void>> h)
Only one of the following handler will be called for each request except that there's something wrong with the onEnd handler(eg. throw an exception)
onEnd(Function)onError(Consumer)h - handlerRequestHandle onError(Consumer<Throwable> h)
Only one of the following handler will be called for each request except that there's something wrong with the onEnd handler(eg. throw an exception)
onEnd(Function)onError(Consumer)h - handlerCopyright © 2020. All rights reserved.