public class HttpStreamsServerHandler
extends io.netty.channel.ChannelDuplexHandler
HttpRequest messages followed by HttpContent messages and produces
StreamedHttpRequest messages, and converts written StreamedHttpResponse messages into
HttpResponse messages followed by HttpContent messages.
This allows request and response bodies to be handled using reactive streams.
There are two types of messages that this handler will send down the chain, StreamedHttpRequest,
and FullHttpRequest. If ChannelOption.AUTO_READ is false for the channel,
then any StreamedHttpRequest messages must be subscribed to consume the body, otherwise
it's possible that no read will be done of the messages.
There are three types of messages that this handler accepts for writing, StreamedHttpResponse,
WebSocketHttpResponse and FullHttpResponse. Writing any other messages may potentially
lead to HTTP message mangling.
As long as messages are returned in the order that they arrive, this handler implicitly supports HTTP
pipelining.| Constructor and Description |
|---|
HttpStreamsServerHandler() |
HttpStreamsServerHandler(List<io.netty.channel.ChannelHandler> dependentHandlers)
Create a new handler that is depended on by the given handlers.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
bodyRequested(io.netty.channel.ChannelHandlerContext ctx)
Invoked every time a read of the incoming body is requested by the subscriber.
|
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) |
protected void |
consumedInMessage(io.netty.channel.ChannelHandlerContext ctx)
Invoked when an incoming message is fully consumed.
|
protected io.netty.handler.codec.http.HttpRequest |
createEmptyMessage(io.netty.handler.codec.http.HttpRequest request)
Create an empty incoming message.
|
protected io.netty.handler.codec.http.HttpRequest |
createStreamedMessage(io.netty.handler.codec.http.HttpRequest httpRequest,
org.reactivestreams.Publisher<io.netty.handler.codec.http.HttpContent> stream)
Create a streamed incoming message with the given stream.
|
void |
handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) |
protected boolean |
hasBody(io.netty.handler.codec.http.HttpRequest request)
Whether the given incoming message has a body.
|
protected void |
receivedInMessage(io.netty.channel.ChannelHandlerContext ctx)
Invoked when an incoming message is first received.
|
protected void |
receivedOutMessage(io.netty.channel.ChannelHandlerContext ctx)
Invoked when an outgoing message is first received.
|
protected void |
sentOutMessage(io.netty.channel.ChannelHandlerContext ctx)
Invoked when an outgoing message is fully sent.
|
protected void |
subscribeSubscriberToStream(StreamedHttpMessage msg,
org.reactivestreams.Subscriber<io.netty.handler.codec.http.HttpContent> subscriber)
Subscribe the given subscriber to the given streamed message.
|
protected void |
unbufferedWrite(io.netty.channel.ChannelHandlerContext ctx,
com.typesafe.netty.http.HttpStreamsHandler.Outgoing out) |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
bind, close, connect, deregister, disconnect, flush, readchannelActive, channelInactive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, handlerAdded, isSharablepublic HttpStreamsServerHandler()
public HttpStreamsServerHandler(List<io.netty.channel.ChannelHandler> dependentHandlers)
dependentHandlers - The handlers that depend on this handler.protected boolean hasBody(io.netty.handler.codec.http.HttpRequest request)
protected io.netty.handler.codec.http.HttpRequest createEmptyMessage(io.netty.handler.codec.http.HttpRequest request)
protected io.netty.handler.codec.http.HttpRequest createStreamedMessage(io.netty.handler.codec.http.HttpRequest httpRequest,
org.reactivestreams.Publisher<io.netty.handler.codec.http.HttpContent> stream)
public void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
channelRead in interface io.netty.channel.ChannelInboundHandlerExceptionprotected void receivedInMessage(io.netty.channel.ChannelHandlerContext ctx)
protected void sentOutMessage(io.netty.channel.ChannelHandlerContext ctx)
protected void unbufferedWrite(io.netty.channel.ChannelHandlerContext ctx,
com.typesafe.netty.http.HttpStreamsHandler.Outgoing out)
protected void consumedInMessage(io.netty.channel.ChannelHandlerContext ctx)
protected void bodyRequested(io.netty.channel.ChannelHandlerContext ctx)
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerRemoved in interface io.netty.channel.ChannelHandlerhandlerRemoved in class io.netty.channel.ChannelHandlerAdapterExceptionprotected void receivedOutMessage(io.netty.channel.ChannelHandlerContext ctx)
protected void subscribeSubscriberToStream(StreamedHttpMessage msg, org.reactivestreams.Subscriber<io.netty.handler.codec.http.HttpContent> subscriber)
public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelReadComplete in interface io.netty.channel.ChannelInboundHandlerchannelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapterExceptionCopyright © 2015–2019 Typesafe. All rights reserved.