Skip to content

Commit 8bfbf77

Browse files
author
Norman Maurer
committed
Also allow to disable header validation via HttpServerCodec and HttpClientCodec. Related to [netty#1981]
1 parent c4130e0 commit 8bfbf77

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

codec-http/src/main/java/io/netty/handler/codec/http/HttpClientCodec.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,21 @@ public HttpClientCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunk
7676
this(maxInitialLineLength, maxHeaderSize, maxChunkSize, false);
7777
}
7878

79+
/**
80+
* Creates a new instance with the specified decoder options.
81+
*/
7982
public HttpClientCodec(
8083
int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse) {
81-
init(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize), new Encoder());
84+
this(maxInitialLineLength, maxHeaderSize, maxChunkSize, failOnMissingResponse, true);
85+
}
86+
87+
/**
88+
* Creates a new instance with the specified decoder options.
89+
*/
90+
public HttpClientCodec(
91+
int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse,
92+
boolean validateHeaders) {
93+
init(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders), new Encoder());
8294
this.failOnMissingResponse = failOnMissingResponse;
8395
}
8496

@@ -104,8 +116,8 @@ protected void encode(
104116
}
105117

106118
private final class Decoder extends HttpResponseDecoder {
107-
Decoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) {
108-
super(maxInitialLineLength, maxHeaderSize, maxChunkSize);
119+
Decoder(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders) {
120+
super(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders);
109121
}
110122

111123
@Override

codec-http/src/main/java/io/netty/handler/codec/http/HttpServerCodec.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,12 @@ public HttpServerCodec() {
4242
public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize) {
4343
super(new HttpRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize), new HttpResponseEncoder());
4444
}
45+
46+
/**
47+
* Creates a new instance with the specified decoder options.
48+
*/
49+
public HttpServerCodec(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean validateHeaders) {
50+
super(new HttpRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders),
51+
new HttpResponseEncoder());
52+
}
4553
}

0 commit comments

Comments
 (0)