Rename DecodeResult to DecoderResult
This commit is contained in:
parent
41e0ef2e9a
commit
bf808b3486
@ -15,23 +15,23 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.handler.codec.DecodeResult;
|
||||
import io.netty.handler.codec.DecoderResult;
|
||||
|
||||
public class DefaultHttpObject implements HttpObject {
|
||||
|
||||
private DecodeResult decodeResult = DecodeResult.SUCCESS;
|
||||
private DecoderResult decodeResult = DecoderResult.SUCCESS;
|
||||
|
||||
protected DefaultHttpObject() {
|
||||
// Disallow direct instantiation
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecodeResult getDecodeResult() {
|
||||
public DecoderResult getDecodeResult() {
|
||||
return decodeResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDecodeResult(DecodeResult result) {
|
||||
public void setDecodeResult(DecoderResult result) {
|
||||
if (result == null) {
|
||||
throw new NullPointerException("result");
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ package io.netty.handler.codec.http;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.DecodeResult;
|
||||
import io.netty.handler.codec.DecoderResult;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -106,12 +106,12 @@ public interface HttpChunk extends HttpObject {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecodeResult getDecodeResult() {
|
||||
return DecodeResult.SUCCESS;
|
||||
public DecoderResult getDecodeResult() {
|
||||
return DecoderResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDecodeResult(DecodeResult result) {
|
||||
public void setDecodeResult(DecoderResult result) {
|
||||
throw new IllegalStateException("read-only");
|
||||
}
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.DecodeResult;
|
||||
import io.netty.handler.codec.DecoderResult;
|
||||
import io.netty.handler.codec.ReplayingDecoder;
|
||||
import io.netty.handler.codec.TooLongFrameException;
|
||||
|
||||
@ -459,10 +459,10 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<Object, HttpMe
|
||||
private HttpMessage invalidMessage(Exception cause) {
|
||||
checkpoint(State.BAD_MESSAGE);
|
||||
if (message != null) {
|
||||
message.setDecodeResult(DecodeResult.partialFailure(cause));
|
||||
message.setDecodeResult(DecoderResult.partialFailure(cause));
|
||||
} else {
|
||||
message = createInvalidMessage();
|
||||
message.setDecodeResult(DecodeResult.failure(cause));
|
||||
message.setDecodeResult(DecoderResult.failure(cause));
|
||||
}
|
||||
return message;
|
||||
}
|
||||
@ -470,7 +470,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<Object, HttpMe
|
||||
private HttpChunk invalidChunk(Exception cause) {
|
||||
checkpoint(State.BAD_MESSAGE);
|
||||
HttpChunk chunk = new DefaultHttpChunk(Unpooled.EMPTY_BUFFER);
|
||||
chunk.setDecodeResult(DecodeResult.failure(cause));
|
||||
chunk.setDecodeResult(DecoderResult.failure(cause));
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.handler.codec.DecodeResult;
|
||||
import io.netty.handler.codec.DecoderResult;
|
||||
|
||||
public interface HttpObject {
|
||||
DecodeResult getDecodeResult();
|
||||
void setDecodeResult(DecodeResult result);
|
||||
DecoderResult getDecodeResult();
|
||||
void setDecodeResult(DecoderResult result);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ package io.netty.handler.codec.http;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.embedded.EmbeddedByteChannel;
|
||||
import io.netty.handler.codec.DecodeResult;
|
||||
import io.netty.handler.codec.DecoderResult;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
import java.util.Random;
|
||||
@ -35,7 +35,7 @@ public class HttpInvalidMessageTest {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new HttpRequestDecoder());
|
||||
ch.writeInbound(Unpooled.copiedBuffer("GET / HTTP/1.0 with extra\r\n", CharsetUtil.UTF_8));
|
||||
HttpRequest req = (HttpRequest) ch.readInbound();
|
||||
DecodeResult dr = req.getDecodeResult();
|
||||
DecoderResult dr = req.getDecodeResult();
|
||||
Assert.assertFalse(dr.isSuccess());
|
||||
Assert.assertFalse(dr.isPartial());
|
||||
ensureInboundTrafficDiscarded(ch);
|
||||
@ -49,7 +49,7 @@ public class HttpInvalidMessageTest {
|
||||
ch.writeInbound(Unpooled.copiedBuffer("Bad=Name: Bad Value\r\n", CharsetUtil.UTF_8));
|
||||
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8));
|
||||
HttpRequest req = (HttpRequest) ch.readInbound();
|
||||
DecodeResult dr = req.getDecodeResult();
|
||||
DecoderResult dr = req.getDecodeResult();
|
||||
Assert.assertFalse(dr.isSuccess());
|
||||
Assert.assertTrue(dr.isPartial());
|
||||
Assert.assertEquals("Good Value", req.getHeader("Good_Name"));
|
||||
@ -62,7 +62,7 @@ public class HttpInvalidMessageTest {
|
||||
EmbeddedByteChannel ch = new EmbeddedByteChannel(new HttpResponseDecoder());
|
||||
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.0 BAD_CODE Bad Server\r\n", CharsetUtil.UTF_8));
|
||||
HttpResponse res = (HttpResponse) ch.readInbound();
|
||||
DecodeResult dr = res.getDecodeResult();
|
||||
DecoderResult dr = res.getDecodeResult();
|
||||
Assert.assertFalse(dr.isSuccess());
|
||||
Assert.assertFalse(dr.isPartial());
|
||||
ensureInboundTrafficDiscarded(ch);
|
||||
@ -76,7 +76,7 @@ public class HttpInvalidMessageTest {
|
||||
ch.writeInbound(Unpooled.copiedBuffer("Bad=Name: Bad Value\r\n", CharsetUtil.UTF_8));
|
||||
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.UTF_8));
|
||||
HttpResponse res = (HttpResponse) ch.readInbound();
|
||||
DecodeResult dr = res.getDecodeResult();
|
||||
DecoderResult dr = res.getDecodeResult();
|
||||
Assert.assertFalse(dr.isSuccess());
|
||||
Assert.assertTrue(dr.isPartial());
|
||||
Assert.assertEquals("Maybe OK", res.getStatus().getReasonPhrase());
|
||||
@ -95,7 +95,7 @@ public class HttpInvalidMessageTest {
|
||||
Assert.assertTrue(req.getDecodeResult().isSuccess());
|
||||
|
||||
HttpChunk chunk = (HttpChunk) ch.readInbound();
|
||||
DecodeResult dr = chunk.getDecodeResult();
|
||||
DecoderResult dr = chunk.getDecodeResult();
|
||||
Assert.assertFalse(dr.isSuccess());
|
||||
Assert.assertFalse(dr.isPartial());
|
||||
ensureInboundTrafficDiscarded(ch);
|
||||
|
@ -15,28 +15,28 @@
|
||||
*/
|
||||
package io.netty.handler.codec;
|
||||
|
||||
public class DecodeResult {
|
||||
public class DecoderResult {
|
||||
|
||||
public static final DecodeResult SUCCESS = new DecodeResult(false, null);
|
||||
public static final DecoderResult SUCCESS = new DecoderResult(false, null);
|
||||
|
||||
public static DecodeResult failure(Throwable cause) {
|
||||
public static DecoderResult failure(Throwable cause) {
|
||||
if (cause == null) {
|
||||
throw new NullPointerException("cause");
|
||||
}
|
||||
return new DecodeResult(false, cause);
|
||||
return new DecoderResult(false, cause);
|
||||
}
|
||||
|
||||
public static DecodeResult partialFailure(Throwable cause) {
|
||||
public static DecoderResult partialFailure(Throwable cause) {
|
||||
if (cause == null) {
|
||||
throw new NullPointerException("cause");
|
||||
}
|
||||
return new DecodeResult(true, cause);
|
||||
return new DecoderResult(true, cause);
|
||||
}
|
||||
|
||||
private final boolean partial;
|
||||
private final Throwable cause;
|
||||
|
||||
protected DecodeResult(boolean partial, Throwable cause) {
|
||||
protected DecoderResult(boolean partial, Throwable cause) {
|
||||
if (partial && cause == null) {
|
||||
throw new IllegalArgumentException("successful result cannot be partial.");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user