Allow to set Http2HeaderEncoder.SensitivityDetector in the Http2ConnectionHandler
Motivation: Some times the user wants to set a Http2HeaderEncoder.SensitivityDetector when building a Http2ConnectionHandler. Modifications: Allow to set Http2HeaderEncoder.SensitivityDetector via builder. Result: More flexible building of Http2ConnectionHandler possible.
This commit is contained in:
parent
f31be51774
commit
f4386fb8e9
@ -78,6 +78,7 @@ public class DefaultHttp2FrameReader implements Http2FrameReader, Http2FrameSize
|
||||
/**
|
||||
* Create a new instance.
|
||||
* @param validateHeaders {@code true} to validate headers. {@code false} to not validate headers.
|
||||
* @see {@link DefaultHttp2HeadersDecoder(boolean)}
|
||||
*/
|
||||
public DefaultHttp2FrameReader(boolean validateHeaders) {
|
||||
this(new DefaultHttp2HeadersDecoder(validateHeaders));
|
||||
|
@ -84,6 +84,10 @@ public class DefaultHttp2FrameWriter implements Http2FrameWriter, Http2FrameSize
|
||||
this(new DefaultHttp2HeadersEncoder());
|
||||
}
|
||||
|
||||
public DefaultHttp2FrameWriter(Http2HeadersEncoder.SensitivityDetector headersSensativityDetector) {
|
||||
this(new DefaultHttp2HeadersEncoder(Http2CodecUtil.DEFAULT_HEADER_TABLE_SIZE, headersSensativityDetector));
|
||||
}
|
||||
|
||||
public DefaultHttp2FrameWriter(Http2HeadersEncoder headersEncoder) {
|
||||
this.headersEncoder = headersEncoder;
|
||||
maxFrameSize = DEFAULT_MAX_FRAME_SIZE;
|
||||
|
@ -92,6 +92,8 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
||||
private Http2Settings initialSettings = new Http2Settings();
|
||||
private Http2FrameListener frameListener;
|
||||
private Http2FrameLogger frameLogger;
|
||||
private Http2HeadersEncoder.SensitivityDetector headersSensativityDetector =
|
||||
Http2HeadersEncoder.NEVER_SENSITIVE;
|
||||
private boolean validateHeaders = true;
|
||||
private boolean server = true;
|
||||
private boolean encoderEnforceMaxConcurrentStreams;
|
||||
@ -169,6 +171,14 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
||||
return thisB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link Http2HeadersEncoder.SensitivityDetector} that will be used.
|
||||
*/
|
||||
public B headersSensativityDetector(Http2HeadersEncoder.SensitivityDetector headersSensativityDetector) {
|
||||
this.headersSensativityDetector = checkNotNull(headersSensativityDetector, "headersSensativityDetector");
|
||||
return thisB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Http2Connection} and build a new instance.
|
||||
*/
|
||||
@ -184,7 +194,7 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
||||
*/
|
||||
public final T build(Http2Connection connection) {
|
||||
Http2FrameReader reader = new DefaultHttp2FrameReader(validateHeaders);
|
||||
Http2FrameWriter writer = new DefaultHttp2FrameWriter();
|
||||
Http2FrameWriter writer = new DefaultHttp2FrameWriter(headersSensativityDetector);
|
||||
if (frameLogger != null) {
|
||||
reader = new Http2InboundFrameLogger(reader, frameLogger);
|
||||
writer = new Http2OutboundFrameLogger(writer, frameLogger);
|
||||
@ -208,9 +218,13 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http
|
||||
* Build a new instance with an existing {@link Http2ConnectionDecoder} and {@link Http2ConnectionEncoder}.
|
||||
* <p>
|
||||
* Methods that will be ignored due to objects already being created:
|
||||
* <ul><li>{@link #server(boolean)}</li><li>
|
||||
* {@link #frameLogger(Http2FrameLogger)}</li><li>{@link #encoderEnforceMaxConcurrentStreams(boolean)}</li><li>
|
||||
* {@link #encoderEnforceMaxConcurrentStreams(boolean)} (int)}</li></ul>
|
||||
* <ul>
|
||||
* <li>{@link #server(boolean)}</li>
|
||||
* <li>{@link #frameLogger(Http2FrameLogger)}</li>
|
||||
* <li>{@link #encoderEnforceMaxConcurrentStreams(boolean)}</li>
|
||||
* <li>{@link #encoderEnforceMaxConcurrentStreams(boolean)} (int)}</li>
|
||||
* <li>{@link #headersSensativityDetector(Http2HeadersEncoder.SensitivityDetector)}</li>
|
||||
* </ul>
|
||||
*/
|
||||
public final T build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder) {
|
||||
final T handler;
|
||||
|
Loading…
x
Reference in New Issue
Block a user