Respect validateHeaders when duplicate/copy the response/request

This commit is contained in:
Norman Maurer 2013-11-26 08:09:14 +01:00
parent 7ec70d0210
commit fd4435e6e3
3 changed files with 13 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
public class DefaultFullHttpRequest extends DefaultHttpRequest implements FullHttpRequest {
private final ByteBuf content;
private final HttpHeaders trailingHeader;
private final boolean validateHeaders;
public DefaultFullHttpRequest(HttpVersion httpVersion, HttpMethod method, String uri) {
this(httpVersion, method, uri, Unpooled.buffer(0));
@ -41,6 +42,7 @@ public class DefaultFullHttpRequest extends DefaultHttpRequest implements FullHt
}
this.content = content;
trailingHeader = new DefaultHttpHeaders(validateHeaders);
this.validateHeaders = validateHeaders;
}
@Override
@ -101,7 +103,7 @@ public class DefaultFullHttpRequest extends DefaultHttpRequest implements FullHt
@Override
public FullHttpRequest copy() {
DefaultFullHttpRequest copy = new DefaultFullHttpRequest(
getProtocolVersion(), getMethod(), getUri(), content().copy());
getProtocolVersion(), getMethod(), getUri(), content().copy(), validateHeaders);
copy.headers().set(headers());
copy.trailingHeaders().set(trailingHeaders());
return copy;
@ -110,7 +112,7 @@ public class DefaultFullHttpRequest extends DefaultHttpRequest implements FullHt
@Override
public FullHttpRequest duplicate() {
DefaultFullHttpRequest duplicate = new DefaultFullHttpRequest(
getProtocolVersion(), getMethod(), getUri(), content().duplicate());
getProtocolVersion(), getMethod(), getUri(), content().duplicate(), validateHeaders);
duplicate.headers().set(headers());
duplicate.trailingHeaders().set(trailingHeaders());
return duplicate;

View File

@ -26,6 +26,7 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full
private final ByteBuf content;
private final HttpHeaders trailingHeaders;
private final boolean validateHeaders;
public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status) {
this(version, status, Unpooled.buffer(0));
@ -43,6 +44,7 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full
}
this.content = content;
trailingHeaders = new DefaultHttpHeaders(validateHeaders);
this.validateHeaders = validateHeaders;
}
@Override
@ -96,7 +98,8 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full
@Override
public FullHttpResponse copy() {
DefaultFullHttpResponse copy = new DefaultFullHttpResponse(getProtocolVersion(), getStatus(), content().copy());
DefaultFullHttpResponse copy = new DefaultFullHttpResponse(
getProtocolVersion(), getStatus(), content().copy(), validateHeaders);
copy.headers().set(headers());
copy.trailingHeaders().set(trailingHeaders());
return copy;
@ -105,7 +108,7 @@ public class DefaultFullHttpResponse extends DefaultHttpResponse implements Full
@Override
public FullHttpResponse duplicate() {
DefaultFullHttpResponse duplicate = new DefaultFullHttpResponse(getProtocolVersion(), getStatus(),
content().duplicate());
content().duplicate(), validateHeaders);
duplicate.headers().set(headers());
duplicate.trailingHeaders().set(trailingHeaders());
return duplicate;

View File

@ -27,6 +27,7 @@ import java.util.Map;
public class DefaultLastHttpContent extends DefaultHttpContent implements LastHttpContent {
private final HttpHeaders trailingHeaders;
private final boolean validateHeaders;
public DefaultLastHttpContent() {
this(Unpooled.buffer(0));
@ -39,18 +40,19 @@ public class DefaultLastHttpContent extends DefaultHttpContent implements LastHt
public DefaultLastHttpContent(ByteBuf content, boolean validateHeaders) {
super(content);
trailingHeaders = new TrailingHeaders(validateHeaders);
this.validateHeaders = validateHeaders;
}
@Override
public LastHttpContent copy() {
DefaultLastHttpContent copy = new DefaultLastHttpContent(content().copy());
DefaultLastHttpContent copy = new DefaultLastHttpContent(content().copy(), validateHeaders);
copy.trailingHeaders().set(trailingHeaders());
return copy;
}
@Override
public LastHttpContent duplicate() {
DefaultLastHttpContent copy = new DefaultLastHttpContent(content().duplicate());
DefaultLastHttpContent copy = new DefaultLastHttpContent(content().duplicate(), validateHeaders);
copy.trailingHeaders().set(trailingHeaders());
return copy;
}