Skip to content

Commit 765160e

Browse files
authored
Merge pull request #48562 from geoand/#47649
Allow configuration of Vert.x's http2UpgradeMaxContentLength in REST Client
2 parents fe37c1f + f5ddecc commit 765160e

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

extensions/resteasy-classic/rest-client-config/runtime/src/main/java/io/quarkus/restclient/config/RestClientsConfig.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ public interface RestClientsConfig {
276276
@WithDefault("false")
277277
boolean http2();
278278

279+
/**
280+
* Configures the HTTP/2 upgrade maximum length of the aggregated content in bytes.
281+
* <p>
282+
* This property is not applicable to the RESTEasy Client.
283+
*/
284+
@ConfigDocDefault("64K")
285+
Optional<MemorySize> http2UpgradeMaxContentLength();
286+
279287
/**
280288
* Configures two different things:
281289
* <ul>
@@ -613,6 +621,14 @@ default Optional<String> uriReload() {
613621
*/
614622
Optional<Boolean> http2();
615623

624+
/**
625+
* Configures the HTTP/2 upgrade maximum length of the aggregated content in bytes.
626+
* <p>
627+
* This property is not applicable to the RESTEasy Client.
628+
*/
629+
@ConfigDocDefault("64K")
630+
Optional<MemorySize> http2UpgradeMaxContentLength();
631+
616632
/**
617633
* Configures two different things:
618634
* <ul>

extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,13 @@ public <T> T build(Class<T> aClass) throws IllegalStateException, RestClientDefi
538538
clientBuilder.http2(true);
539539
}
540540

541+
if (getConfiguration().hasProperty(QuarkusRestClientProperties.HTTP2_UPGRADE_MAX_CONTENT_LENGTH)) {
542+
clientBuilder.http2UpgradeMaxContentLength(
543+
(int) getConfiguration().getProperty(QuarkusRestClientProperties.HTTP2_UPGRADE_MAX_CONTENT_LENGTH));
544+
} else if (restClients.http2UpgradeMaxContentLength().isPresent()) {
545+
clientBuilder.http2UpgradeMaxContentLength((int) restClients.http2UpgradeMaxContentLength().get().asLongValue());
546+
}
547+
541548
if (getConfiguration().hasProperty(QuarkusRestClientProperties.ALPN)) {
542549
clientBuilder.alpn((Boolean) getConfiguration().getProperty(QuarkusRestClientProperties.ALPN));
543550
} else if (restClients.alpn().isPresent()) {

extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientCDIDelegateBuilder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ private void configureCustomProperties(QuarkusRestClientBuilder builder) {
156156
Boolean http2 = oneOf(restClientConfig.http2()).orElse(configRoot.http2());
157157
builder.property(QuarkusRestClientProperties.HTTP2, http2);
158158

159+
Optional<MemorySize> http2UpgradeMaxContentLength = oneOf(restClientConfig.http2UpgradeMaxContentLength(),
160+
configRoot.http2UpgradeMaxContentLength());
161+
if (http2UpgradeMaxContentLength.isPresent()) {
162+
builder.property(QuarkusRestClientProperties.HTTP2_UPGRADE_MAX_CONTENT_LENGTH,
163+
(int) http2UpgradeMaxContentLength.get().asLongValue());
164+
}
165+
159166
Optional<Boolean> alpn = oneOf(restClientConfig.alpn(), configRoot.alpn());
160167
if (alpn.isPresent()) {
161168
builder.property(QuarkusRestClientProperties.ALPN, alpn.get());

independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/api/QuarkusRestClientProperties.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ public class QuarkusRestClientProperties {
7575
*/
7676
public static final String HTTP2 = "io.quarkus.rest.client.http2";
7777

78+
/**
79+
* Configures the HTTP/2 upgrade maximum length of the aggregated content in bytes.
80+
*/
81+
public static final String HTTP2_UPGRADE_MAX_CONTENT_LENGTH = "io.quarkus.rest.client.http2UpgradeMaxContentLength";
82+
7883
/**
7984
* Set to true to explicitly use the Application-Layer Protocol Negotiation extension.
8085
*/

independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientBuilderImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public class ClientBuilderImpl extends ClientBuilder {
8282
private String userAgent = RestClientRequestContext.DEFAULT_USER_AGENT_VALUE;
8383

8484
private Boolean enableCompression;
85+
private Integer http2UpgradeMaxContentLength;
8586

8687
public ClientBuilderImpl() {
8788
configuration = new ConfigurationImpl(RuntimeType.CLIENT);
@@ -155,6 +156,11 @@ public ClientBuilder http2(boolean http2) {
155156
return this;
156157
}
157158

159+
public ClientBuilder http2UpgradeMaxContentLength(int http2UpgradeMaxContentLength) {
160+
this.http2UpgradeMaxContentLength = http2UpgradeMaxContentLength;
161+
return this;
162+
}
163+
158164
public ClientBuilder alpn(boolean alpn) {
159165
this.alpn = alpn;
160166
return this;
@@ -228,6 +234,10 @@ public ClientImpl build() {
228234
options.setAlpnVersions(List.of(HttpVersion.HTTP_2, HttpVersion.HTTP_1_1));
229235
}
230236

237+
if (http2UpgradeMaxContentLength != null) {
238+
options.setHttp2UpgradeMaxContentLength(http2UpgradeMaxContentLength);
239+
}
240+
231241
if (tlsConfig != null) {
232242
populateSecurityOptionsFromTlsConfig(options);
233243
} else {

0 commit comments

Comments
 (0)