diff --git a/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/QuarkusRestClientBuilder.java b/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/QuarkusRestClientBuilder.java index a7c66165bea7f..c67adff8fa9e9 100644 --- a/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/QuarkusRestClientBuilder.java +++ b/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/QuarkusRestClientBuilder.java @@ -178,6 +178,14 @@ static QuarkusRestClientBuilder newBuilder() { */ QuarkusRestClientBuilder followRedirects(boolean follow); + /** + * Mode in which the form data are encoded. Possible values are `HTML5`, `RFC1738` and `RFC3986`. + * The modes are described in the + * Netty + * documentation + */ + QuarkusRestClientBuilder multipartPostEncoderMode(String mode); + /** * Specifies the HTTP proxy hostname/IP address and port to use for requests from client instances. * diff --git a/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/QuarkusRestClientBuilderImpl.java b/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/QuarkusRestClientBuilderImpl.java index 3ba9ad115f961..5a663f92641c4 100644 --- a/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/QuarkusRestClientBuilderImpl.java +++ b/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/QuarkusRestClientBuilderImpl.java @@ -120,6 +120,12 @@ public QuarkusRestClientBuilder nonProxyHosts(String nonProxyHosts) { return this; } + @Override + public QuarkusRestClientBuilder multipartPostEncoderMode(String mode) { + proxy.multipartPostEncoderMode(mode); + return this; + } + @Override public QuarkusRestClientBuilder queryParamStyle(QueryParamStyle style) { proxy.queryParamStyle(style); diff --git a/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java b/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java index 3920c8db594c1..daa221114c341 100644 --- a/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java +++ b/extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/RestClientBuilderImpl.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; @@ -34,6 +35,7 @@ import org.jboss.resteasy.reactive.client.impl.ClientBuilderImpl; import org.jboss.resteasy.reactive.client.impl.ClientImpl; import org.jboss.resteasy.reactive.client.impl.WebTargetImpl; +import org.jboss.resteasy.reactive.client.impl.multipart.PausableHttpPostRequestEncoder; import org.jboss.resteasy.reactive.common.jaxrs.ConfigurationImpl; import org.jboss.resteasy.reactive.common.jaxrs.MultiQueryParamMode; @@ -63,6 +65,7 @@ public class RestClientBuilderImpl implements RestClientBuilder { private boolean followRedirects; private QueryParamStyle queryParamStyle; + private String multipartPostEncoderMode; private String proxyHost; private Integer proxyPort; private String proxyUser; @@ -167,6 +170,11 @@ public RestClientBuilderImpl nonProxyHosts(String nonProxyHosts) { return this; } + public RestClientBuilderImpl multipartPostEncoderMode(String mode) { + this.multipartPostEncoderMode = mode; + return this; + } + public RestClientBuilderImpl clientLogger(ClientLogger clientLogger) { this.clientLogger = clientLogger; return this; @@ -435,6 +443,21 @@ public T build(Class aClass) throws IllegalStateException, RestClientDefi configureProxy(globalProxy.host, globalProxy.port, restClientsConfig.proxyUser.orElse(null), restClientsConfig.proxyPassword.orElse(null), restClientsConfig.nonProxyHosts.orElse(null)); } + + if (!clientBuilder.getConfiguration().hasProperty(QuarkusRestClientProperties.MULTIPART_ENCODER_MODE)) { + PausableHttpPostRequestEncoder.EncoderMode multipartPostEncoderMode = null; + if (this.multipartPostEncoderMode != null) { + multipartPostEncoderMode = PausableHttpPostRequestEncoder.EncoderMode + .valueOf(this.multipartPostEncoderMode.toUpperCase(Locale.ROOT)); + } else if (restClientsConfig.multipartPostEncoderMode.isPresent()) { + multipartPostEncoderMode = PausableHttpPostRequestEncoder.EncoderMode + .valueOf(restClientsConfig.multipartPostEncoderMode.get().toUpperCase(Locale.ROOT)); + } + if (multipartPostEncoderMode != null) { + clientBuilder.property(QuarkusRestClientProperties.MULTIPART_ENCODER_MODE, multipartPostEncoderMode); + } + } + ClientImpl client = clientBuilder.build(); WebTargetImpl target = (WebTargetImpl) client.target(uri); target.setParamConverterProviders(paramConverterProviders);