Skip to content

Commit

Permalink
2.x: Fix helidon-io#7783: max-payload-size is parsed as an Integer (h…
Browse files Browse the repository at this point in the history
…elidon-io#7897)

* Fix helidon-io#7783: max-payload-size is parsed as an Integer
  • Loading branch information
barchetta authored Oct 26, 2023
1 parent dfe2ac3 commit 45acab9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ default B config(Config config) {
config.get("backlog").asInt().ifPresent(this::backlog);
config.get("max-header-size").asInt().ifPresent(this::maxHeaderSize);
config.get("max-initial-line-length").asInt().ifPresent(this::maxInitialLineLength);
config.get("max-payload-size").asInt().ifPresent(this::maxPayloadSize);
config.get("max-payload-size").asLong().ifPresent(this::maxPayloadSize);

DeprecatedConfig.get(config, "timeout-millis", "timeout")
.asInt()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
package io.helidon.webserver;

import java.nio.charset.Charset;
import java.util.Map;
import java.util.concurrent.CompletionException;
import java.util.concurrent.Flow;
import java.util.concurrent.TimeUnit;
Expand All @@ -25,6 +26,8 @@
import io.helidon.common.http.DataChunk;
import io.helidon.common.http.Http;
import io.helidon.common.http.MediaType;
import io.helidon.config.Config;
import io.helidon.config.ConfigSources;
import io.helidon.webclient.WebClient;
import io.helidon.webclient.WebClientRequestBuilder;
import io.helidon.webclient.WebClientResponse;
Expand Down Expand Up @@ -188,6 +191,18 @@ public void testMixedGoodAndBadPayloads() {
assertThat(response.status().code(), is(Http.Status.OK_200.code()));
}

/**
* Verify fix for 7783
*/
@Test
public void testMaxLongMaxPayloadSizeFromConfig() {
final long MAX_PAYLOAD_SIZE = Long.MAX_VALUE;
Config justConfig = Config.just(ConfigSources.create(Map.of("max-payload-size", Long.toString(MAX_PAYLOAD_SIZE))).build());
WebServer webServer = WebServer.builder().config(justConfig).build();
assertThat(webServer.configuration().namedSocket(WebServer.DEFAULT_SOCKET_NAME).get().maxPayloadSize(),
is(Long.MAX_VALUE));
}

/**
* Publishes the same chunk multiple times. If number of times is greater than
* one, Helidon will send content using chunked encoding.
Expand Down

0 comments on commit 45acab9

Please sign in to comment.