@UnstableApi public class CompressorHttp2ConnectionEncoder extends DecoratingHttp2ConnectionEncoder
content-encoding
header for each
stream. The compression provided by this class will be applied to the data for the entire stream.Http2FrameWriter.Configuration
限定符和类型 | 字段和说明 |
---|---|
static int |
DEFAULT_COMPRESSION_LEVEL |
static int |
DEFAULT_MEM_LEVEL |
static int |
DEFAULT_WINDOW_BITS |
构造器和说明 |
---|
CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate)
Create a new
CompressorHttp2ConnectionEncoder instance
with default implementation of StandardCompressionOptions |
CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate,
CompressionOptions... compressionOptionsArgs)
Create a new
CompressorHttp2ConnectionEncoder with
specified StandardCompressionOptions |
CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate,
int compressionLevel,
int windowBits,
int memLevel)
已过时。
|
限定符和类型 | 方法和说明 |
---|---|
protected java.lang.CharSequence |
getTargetContentEncoding(java.lang.CharSequence contentEncoding)
Returns the expected content encoding of the decoded content.
|
protected EmbeddedChannel |
newContentCompressor(ChannelHandlerContext ctx,
java.lang.CharSequence contentEncoding)
Returns a new
EmbeddedChannel that encodes the HTTP2 message content encoded in the specified
contentEncoding . |
ChannelFuture |
writeData(ChannelHandlerContext ctx,
int streamId,
ByteBuf data,
int padding,
boolean endOfStream,
ChannelPromise promise)
Writes a
DATA frame to the remote endpoint. |
ChannelFuture |
writeHeaders(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int padding,
boolean endStream,
ChannelPromise promise)
Writes a HEADERS frame to the remote endpoint.
|
ChannelFuture |
writeHeaders(ChannelHandlerContext ctx,
int streamId,
Http2Headers headers,
int streamDependency,
short weight,
boolean exclusive,
int padding,
boolean endOfStream,
ChannelPromise promise)
Writes a HEADERS frame with priority specified to the remote endpoint.
|
connection, consumeReceivedSettings, flowController, frameWriter, lifecycleManager, pollSentSettings, remoteSettings
close, configuration, writeFrame, writeGoAway, writePing, writePriority, writePushPromise, writeRstStream, writeSettings, writeSettingsAck, writeWindowUpdate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
writeFrame
close, configuration, writeGoAway, writePing, writePriority, writePushPromise, writeRstStream, writeSettings, writeSettingsAck, writeWindowUpdate
public static final int DEFAULT_COMPRESSION_LEVEL
public static final int DEFAULT_WINDOW_BITS
public static final int DEFAULT_MEM_LEVEL
public CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate)
CompressorHttp2ConnectionEncoder
instance
with default implementation of StandardCompressionOptions
@Deprecated public CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate, int compressionLevel, int windowBits, int memLevel)
CompressorHttp2ConnectionEncoder
instancepublic CompressorHttp2ConnectionEncoder(Http2ConnectionEncoder delegate, CompressionOptions... compressionOptionsArgs)
CompressorHttp2ConnectionEncoder
with
specified StandardCompressionOptions
public ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream, ChannelPromise promise)
Http2DataWriter
DATA
frame to the remote endpoint. This will result in one or more
frames being written to the context.writeData
在接口中 Http2DataWriter
writeData
在类中 DecoratingHttp2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.data
- the payload of the frame. This will be released by this method.padding
- additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive). A 1 byte padding is encoded as just the pad length field with value 0.
A 256 byte padding is encoded as the pad length field with value 255 and 255 padding bytes
appended to the end of the frame.endOfStream
- indicates if this is the last frame to be sent for the stream.promise
- the promise for the write.public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, ChannelPromise promise)
Http2FrameWriter
writeHeaders
在接口中 Http2FrameWriter
writeHeaders
在类中 DecoratingHttp2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.headers
- the headers to be sent.padding
- additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).endStream
- indicates if this is the last frame to be sent for the stream.promise
- the promise for the write.The header block MUST be processed to ensure a consistent connection state, unless the connection is closed.If this call has modified the HPACK header state you MUST throw a connection error.
If this call has NOT modified the HPACK header state you are free to throw a stream error.
public ChannelFuture writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endOfStream, ChannelPromise promise)
Http2FrameWriter
writeHeaders
在接口中 Http2FrameWriter
writeHeaders
在类中 DecoratingHttp2FrameWriter
ctx
- the context to use for writing.streamId
- the stream for which to send the frame.headers
- the headers to be sent.streamDependency
- the stream on which this stream should depend, or 0 if it should
depend on the connection.weight
- the weight for this stream.exclusive
- whether this stream should be the exclusive dependant of its parent.padding
- additional bytes that should be added to obscure the true content size. Must be between 0 and
256 (inclusive).endOfStream
- indicates if this is the last frame to be sent for the stream.promise
- the promise for the write.The header block MUST be processed to ensure a consistent connection state, unless the connection is closed.If this call has modified the HPACK header state you MUST throw a connection error.
If this call has NOT modified the HPACK header state you are free to throw a stream error.
protected EmbeddedChannel newContentCompressor(ChannelHandlerContext ctx, java.lang.CharSequence contentEncoding) throws Http2Exception
EmbeddedChannel
that encodes the HTTP2 message content encoded in the specified
contentEncoding
.ctx
- the context.contentEncoding
- the value of the content-encoding
headerByteToMessageDecoder
if the specified encoding is supported. null
otherwise
(alternatively, you can throw a Http2Exception
to block unknown encoding).Http2Exception
- If the specified encoding is not supported and warrants an exceptionprotected java.lang.CharSequence getTargetContentEncoding(java.lang.CharSequence contentEncoding) throws Http2Exception
contentEncoding
is the default
behavior, which is the case for most compressors.contentEncoding
- the value of the content-encoding
headerHttp2Exception
- if the contentEncoding
is not supported and warrants an exception