GH-3154: Support UriBuilderFactory.EncodingMode (#3162)
* GH-3154: Support `UriBuilderFactory.EncodingMode` Fixes https://github.com/spring-projects/spring-integration/issues/3154 Spring Framework now provides a `DefaultUriBuilderFactory.EncodingMode` for encoding URIs in the `RestTemplate` before and after uri template enrichment with uri variables. Therefore `encodeUri` and manual uri variables substitution is not necessary in Spring Integration HTTP components * Deprecate `AbstractHttpRequestExecutingMessageHandler.encodeUri` in favor of `DefaultUriBuilderFactory.EncodingMode` and respective configuration on the `RestTemplate` in HTTP module and `WebClient` in WebFlux module * * Really populate `uriFactory` into an internal `RestTemplate` * Ensure in tests that `encoding-mode` is populated properly into an internal `RestTemplate` * Clean up affected HTTP tests for AssertJ and JUnit 5 * * Clean up formatting * * Apply fix for WebFlux module * Add docs for new `encoding-mode` option * * Remove unused import in the test
This commit is contained in:
@@ -703,12 +703,13 @@ List<NameValuePair> nameValuePairs =
|
||||
----
|
||||
====
|
||||
|
||||
[[http-uri-encoding]]
|
||||
==== Controlling URI Encoding
|
||||
|
||||
By default, the URL string is encoded (see https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/util/UriComponentsBuilder.html[`UriComponentsBuilder`]) to the URI object before sending the request.
|
||||
In some scenarios with a non-standard URI (such as the RabbitMQ REST API), it is undesirable to perform the encoding.
|
||||
The `<http:outbound-gateway/>` and `<http:outbound-channel-adapter/>` provide an `encode-uri` attribute.
|
||||
To disable encoding the URL, set this attribute to `false` (by default, it is `true`).
|
||||
The `<http:outbound-gateway/>` and `<http:outbound-channel-adapter/>` provide an `encoding-mode` attribute.
|
||||
To disable encoding the URL, set this attribute to `NONE` (by default, it is `TEMPLATE_AND_VALUES`).
|
||||
If you wish to partially encode some of the URL, use an `expression` within a `<uri-variable/>`, as the following example shows:
|
||||
|
||||
====
|
||||
@@ -722,6 +723,10 @@ If you wish to partially encode some of the URL, use an `expression` within a `<
|
||||
----
|
||||
====
|
||||
|
||||
With Java DSL this option can be controlled by the `BaseHttpMessageHandlerSpec.encodingMode()` option.
|
||||
Same configuration applies for similar outbound components in the <<./webflux.adoc/[webflux,WebFlux module>>.
|
||||
For much sophisticated scenarios it is recommended to configure an `UriTemplateHandler` on the externally provided `RestTemplate`; or in case of WebFlux - `WebClient` with it `UriBuilderFactory`.
|
||||
|
||||
[[http-java-config]]
|
||||
=== Configuring HTTP Endpoints with Java
|
||||
|
||||
|
||||
@@ -41,3 +41,10 @@ See <<./gateway.adoc/gateway-calling-default-methods,Invoking `default` Methods>
|
||||
|
||||
Internal components (such as `_org.springframework.integration.errorLogger`) now have a shortened name when they are represented in the integration graph.
|
||||
See <<./graph.adoc#integration-graph,Integration Graph>> for more information.
|
||||
|
||||
[[x5.3-http]]
|
||||
=== HTTP Changes
|
||||
|
||||
The `encodeUri` property on the `AbstractHttpRequestExecutingMessageHandler` has been deprecated in favor of newly introduced `encodingMode`.
|
||||
See `DefaultUriBuilderFactory.EncodingMode` JavaDocs and <<./http.adoc/http-uri-encoding,Controlling URI Encoding>> for more information.
|
||||
This also effects `WebFluxRequestExecutingMessageHandler`, respective Java DSL and XML configuration.
|
||||
|
||||
Reference in New Issue
Block a user