diff --git a/applications/processor/http-request-processor/README.adoc b/applications/processor/http-request-processor/README.adoc index f35708aa..44a8b477 100644 --- a/applications/processor/http-request-processor/README.adoc +++ b/applications/processor/http-request-processor/README.adoc @@ -43,14 +43,23 @@ The **$$http-request$$** $$processor$$ has the following options: == Options //tag::configuration-properties[] -$$http.request.body-expression$$:: $$A SpEL expression to derive the request body from the incoming message.$$ *($$Expression$$, default: `$$$$`)* -$$http.request.expected-response-type$$:: $$The type used to interpret the response.$$ *($$Class$$, default: `$$$$`)* -$$http.request.headers-expression$$:: $$A SpEL expression used to derive the http headers map to use.$$ *($$Expression$$, default: `$$$$`)* -$$http.request.http-method-expression$$:: $$A SpEL expression to derive the request method from the incoming message.$$ *($$Expression$$, default: `$$$$`)* -$$http.request.maximum-buffer-size$$:: $$Maximum buffer size in bytes allocated for input stream buffers. Defaults to 256k. Increase, as necessary, for posting or getting large binary content.$$ *($$Integer$$, default: `$$0$$`)* -$$http.request.reply-expression$$:: $$A SpEL expression used to compute the final result, applied against the whole http {@link org.springframework.http.ResponseEntity}.$$ *($$Expression$$, default: `$$$$`)* -$$http.request.timeout$$:: $$Request timeout in milliseconds.$$ *($$Long$$, default: `$$30000$$`)* -$$http.request.url-expression$$:: $$A SpEL expression against incoming message to determine the URL to use.$$ *($$Expression$$, default: `$$$$`)* +Properties grouped by prefix: + + +=== http.request + +$$body-expression$$:: $$A SpEL expression to derive the request body from the incoming message.$$ *($$Expression$$, default: `$$$$`)* +$$expected-response-type$$:: $$The type used to interpret the response.$$ *($$Class$$, default: `$$$$`)* +$$headers-expression$$:: $$A SpEL expression used to derive the http headers map to use.$$ *($$Expression$$, default: `$$$$`)* +$$http-method-expression$$:: $$A SpEL expression to derive the request method from the incoming message.$$ *($$Expression$$, default: `$$$$`)* +$$reply-expression$$:: $$A SpEL expression used to compute the final result, applied against the whole http {@link org.springframework.http.ResponseEntity}.$$ *($$Expression$$, default: `$$$$`)* +$$timeout$$:: $$Request timeout in milliseconds.$$ *($$Long$$, default: `$$30000$$`)* +$$url-expression$$:: $$A SpEL expression against incoming message to determine the URL to use.$$ *($$Expression$$, default: `$$$$`)* + +=== spring.codec + +$$log-request-details$$:: $$Whether to log form data at DEBUG level, and headers at TRACE level.$$ *($$Boolean$$, default: `$$false$$`)* +$$max-in-memory-size$$:: $$Limit on the number of bytes that can be buffered whenever the input stream needs to be aggregated. This applies only to the auto-configured WebFlux server and WebClient instances. By default this is not set, in which case individual codec defaults apply. Most codecs are limited to 256K by default.$$ *($$DataSize$$, default: `$$$$`)* //end::configuration-properties[] //end::ref-doc[] diff --git a/applications/processor/http-request-processor/src/main/resources/META-INF/dataflow-configuration-metadata-whitelist.properties b/applications/processor/http-request-processor/src/main/resources/META-INF/dataflow-configuration-metadata-whitelist.properties index 6e966678..31c417dd 100644 --- a/applications/processor/http-request-processor/src/main/resources/META-INF/dataflow-configuration-metadata-whitelist.properties +++ b/applications/processor/http-request-processor/src/main/resources/META-INF/dataflow-configuration-metadata-whitelist.properties @@ -1,2 +1,2 @@ -configuration-properties.classes=org.springframework.cloud.fn.http.request.HttpRequestFunctionProperties - +configuration-properties.classes=org.springframework.cloud.fn.http.request.HttpRequestFunctionProperties,\ + org.springframework.boot.autoconfigure.codec.CodecProperties diff --git a/applications/processor/http-request-processor/src/main/resources/META-INF/dataflow-configuration-metadata.properties b/applications/processor/http-request-processor/src/main/resources/META-INF/dataflow-configuration-metadata.properties index 6e966678..aeb4e368 100644 --- a/applications/processor/http-request-processor/src/main/resources/META-INF/dataflow-configuration-metadata.properties +++ b/applications/processor/http-request-processor/src/main/resources/META-INF/dataflow-configuration-metadata.properties @@ -1,2 +1,3 @@ -configuration-properties.classes=org.springframework.cloud.fn.http.request.HttpRequestFunctionProperties +configuration-properties.classes=org.springframework.cloud.fn.http.request.HttpRequestFunctionProperties,\ + org.springframework.boot.autoconfigure.codec.CodecProperties diff --git a/functions/function/http-request-function/src/main/java/org/springframework/cloud/fn/http/request/HttpRequestFunctionConfiguration.java b/functions/function/http-request-function/src/main/java/org/springframework/cloud/fn/http/request/HttpRequestFunctionConfiguration.java index a68a459b..48fa392a 100644 --- a/functions/function/http-request-function/src/main/java/org/springframework/cloud/fn/http/request/HttpRequestFunctionConfiguration.java +++ b/functions/function/http-request-function/src/main/java/org/springframework/cloud/fn/http/request/HttpRequestFunctionConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 the original author or authors. + * Copyright 2018-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import java.util.function.Function; import reactor.core.publisher.Flux; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,11 +33,14 @@ import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.util.DefaultUriBuilderFactory; import org.springframework.web.util.UriBuilderFactory; + + /** * Configuration for a {@link Function} that makes HTTP requests to a resource and for * each request, returns a {@link ResponseEntity}. * * @author David Turanski + * @author Sunny Hemdev * **/ @Configuration @@ -46,17 +48,8 @@ import org.springframework.web.util.UriBuilderFactory; public class HttpRequestFunctionConfiguration { @Bean - @ConditionalOnMissingBean(WebClient.class) - public WebClient webClient(HttpRequestFunctionProperties properties) { - return WebClient.builder() - .codecs(clientCodecConfigurer -> - clientCodecConfigurer.defaultCodecs().maxInMemorySize(properties.getMaximumBufferSize())) - .build(); - } - - @Bean - public HttpRequestFunction httpRequestFunction(WebClient webClient, HttpRequestFunctionProperties properties) { - return new HttpRequestFunction(webClient, properties); + public HttpRequestFunction httpRequestFunction(WebClient.Builder webClientBuilder, HttpRequestFunctionProperties properties) { + return new HttpRequestFunction(webClientBuilder.build(), properties); } /** diff --git a/functions/function/http-request-function/src/main/java/org/springframework/cloud/fn/http/request/HttpRequestFunctionProperties.java b/functions/function/http-request-function/src/main/java/org/springframework/cloud/fn/http/request/HttpRequestFunctionProperties.java index 12dce44c..7166e4cf 100644 --- a/functions/function/http-request-function/src/main/java/org/springframework/cloud/fn/http/request/HttpRequestFunctionProperties.java +++ b/functions/function/http-request-function/src/main/java/org/springframework/cloud/fn/http/request/HttpRequestFunctionProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 the original author or authors. + * Copyright 2015-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.cloud.fn.http.request; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Positive; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.expression.Expression; @@ -35,6 +34,7 @@ import org.springframework.validation.annotation.Validated; * @author Christian Tzolov * @author Artem Bilan * @author David Turanski + * @author Sunny Hemdev */ @Validated @ConfigurationProperties("http.request") @@ -52,13 +52,6 @@ public class HttpRequestFunctionProperties { */ private long timeout = 30_000; - /** - * Maximum buffer size in bytes allocated for input stream buffers. Defaults to 256k. - * Increase, as necessary, for posting or getting large binary content. - */ - - private int maximumBufferSize = 256 * 1024; - /** * A SpEL expression against incoming message to determine the URL to use. */ @@ -119,15 +112,6 @@ public class HttpRequestFunctionProperties { this.timeout = timeout; } - @Positive - public int getMaximumBufferSize() { - return maximumBufferSize; - } - - public void setMaximumBufferSize(int maximumBufferSize) { - this.maximumBufferSize = maximumBufferSize; - } - public Expression getBodyExpression() { return bodyExpression; }