Class NonChunkedHttpMessageHandler
java.lang.Object
com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter
com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
com.couchbase.client.core.io.netty.NonChunkedHttpMessageHandler
- All Implemented Interfaces:
com.couchbase.client.core.deps.io.netty.channel.ChannelHandler,com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler,com.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler
- Direct Known Subclasses:
NonChunkedEventingMessageHandler
@Sharable
public abstract class NonChunkedHttpMessageHandler
extends com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
This message handler can be considered the opposite of the
ChunkedMessageHandler.
This generic implementation makes sure that when it lives in the pipeline it also pulls in the http aggregator and sends full http requests / receives full http responses.
You usually want to add this handler for non-perf critical messages like creating indexes and similar, so their encoder and decoder implementations are considerably simpler than having to deal with chunking and a streaming parser.
- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandler
com.couchbase.client.core.deps.io.netty.channel.ChannelHandler.Sharable -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNonChunkedHttpMessageHandler(BaseEndpoint endpoint, ServiceType serviceType) -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) When this channel is marked active it also needs to propagate that to the aggregator.voidchannelInactive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) voidchannelRead(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg) Parses the full http response and sends it to decode into the request.protected ExceptionfailRequestWith(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponseStatus status, String content, NonChunkedHttpRequest<Response> request) To be implemented by children, should return the proper service exception type for each.voidhandlerAdded(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) When the non-chunked handler is added, it also needs to add the http aggregator.voidhandlerRemoved(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) When the non-chunked handler is removed, it also needs to remove its http aggregator.voidwrite(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg, com.couchbase.client.core.deps.io.netty.channel.ChannelPromise promise) Writes a given request and encodes it.Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
IDENTIFIER
-
-
Constructor Details
-
NonChunkedHttpMessageHandler
-
-
Method Details
-
failRequestWith
protected Exception failRequestWith(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponseStatus status, String content, NonChunkedHttpRequest<Response> request) To be implemented by children, should return the proper service exception type for each.- Parameters:
content- the raw full content body of the response if not successful.- Returns:
- the exception with which the request will be failed.
-
write
public void write(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg, com.couchbase.client.core.deps.io.netty.channel.ChannelPromise promise) Writes a given request and encodes it.- Specified by:
writein interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler- Overrides:
writein classcom.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler- Parameters:
ctx- the channel handler context.msg- the msg to write.promise- the promise that will be passed along.
-
channelActive
public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) throws Exception When this channel is marked active it also needs to propagate that to the aggregator.- Specified by:
channelActivein interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- the channel handler context.- Throws:
Exception
-
channelRead
public void channelRead(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg) Parses the full http response and sends it to decode into the request.- Specified by:
channelReadin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- the channel handler context.msg- the FullHttpResponse from the server.
-
handlerAdded
public void handlerAdded(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) When the non-chunked handler is added, it also needs to add the http aggregator.- Specified by:
handlerAddedin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelHandler- Overrides:
handlerAddedin classcom.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter- Parameters:
ctx- the channel handler context.
-
channelInactive
public void channelInactive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelInactivein interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
-
handlerRemoved
public void handlerRemoved(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) When the non-chunked handler is removed, it also needs to remove its http aggregator.- Specified by:
handlerRemovedin interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classcom.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter- Parameters:
ctx- the channel handler context.
-