DefaultHttpContent instead of HttpResponse in netty 4.0.23 -
i have following pipeline configuration http client -
pipeline.addlast("ssl", new sslhandler()); pipeline.addlast("decoder", new httpresponsedecoder()); pipeline.addlast("encoder", new httprequestencoder()); pipeline.addlast("handler", new mysimplechannelinboundhandler());
in mysimplechannelinboundhandler
's channelread0()
method, instance of defaulthttpcontent
instead of httpresponse
. when log defaulthttpcontent
's content using -
defaulthttpcontent content = (defaulthttpcontent) msg; log.debug(content.content().tostring(charsetutil.utf_8));
i can see actual http response being logged.
why http response not being decoded httpresponse
object though have http decoder in pipeline?
thanks!
use httpobjectaggregator
before enc/decoders in order aggregate httpresponse , following httpcontents. after adding httpobjectaggregator
in pipeline you'll fullhttpresponse
object in handler.
eg : p.addlast("aggregator", new httpobjectaggregator(1048576));
one more thing, if not implementing own enc/decoders client, can netty's provided httpclientcodec
Comments
Post a Comment