Maintain decoder result in HttpObjectAggregator
Motivation: DecodeResult is dropped when aggregate HTTP messages. Modification: Make sure we not drop the DecodeResult while aggregate HTTP messages. Result: Correctly include the DecodeResult for later processing.
This commit is contained in:
parent
c8b170e9eb
commit
db3c592e6a
@ -123,7 +123,7 @@ public class HttpObjectAggregator
|
|||||||
HttpRequest req = (HttpRequest) start;
|
HttpRequest req = (HttpRequest) start;
|
||||||
ret = new DefaultFullHttpRequest(req.protocolVersion(),
|
ret = new DefaultFullHttpRequest(req.protocolVersion(),
|
||||||
req.method(), req.uri(), content);
|
req.method(), req.uri(), content);
|
||||||
} else if (start instanceof HttpResponse) {
|
} else if (start instanceof HttpResponse) {
|
||||||
HttpResponse res = (HttpResponse) start;
|
HttpResponse res = (HttpResponse) start;
|
||||||
ret = new DefaultFullHttpResponse(
|
ret = new DefaultFullHttpResponse(
|
||||||
res.protocolVersion(), res.status(), content);
|
res.protocolVersion(), res.status(), content);
|
||||||
@ -132,6 +132,7 @@ public class HttpObjectAggregator
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret.headers().set(start.headers());
|
ret.headers().set(start.headers());
|
||||||
|
ret.setDecoderResult(start.decoderResult());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +306,9 @@ public class HttpObjectAggregatorTest {
|
|||||||
public void testBadRequest() {
|
public void testBadRequest() {
|
||||||
EmbeddedChannel ch = new EmbeddedChannel(new HttpRequestDecoder(), new HttpObjectAggregator(1024 * 1024));
|
EmbeddedChannel ch = new EmbeddedChannel(new HttpRequestDecoder(), new HttpObjectAggregator(1024 * 1024));
|
||||||
ch.writeInbound(Unpooled.copiedBuffer("GET / HTTP/1.0 with extra\r\n", CharsetUtil.UTF_8));
|
ch.writeInbound(Unpooled.copiedBuffer("GET / HTTP/1.0 with extra\r\n", CharsetUtil.UTF_8));
|
||||||
assertThat(ch.readInbound(), is(instanceOf(FullHttpRequest.class)));
|
Object inbound = ch.readInbound();
|
||||||
|
assertThat(inbound, is(instanceOf(FullHttpRequest.class)));
|
||||||
|
assertTrue(((FullHttpRequest) inbound).getDecoderResult().isFailure());
|
||||||
assertNull(ch.readInbound());
|
assertNull(ch.readInbound());
|
||||||
ch.finish();
|
ch.finish();
|
||||||
}
|
}
|
||||||
@ -315,7 +317,9 @@ public class HttpObjectAggregatorTest {
|
|||||||
public void testBadResponse() throws Exception {
|
public void testBadResponse() throws Exception {
|
||||||
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(), new HttpObjectAggregator(1024 * 1024));
|
EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(), new HttpObjectAggregator(1024 * 1024));
|
||||||
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.0 BAD_CODE Bad Server\r\n", CharsetUtil.UTF_8));
|
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.0 BAD_CODE Bad Server\r\n", CharsetUtil.UTF_8));
|
||||||
assertThat(ch.readInbound(), is(instanceOf(FullHttpResponse.class)));
|
Object inbound = ch.readInbound();
|
||||||
|
assertThat(inbound, is(instanceOf(FullHttpResponse.class)));
|
||||||
|
assertTrue(((FullHttpResponse) inbound).getDecoderResult().isFailure());
|
||||||
assertNull(ch.readInbound());
|
assertNull(ch.readInbound());
|
||||||
ch.finish();
|
ch.finish();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user