Class HttpStreamsClientHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.ChannelDuplexHandler
-
- software.amazon.awssdk.http.nio.netty.internal.nrs.HttpStreamsClientHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public class HttpStreamsClientHandler extends io.netty.channel.ChannelDuplexHandlerHandler that converts writtenStreamedHttpRequestmessages intoHttpRequestmessages followed byHttpContentmessages and readsHttpResponsemessages followed byHttpContentmessages and producesStreamedHttpResponsemessages. This allows request and response bodies to be handled using reactive streams. There are two types of messages that this handler accepts for writing,StreamedHttpRequestandFullHttpRequest. Writing any other messages may potentially lead to HTTP message mangling. There are two types of messages that this handler will send down the chain,StreamedHttpResponse, andFullHttpResponse. IfChannelOption.AUTO_READis false for the channel, then anyStreamedHttpResponsemessages must be subscribed to consume the body, otherwise it's possible that no read will be done of the messages. As long as messages are returned in the order that they arrive, this handler implicitly supports HTTP pipelining. This class contains source imported from https://github.com/playframework/netty-reactive-streams, licensed under the Apache License 2.0, available at the time of the fork (1/31/2020) here: https://github.com/playframework/netty-reactive-streams/blob/master/LICENSE.txt All original source licensed under the Apache License 2.0 by playframework. All modifications are licensed under the Apache License 2.0 by Amazon Web Services.
-
-
Constructor Summary
Constructors Constructor Description HttpStreamsClientHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbodyRequested(io.netty.channel.ChannelHandlerContext ctx)Invoked every time a read of the incoming body is requested by the subscriber.voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)voidchannelReadComplete(io.netty.channel.ChannelHandlerContext ctx)voidclose(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise future)protected voidconsumedInMessage(io.netty.channel.ChannelHandlerContext ctx)Invoked when an incoming message is fully consumed.protected io.netty.handler.codec.http.HttpResponsecreateEmptyMessage(io.netty.handler.codec.http.HttpResponse response)Create an empty incoming message.protected io.netty.handler.codec.http.HttpResponsecreateStreamedMessage(io.netty.handler.codec.http.HttpResponse response, org.reactivestreams.Publisher<io.netty.handler.codec.http.HttpContent> stream)Create a streamed incoming message with the given stream.protected booleanhasBody(io.netty.handler.codec.http.HttpResponse response)Whether the given incoming message has a body.protected voidreceivedInMessage(io.netty.channel.ChannelHandlerContext ctx)Invoked when an incoming message is first received.protected voidreceivedOutMessage(io.netty.channel.ChannelHandlerContext ctx)Invoked when an outgoing message is first received.protected voidsentOutMessage(io.netty.channel.ChannelHandlerContext ctx)Invoked when an outgoing message is fully sent.protected voidsubscribeSubscriberToStream(StreamedHttpMessage msg, org.reactivestreams.Subscriber<io.netty.handler.codec.http.HttpContent> subscriber)Subscribe the given subscriber to the given streamed message.protected voidunbufferedWrite(io.netty.channel.ChannelHandlerContext ctx, software.amazon.awssdk.http.nio.netty.internal.nrs.HttpStreamsHandler.Outgoing out)voidwrite(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)-
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, connect, deregister, disconnect, flush, read
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Method Detail
-
hasBody
protected boolean hasBody(io.netty.handler.codec.http.HttpResponse response)
Whether the given incoming message has a body.
-
close
public void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise future) throws Exception- Specified by:
closein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
closein classio.netty.channel.ChannelDuplexHandler- Throws:
Exception
-
consumedInMessage
protected void consumedInMessage(io.netty.channel.ChannelHandlerContext ctx)
Invoked when an incoming message is fully consumed. Overridden by sub classes for state tracking.
-
receivedOutMessage
protected void receivedOutMessage(io.netty.channel.ChannelHandlerContext ctx)
Invoked when an outgoing message is first received. Overridden by sub classes for state tracking.
-
sentOutMessage
protected void sentOutMessage(io.netty.channel.ChannelHandlerContext ctx)
Invoked when an outgoing message is fully sent. Overridden by sub classes for state tracking.
-
createEmptyMessage
protected io.netty.handler.codec.http.HttpResponse createEmptyMessage(io.netty.handler.codec.http.HttpResponse response)
Create an empty incoming message. This must be of type FullHttpMessage, and is invoked when we've determined that an incoming message can't have a body, so we send it on as a FullHttpMessage.
-
createStreamedMessage
protected io.netty.handler.codec.http.HttpResponse createStreamedMessage(io.netty.handler.codec.http.HttpResponse response, org.reactivestreams.Publisher<io.netty.handler.codec.http.HttpContent> stream)Create a streamed incoming message with the given stream.
-
subscribeSubscriberToStream
protected void subscribeSubscriberToStream(StreamedHttpMessage msg, org.reactivestreams.Subscriber<io.netty.handler.codec.http.HttpContent> subscriber)
Subscribe the given subscriber to the given streamed message. Provided so that the client subclass can intercept this to hold off sending the body of an expect 100 continue request.
-
channelRead
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Throws:
Exception
-
receivedInMessage
protected void receivedInMessage(io.netty.channel.ChannelHandlerContext ctx)
Invoked when an incoming message is first received. Overridden by sub classes for state tracking.
-
bodyRequested
protected void bodyRequested(io.netty.channel.ChannelHandlerContext ctx)
Invoked every time a read of the incoming body is requested by the subscriber. Provided so that the server subclass can intercept this to send a 100 continue response.
-
channelReadComplete
public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelReadCompletein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadCompletein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception- Specified by:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelDuplexHandler- Throws:
Exception
-
unbufferedWrite
protected void unbufferedWrite(io.netty.channel.ChannelHandlerContext ctx, software.amazon.awssdk.http.nio.netty.internal.nrs.HttpStreamsHandler.Outgoing out)
-
-