@ChannelHandler.Sharable
public abstract class NonChunkedHttpMessageHandler
extends com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
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.
| Modifier | Constructor and Description |
|---|---|
protected |
NonChunkedHttpMessageHandler(BaseEndpoint endpoint,
ServiceType serviceType) |
| Modifier and Type | Method and Description |
|---|---|
void |
channelActive(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.
|
void |
channelInactive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx) |
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.
|
protected abstract Exception |
failRequestWith(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponseStatus status,
String content)
To be implemented by children, should return the proper service exception type for each.
|
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.
|
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.
|
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.
|
bind, close, connect, deregister, disconnect, flush, readchannelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, isSharableprotected NonChunkedHttpMessageHandler(BaseEndpoint endpoint, ServiceType serviceType)
protected abstract Exception failRequestWith(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponseStatus status, String content)
content - the raw full content body of the response if not successful.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)
write in interface com.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandlerwrite in class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandlerctx - the channel handler context.msg - the msg to write.promise - the promise that will be passed along.public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelActive in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerchannelActive in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapterctx - the channel handler context.Exceptionpublic void channelRead(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx,
Object msg)
channelRead in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerchannelRead in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapterctx - the channel handler context.msg - the FullHttpResponse from the server.public void handlerAdded(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)
handlerAdded in interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerhandlerAdded in class com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapterctx - the channel handler context.public void channelInactive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)
channelInactive in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerchannelInactive in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapterpublic void handlerRemoved(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)
handlerRemoved in interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerhandlerRemoved in class com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapterctx - the channel handler context.Copyright © 2021 Couchbase, Inc.. All rights reserved.