public class HttpContentCompressor extends HttpContentEncoder
gzip或deflate编码中压缩HttpMessage和HttpContent ,同时考虑"Accept-Encoding"标头。
如果没有匹配的编码,则不进行压缩。
有关此处理程序如何修改消息的更多信息,请参阅HttpContentEncoder 。
HttpContentEncoder.ResultChannelHandler.Sharable| Constructor and Description |
|---|
HttpContentCompressor()
使用默认压缩级别(
6 ),默认窗口大小(
15 )和默认内存级别(
8 )创建新的处理程序。
|
HttpContentCompressor(int compressionLevel)
创建具有指定压缩级别,默认窗口大小(
15 )和默认内存级别(
8 )的新处理程序。
|
HttpContentCompressor(int compressionLevel, int windowBits, int memLevel)
用指定的压缩级别,窗口大小和内存级别创建一个新的处理程序。
|
| Modifier and Type | Method and Description |
|---|---|
protected HttpContentEncoder.Result |
beginEncode(HttpResponse headers, java.lang.String acceptEncoding)
准备编码HTTP消息内容。
|
protected ZlibWrapper |
determineWrapper(java.lang.String acceptEncoding) |
void |
handlerAdded(ChannelHandlerContext ctx)
子类可以忽略这个方法。
|
acceptOutboundMessage, channelInactive, decode, encode, handlerRemovedacceptInboundMessage, channelRead, writebind, close, connect, deregister, disconnect, flush, readchannelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexceptionCaughtpublic HttpContentCompressor()
public HttpContentCompressor(int compressionLevel)
compressionLevel - 1产生最快的压缩率, 9产生最好的压缩率。
0意味着没有压缩。
默认的压缩级别是6 。
public HttpContentCompressor(int compressionLevel,
int windowBits,
int memLevel)
compressionLevel - 1产生最快的压缩率, 9产生最好的压缩率。
0表示不压缩。
默认的压缩级别是6 。
windowBits - 历史缓冲区大小的基础两倍对数。
该值应该在9到15含)。
较大的值会导致更好的压缩,但会以内存使用量为代价。
默认值是15 。
memLevel - 应为内部压缩状态分配多少内存。
1使用最小内存, 9使用最大内存。
较大的值会导致更好更快的压缩,但会以内存使用量为代价。
默认值是8
public void handlerAdded(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelHandlerAdapter
handlerAdded接口
ChannelHandler
handlerAdded在课堂
ChannelHandlerAdapter
java.lang.Exception
protected HttpContentEncoder.Result beginEncode(HttpResponse headers, java.lang.String acceptEncoding) throws java.lang.Exception
HttpContentEncoder
beginEncode在课程
HttpContentEncoder
headers - 标题
acceptEncoding -
"Accept-Encoding"标题的值
EmbeddedChannel组成。
null如果acceptEncoding不支持或被拒绝,因此内容应按原样处理(即不编码)。
java.lang.Exception
protected ZlibWrapper determineWrapper(java.lang.String acceptEncoding)
Copyright © 2008–2018 The Netty Project. All rights reserved.