Skip to content

Commit 1df43a0

Browse files
authored
Remove HTTP max content length leniency (#29337)
I am not sure why we have this leniency for HTTP max content length, it has been there since the beginning (5ac51ee) with no explanation of its source. That said, our philosophy today is different than the philosophy of the past where Elasticsearch would be quite lenient in its handling of settings and today we aim for predictability for both users and us. This commit removes leniency in the parsing of http.max_content_length.
1 parent 6b2167f commit 1df43a0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

docs/reference/modules/http.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ from the outside. Defaults to the actual port assigned via `http.port`.
3939
|`http.host` |Used to set the `http.bind_host` and the `http.publish_host` Defaults to `http.host` or `network.host`.
4040

4141
|`http.max_content_length` |The max content of an HTTP request. Defaults to
42-
`100mb`. If set to greater than `Integer.MAX_VALUE`, it will be reset to 100mb.
42+
`100mb`.
4343

4444
|`http.max_initial_line_length` |The max length of an HTTP URL. Defaults
4545
to `4kb`

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

-5
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,6 @@ public Netty4HttpServerTransport(Settings settings, NetworkService networkServic
233233
this.pipeliningMaxEvents = SETTING_PIPELINING_MAX_EVENTS.get(settings);
234234
this.corsConfig = buildCorsConfig(settings);
235235

236-
// validate max content length
237-
if (maxContentLength.getBytes() > Integer.MAX_VALUE) {
238-
logger.warn("maxContentLength[{}] set to high value, resetting it to [100mb]", maxContentLength);
239-
maxContentLength = new ByteSizeValue(100, ByteSizeUnit.MB);
240-
}
241236
this.maxContentLength = maxContentLength;
242237

243238
logger.debug("using max_chunk_size[{}], max_header_size[{}], max_initial_line_length[{}], max_content_length[{}], " +

server/src/main/java/org/elasticsearch/http/HttpTransportSettings.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ public final class HttpTransportSettings {
8383
return true;
8484
}, Property.NodeScope, Property.Deprecated);
8585
public static final Setting<ByteSizeValue> SETTING_HTTP_MAX_CONTENT_LENGTH =
86-
Setting.byteSizeSetting("http.max_content_length", new ByteSizeValue(100, ByteSizeUnit.MB), Property.NodeScope);
86+
Setting.byteSizeSetting(
87+
"http.max_content_length",
88+
new ByteSizeValue(100, ByteSizeUnit.MB),
89+
new ByteSizeValue(0, ByteSizeUnit.BYTES),
90+
new ByteSizeValue(Integer.MAX_VALUE, ByteSizeUnit.BYTES),
91+
Property.NodeScope);
8792
public static final Setting<ByteSizeValue> SETTING_HTTP_MAX_CHUNK_SIZE =
8893
Setting.byteSizeSetting("http.max_chunk_size", new ByteSizeValue(8, ByteSizeUnit.KB), Property.NodeScope);
8994
public static final Setting<ByteSizeValue> SETTING_HTTP_MAX_HEADER_SIZE =

0 commit comments

Comments
 (0)