@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, read
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, isSharable
protected 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.ChannelOutboundHandler
write
in class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
ctx
- 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.ChannelInboundHandler
channelActive
in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
ctx
- the channel handler context.Exception
public 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.ChannelInboundHandler
channelRead
in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
ctx
- 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.ChannelHandler
handlerAdded
in class com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter
ctx
- 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.ChannelInboundHandler
channelInactive
in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
public void handlerRemoved(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)
handlerRemoved
in interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandler
handlerRemoved
in class com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter
ctx
- the channel handler context.Copyright © 2020 Couchbase, Inc.. All rights reserved.