Add the encoder/decoder getter methods to HttpClientCodec
Motivation: There's no way for a user to get the encoder and the decoder of an HttpClientCodec. The lack of such getter methods makes it impossible to remove the codec handlers from the pipeline correctly. For example, a user could add more than one HttpClientCodec to the pipeline, and then the user cannot easily decide which encoder and decoder to remove. Modifications: - Add encoder() and decoder() method to HttpClientCodec which returns HttpRequestEncoder and HttpResponseDecoder respectively - Also made the same changes to HttpServerCodec Result: A user can distinguish the handlers added by multiple HttpClientCodecs easily.
This commit is contained in:
parent
a64484249c
commit
4a45d23129
@ -86,7 +86,17 @@ public final class HttpClientCodec extends ChannelHandlerAppender {
|
||||
this.failOnMissingResponse = failOnMissingResponse;
|
||||
}
|
||||
|
||||
private Decoder decoder() {
|
||||
/**
|
||||
* Returns the encoder of this codec.
|
||||
*/
|
||||
public HttpRequestEncoder encoder() {
|
||||
return handlerAt(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the decoder of this codec.
|
||||
*/
|
||||
public HttpResponseDecoder decoder() {
|
||||
return handlerAt(0);
|
||||
}
|
||||
|
||||
|
@ -49,4 +49,18 @@ public final class HttpServerCodec extends ChannelHandlerAppender {
|
||||
super(new HttpRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders),
|
||||
new HttpResponseEncoder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the encoder of this codec.
|
||||
*/
|
||||
public HttpResponseEncoder encoder() {
|
||||
return handlerAt(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the decoder of this codec.
|
||||
*/
|
||||
public HttpRequestDecoder decoder() {
|
||||
return handlerAt(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user