Motivation: Parameter name is confusing and not match the actual type. Modification: Rename parameter. Result: Code cleanup
This commit is contained in:
parent
4a8476af67
commit
0611683106
|
@ -132,15 +132,15 @@ public class HttpContentCompressor extends HttpContentEncoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Result beginEncode(HttpResponse headers, String acceptEncoding) throws Exception {
|
protected Result beginEncode(HttpResponse httpResponse, String acceptEncoding) throws Exception {
|
||||||
if (this.contentSizeThreshold > 0) {
|
if (this.contentSizeThreshold > 0) {
|
||||||
if (headers instanceof HttpContent &&
|
if (httpResponse instanceof HttpContent &&
|
||||||
((HttpContent) headers).content().readableBytes() < contentSizeThreshold) {
|
((HttpContent) httpResponse).content().readableBytes() < contentSizeThreshold) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String contentEncoding = headers.headers().get(HttpHeaderNames.CONTENT_ENCODING);
|
String contentEncoding = httpResponse.headers().get(HttpHeaderNames.CONTENT_ENCODING);
|
||||||
if (contentEncoding != null) {
|
if (contentEncoding != null) {
|
||||||
// Content-Encoding was set, either as something specific or as the IDENTITY encoding
|
// Content-Encoding was set, either as something specific or as the IDENTITY encoding
|
||||||
// Therefore, we should NOT encode here
|
// Therefore, we should NOT encode here
|
||||||
|
|
|
@ -289,8 +289,8 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpReque
|
||||||
/**
|
/**
|
||||||
* Prepare to encode the HTTP message content.
|
* Prepare to encode the HTTP message content.
|
||||||
*
|
*
|
||||||
* @param headers
|
* @param httpResponse
|
||||||
* the headers
|
* the http response
|
||||||
* @param acceptEncoding
|
* @param acceptEncoding
|
||||||
* the value of the {@code "Accept-Encoding"} header
|
* the value of the {@code "Accept-Encoding"} header
|
||||||
*
|
*
|
||||||
|
@ -300,7 +300,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpReque
|
||||||
* {@code null} if {@code acceptEncoding} is unsupported or rejected
|
* {@code null} if {@code acceptEncoding} is unsupported or rejected
|
||||||
* and thus the content should be handled as-is (i.e. no encoding).
|
* and thus the content should be handled as-is (i.e. no encoding).
|
||||||
*/
|
*/
|
||||||
protected abstract Result beginEncode(HttpResponse headers, String acceptEncoding) throws Exception;
|
protected abstract Result beginEncode(HttpResponse httpResponse, String acceptEncoding) throws Exception;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class HttpContentEncoderTest {
|
||||||
|
|
||||||
private static final class TestEncoder extends HttpContentEncoder {
|
private static final class TestEncoder extends HttpContentEncoder {
|
||||||
@Override
|
@Override
|
||||||
protected Result beginEncode(HttpResponse headers, String acceptEncoding) {
|
protected Result beginEncode(HttpResponse httpResponse, String acceptEncoding) {
|
||||||
return new Result("test", new EmbeddedChannel(new MessageToByteEncoder<ByteBuf>() {
|
return new Result("test", new EmbeddedChannel(new MessageToByteEncoder<ByteBuf>() {
|
||||||
@Override
|
@Override
|
||||||
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception {
|
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception {
|
||||||
|
@ -395,7 +395,7 @@ public class HttpContentEncoderTest {
|
||||||
public void testCleanupThrows() {
|
public void testCleanupThrows() {
|
||||||
HttpContentEncoder encoder = new HttpContentEncoder() {
|
HttpContentEncoder encoder = new HttpContentEncoder() {
|
||||||
@Override
|
@Override
|
||||||
protected Result beginEncode(HttpResponse headers, String acceptEncoding) throws Exception {
|
protected Result beginEncode(HttpResponse httpResponse, String acceptEncoding) throws Exception {
|
||||||
return new Result("myencoding", new EmbeddedChannel(
|
return new Result("myencoding", new EmbeddedChannel(
|
||||||
new ChannelHandler() {
|
new ChannelHandler() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user