Commit Graph

5915 Commits

Author SHA1 Message Date
Sam Brannen a5a0840f48 Stop implying that HttpHeaders implements java.util.Map 2025-11-12 18:02:30 +01:00
Sam Brannen a54618b498 Simplify HttpHeaders(HttpHeaders) constructor 2025-11-12 17:47:39 +01:00
Sam Brannen d37030b9e1 Polishing 2025-11-12 17:47:39 +01:00
Sam Brannen 93b72fa080 Polishing 2025-11-12 16:53:24 +01:00
Brian Clozel 3ac7f83900 Relax media type checks in HttpMessageConverters
Prior to this commit, `HttpMessageConverters` would assert that the
given converter in `withXmlConverter` has a media type that is equal to
"application/xml" in its list of supported converters.

This approach would not work if the given converter supports
"application/xml;charset=UTF-8" because of the strict equal check being
performed.

This commit ensures that we only consider the type and subtype of the
considered media types when comparing, removing the parameters from the
picture.

Fixes gh-35801
2025-11-12 15:50:15 +01:00
Sam Brannen deca37da4a Improve Javadoc for new HttpHeaders features 2025-11-12 15:11:33 +01:00
Sam Brannen 347040c5a4 Improve Javadoc for HttpHeaders.formatHeaders() 2025-11-12 14:17:13 +01:00
Sam Brannen 4593f877dd Fix HttpHeaders and WebSocketHttpHeaders interop issues
Since HttpHeaders no longer implements MultiValueMap (see gh-33913),
a few interoperability issues have arisen between HttpHeaders and
WebSocketHttpHeaders.

To address those issues, this commit:

- Revises addAll(HttpHeaders), putAll(HttpHeaders), and putAll(Map) in
  HttpHeaders so that they no longer operate on the HttpHeaders.headers
  field.

- Overrides addAll(String, List), asSingleValueMap(), and
  asMultiValueMap() in WebSocketHttpHeaders.

- Deletes putAll(HttpHeaders), putAll(Map), and forEach(BiConsumer) in
  WebSocketHttpHeaders, since they do not need to be overridden.

This commit also removes unnecessarily overridden Javadoc in
WebSocketHttpHeaders and revises the implementation of several methods
in HttpHeaders so that they delegate to key methods such as get()
instead of directly accessing the HttpHeaders.headers field.

See gh-33913
Closes gh-35792
2025-11-11 18:29:29 +01:00
Sam Brannen a3e8a173a8 Polishing 2025-11-11 16:52:07 +01:00
rstoyanchev 721c40b5c5 Add defaultVersion to set of supported versions
Closes gh-35755
2025-11-11 12:28:28 +00:00
Sébastien Deleuze 622251d89a Merge branch '6.2.x' 2025-11-11 13:00:16 +01:00
Dmitry Sulman d0ff8f9243 Fix HttpServiceMethod for suspending functions returning Flow
Closes gh-35718
Signed-off-by: Dmitry Sulman <dmitry.sulman@gmail.com>
2025-11-11 12:58:42 +01:00
Brian Clozel e85afff8a3 Merge branch '6.2.x' 2025-11-10 16:30:50 +01:00
Brian Clozel ba39385cce Use executor for blocking I/O in Reactor request factory
Prior to this commit, the `ReactorClientHttpRequestFactory` and the
`ReactorClientHttpRequest` would use the `Executor` from the current
event loop for performing write operations.
Depending on I/O demand, this work could be blocked and would result in
blocked Netty event loop executors and the HTTP client hanging.

This commit ensures that the client uses a separate Executor for such
operations. If the application does not provide one on the request
factory, a `Schedulers#boundedElastic` instance will be used.

Fixes gh-34707
2025-11-10 16:12:14 +01:00
rstoyanchev 9daf99af3f Merge branch '6.2.x' 2025-11-10 14:43:58 +00:00
rstoyanchev 3cb498fa98 Improve docs on streaming via StreamingHttpOutputMessage
Closes gh-35700
2025-11-10 14:43:34 +00:00
Sam Brannen 1714a00492 Suppress warnings in Gradle build 2025-11-10 14:13:34 +01:00
Sébastien Deleuze 816cee12e5 Change default converters ordering
This commit adds a new withKotlinSerializationCborConverter
method to HttpMessageConverters and updates DefaultHttpMessageConverters
to put JSON and CBOR Kotlin Serialization converters before
their Jackson/GSON/JSONB counterparts with their new default
behavior that only handles classes with `@Serializable` at
type or generics level.

When there is no alternative converter for the same mime type,
Kotlin Serialization converters handle all supported cases.

Closes gh-35761
2025-11-10 11:36:00 +01:00
Sébastien Deleuze d64edc01c0 Prevent Kotlin Serialization converters side effects
This commit updates Kotlin serialization converters to perform
an additional check invoking
KotlinDetector#hasSerializableAnnotation to decide if the
related type should be processed or not.

The goal is to prevent in the default arrangement conflicts
between general purpose converters like Jackson and
Kotlin serialization when both are used.

New constructors allowing to specify a custom predicate
are also introduced.

See gh-35761
2025-11-10 11:35:44 +01:00
Sébastien Deleuze d0f57013b0 Change default codecs ordering and add Jackson CBOR
This commit updates BaseDefaultCodecs by adding Kotlin
Serialization codecs before their Jackson/GSON counterparts
with their new default behavior that only handles classes with
`@Serializable` at type or generics level.

When there is no alternative codec for the same mime type,
Kotlin Serialization codecs handle all supported cases.

This commit also adds missing Jackson CBOR codecs, and moves both
CBOR and Protobuf codecs to a lower priority, as they are less
commonly used than JSON ones, with the same ordering used on
Spring MVC side.

See gh-35761
Closes gh-35787
2025-11-10 11:35:29 +01:00
Sébastien Deleuze 19dd488dd7 Prevent Kotlin Serialization codecs side effects
This commit updates Kotlin serialization codecs to perform
an additional check invoking
KotlinDetector#hasSerializableAnnotation to decide if the
related type should be processed or not.

The goal is to prevent in the default arrangement conflicts
between general purpose codecs like Jackson and
Kotlin serialization when both are used.

New constructors allowing to specify a custom predicate
are also introduced.

See gh-35761
2025-11-10 11:35:02 +01:00
rstoyanchev 115dee9be1 Fix failing test
See gh-35707
2025-11-06 13:18:41 +00:00
rstoyanchev 09105eb7b2 Option to supply client builder in HttpServiceGroupConfigurer
Closes gh-35707
2025-11-06 11:58:37 +00:00
rstoyanchev 6dd40a0252 Refactoring in HttpServiceProxyRegistryFactoryBean
See gh-35707
2025-11-06 11:58:37 +00:00
Brian Clozel 783299d24e Merge branch '6.2.x' 2025-11-05 18:36:15 +01:00
Brian Clozel 285182be27 Relax multiple segment matching constraints in PathPattern
Prior to this commit, gh-35213 allowed wildcard path elments at the
start of path patterns. This came with an additional constraint that
rejected such patterns if the pattern segment following the wildcard one
was not a literal:

* `/**/{name}` was rejected
* `/**/something/{name}` was accepted

The motivation here was to make the performance impact of wildard
patterns as small as possible at runtime.

This commit relaxes this constraint because `/**/*.js` patterns are very
popular in the security space for request matchers.

Closes gh-35686
2025-11-05 18:32:44 +01:00
Brian Clozel 9a54fac998 Merge branch '6.2.x' 2025-11-05 15:18:10 +01:00
Brian Clozel 8bb63081a8 Document PathPattern matching for single/multiple segments
This commit improves the reference document to better reflect the
different between `*` or `{name}` on one side, and `**` or `{*path}` on
the other.

The former patterns only consider a single path segment and its content,
while the latter variants consider zero or more path segments. This
explains why `/test/{*path}` can match `/test`.

Closes gh-35727
2025-11-05 14:58:58 +01:00
Sam Brannen 94d7aa2844 Suppress deprecation warnings 2025-11-05 14:55:07 +01:00
rstoyanchev b128f59714 Expose handler to ApiVersionDeprecationHandler implementations
Closes gh-35750
2025-11-05 12:23:59 +00:00
Brian Clozel 5f895d7b1f Merge branch '6.2.x' 2025-11-05 10:51:54 +01:00
Brian Clozel c0429dbb09 Fix file extension resolution for media types with q parameter
Prior to this commit, the `MappingMediaTypeFileExtensionResolver` would
resolve file extensions for a given media type by using a direct lookup
using the given media type provided by the request.
If the request contains a quality parameter like
"application/json;q=0.9", this would not resolve configured file
extensions for this media type.
While other media type parameters can be meaningful, the quality
parameter should not be used for lookups. This commit ensures that the
quality parameter is dropped before performing lookups.

Fixes gh-35754
2025-11-05 10:48:24 +01:00
Brian Clozel ad22a99993 Merge branch '6.2.x' 2025-11-03 17:09:57 +01:00
Brian Clozel d65de19e7d Deprecate setConnectTimeout on HttpComponents client factory
Prior to this commit, the `HttpComponentsClientHttpRequestFactory` would
set the connection timeout on the request configuration. This has been
deprecated by the client itself and this value should be set while
creating the client on the connection manager itself.

This commit deprecates this method, as there is no way for the factory
to set this value anymore.

Closes gh-35748
2025-11-03 16:53:54 +01:00
Brian Clozel e6a076017b Configure custom Kotlin Serialization converter
Prior to this commit, `HttpMessageConverters` would consider the Kotlin
Serialization JSON converter as an alternative to the Jackson variant.
As seen in related issues, this converter is more commonly used for
annotated classes specifically and applications often rely on Jackson
acting as a fallback for types not supported by Kotlin Serialization.

This commit enables applications to configure such a converter on
`HttpMessageConverters` and order it ahead of of the JSON one.

Closes gh-35733
2025-11-03 14:33:12 +01:00
Sam Brannen 2f47efe2d3 Polishing 2025-11-03 12:05:34 +01:00
rstoyanchev 183a9466c5 Add dedicated ApiVersionResolver implementations
Closes gh-35747
2025-11-03 09:19:38 +00:00
Juergen Hoeller 29a76a6c70 Merge branch '6.2.x'
# Conflicts:
#	spring-web/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java
2025-11-02 20:42:43 +01:00
Juergen Hoeller 4b7cf85d71 Retrieve cached response body in a thread-safe manner
Closes gh-35745
2025-11-02 20:40:02 +01:00
Brian Clozel af026c0373 Review HttpMessageConverters semantics in Builder
Prior to this commit, the `HttpMessageConverters` builder API had
methods like "jsonMessageConverter" for configuring a specific converter
for JSON support. This converter would be always configured at a given
position, even if default converters registration is not requested.
On the other hand, `customMessageConverter` would add any converter
ahead of the list, in all cases. This difference was not conveyed as it
should by the API.

This commit makes the following changes:

* builder methods are renamed to `withJsonConverter` and variants, to
  better convey the fact that those are replacing the default converter
  for a given format.
* `customMessageConverter` is renamed to `addCustomConverter` to better
  reflect the additive aspect.
* the JavaDoc has been updated accordingly
* `withJsonConverter` and others are now only effective if the default
  registration of auto-detected converters is requested. This better
  aligns with the behavior in the reactive codecs configuration

Closes gh-35704
2025-10-31 17:18:28 +01:00
Juergen Hoeller b2b526162f Polishing 2025-10-30 21:05:47 +01:00
Sébastien Deleuze a705c6f32a Merge branch '6.2.x' 2025-10-30 19:42:45 +01:00
Anton Xu 01a58a253b Fix minor typo in RestClient
Closes gh-35723
Signed-off-by: Anton Xu <anton-xu@hotmail.com>
2025-10-30 19:41:56 +01:00
Sébastien Deleuze 694224f1a6 Remove outdated Spring version mentions
Close gh-35696
2025-10-28 13:58:09 +01:00
rstoyanchev f07873c966 Merge branch '6.2.x' 2025-10-28 12:07:46 +00:00
rstoyanchev b19059f6cb Handle null from JDK HttpResponse#body
Closes gh-35692
2025-10-28 11:44:16 +00:00
rstoyanchev 9331e1e86c Allow Protobuf codec extensions
Closes gh-35403
2025-10-23 12:16:52 +01:00
rstoyanchev 6ebb2071f5 Allow to set MimeType's in ProtobufCodecSupport
See gh-35403
2025-10-23 12:16:52 +01:00
rstoyanchev 754372a1f6 Allow ProtobufHttpMessageConverter extensions
Make ProtobufFormatDelegate protected and visible to subclasses.
Expose constructor that allows passing the delegate in.

See gh-35403
2025-10-23 12:16:52 +01:00
rstoyanchev 87607cccff Polishing in Protobuf support
See gh-35403
2025-10-23 12:16:52 +01:00