Skip to content

Commit e465b8b

Browse files
committed
Revert "Disable strict line parsing"
This reverts commit ce7f506.
1 parent ce7f506 commit e465b8b

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import io.netty.handler.codec.ByteToMessageDecoder;
2424
import io.netty.handler.codec.http.HttpContentCompressor;
2525
import io.netty.handler.codec.http.HttpContentDecompressor;
26-
import io.netty.handler.codec.http.HttpDecoderConfig;
2726
import io.netty.handler.codec.http.HttpMessage;
2827
import io.netty.handler.codec.http.HttpRequestDecoder;
2928
import io.netty.handler.codec.http.HttpResponse;
@@ -343,19 +342,23 @@ protected void initChannel(Channel ch) throws Exception {
343342
ch.pipeline().addLast("read_timeout", new ReadTimeoutHandler(transport.readTimeoutMillis, TimeUnit.MILLISECONDS));
344343
}
345344
final HttpRequestDecoder decoder;
346-
final HttpDecoderConfig decoderConfig = new HttpDecoderConfig().setMaxInitialLineLength(handlingSettings.maxInitialLineLength())
347-
.setMaxHeaderSize(handlingSettings.maxHeaderSize())
348-
.setMaxChunkSize(handlingSettings.maxChunkSize())
349-
.setStrictLineParsing(false);
350345
if (httpValidator != null) {
351-
decoder = new HttpRequestDecoder(decoderConfig) {
346+
decoder = new HttpRequestDecoder(
347+
handlingSettings.maxInitialLineLength(),
348+
handlingSettings.maxHeaderSize(),
349+
handlingSettings.maxChunkSize()
350+
) {
352351
@Override
353352
protected HttpMessage createMessage(String[] initialLine) throws Exception {
354353
return HttpHeadersAuthenticatorUtils.wrapAsMessageWithAuthenticationContext(super.createMessage(initialLine));
355354
}
356355
};
357356
} else {
358-
decoder = new HttpRequestDecoder(decoderConfig);
357+
decoder = new HttpRequestDecoder(
358+
handlingSettings.maxInitialLineLength(),
359+
handlingSettings.maxHeaderSize(),
360+
handlingSettings.maxChunkSize()
361+
);
359362
}
360363
decoder.setCumulator(ByteToMessageDecoder.COMPOSITE_CUMULATOR);
361364
ch.pipeline().addLast("decoder", decoder); // parses the HTTP bytes request into HTTP message pieces

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SecurityNetty4HttpServerTransportTests.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -800,18 +800,14 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
800800
}
801801

802802
/**
803-
* Append a string as ASCII terminated by a newline (sometimes CR/LF, sometimes LF)
803+
* Append a string as ASCII terminated by a CR/LF newline
804804
*
805805
* @param string The string to append
806806
* @param buf The buffer to append to
807807
*/
808808
private static void appendAsciiLine(String string, ByteBuf buf) {
809809
ByteBufUtil.copy(AsciiString.of(string), buf);
810-
if (randomBoolean()) {
811-
buf.writeByte(HttpConstants.LF);
812-
} else {
813-
appendCrLf(buf);
814-
}
810+
appendCrLf(buf);
815811
}
816812

817813
/**

0 commit comments

Comments
 (0)