Commit Graph

5372 Commits

Author SHA1 Message Date
Brian Clozel 9df4fcdc9e Merge branch '6.1.x' 2024-10-25 10:55:00 +02:00
Brian Clozel a06bbccf9e HttpHeaders.writeableHttpHeaders should unwrap many times
Prior to this commit, the `HttpHeaders.writeableHttpHeaders` would only
consider headers read-only instances that were wrapped once by
`HttpHeaders.readOnlyHttpHeaders`. This does not work when other
`HttpHeaders` wrappers are involved in the chain.

This commit ensures that `writeableHttpHeaders` unwraps all headers
instances down to the actual multivalue map and create a new headers
instance out of it.

Fixes gh-33789
2024-10-25 10:22:12 +02:00
rstoyanchev bbe362c0e6 Allow null from RestClient exchange methods
Closes gh-33779
2024-10-23 19:08:54 +01:00
rstoyanchev bff76d756b Refactor implementation of retrieve in RestClient
Closes gh-33777
2024-10-23 18:59:07 +01:00
rstoyanchev d05f880d74 Fix test causing failure in RestClientObservationTests
See gh-33697
2024-10-23 12:24:28 +01:00
rstoyanchev 2b113e3fd0 Minor refactoring
Closes gh-33697
2024-10-23 11:38:19 +01:00
rstoyanchev 73e5aa38ec Polishing contribution
See gh-33697
2024-10-23 11:38:19 +01:00
Nicklas Wiegandt a0af708c03 Add cookie support to RestClient
See gh-33697
2024-10-23 11:38:18 +01:00
Brian Clozel d8c153a9d1 Remove support for Resin Servlet container
This commit removes all references to the Resin Servlet container, as it
is not supported as of Spring Framework 6.0 because we require a
JakartaEE baseline.

Closes gh-33772
2024-10-23 10:10:29 +02:00
Brian Clozel 1ba773170d Merge branch '6.1.x' 2024-10-23 09:26:40 +02:00
Brian Clozel 4a81f2c904 Remove HTTP parts workaround for Resin
A workaround was added for the Resin Servlet container in gh-13937.
This avoids attempting to delete parts that are not named, because the
`part.delete()` call would fail for non-file entries. This can be
problematic for files that are unnamed as they might not be removed by
the Framework.

This commit removes this workaround as Resin is not supported anymore.

Fixes gh-33511
2024-10-23 09:24:30 +02:00
rstoyanchev b7fc4bc5c8 Polishing contribution
Closes gh-33716
2024-10-22 17:37:45 +01:00
Ilya Serkov 657e002ed7 Fix HttpHeaders.setHost() to remove the header
See gh-33716
2024-10-22 17:37:44 +01:00
Brian Clozel 5f14703105 Merge branch '6.1.x' 2024-10-18 14:43:54 +02:00
Brian Clozel 67d78eb61c Avoid Servlet observations failures for invalid HTTP status
Prior to this commit, the `DefaultServerRequestObservationConvention`
for Servlet failed when the HTTP response status was invalid (for
example, set to "0").

This commit catches `IllegalArgumentException` thrown for such invalid
HTTP status and instead returns an unknown outcome for the observation.

Fixes gh-33725
2024-10-18 14:43:46 +02:00
Sébastien Deleuze e02f8ca492 Merge branch '6.1.x' 2024-10-18 12:37:00 +02:00
Johnny Lim 73fd9133e9 Fix Javadoc in ReactorNetty2ResourceFactory
See gh-33338
Closes gh-33735
2024-10-18 12:36:15 +02:00
Brian Clozel cee8b52de8 Merge branch '6.1.x' 2024-10-18 10:55:21 +02:00
Brian Clozel 912c067e23 Fix buffer leak in Jackson2 decoders
Prior to this commit, the Jackson2 decoders (JSON, Smile, CBOR) could
leak buffers in case the decoding operation times out or is cancelled
and some buffers are still in flight.

This commit ensures that buffers are released on cancel signals.

Fixes gh-33731
2024-10-18 10:51:38 +02:00
Johnny Lim cbdfe815aa Add Javadoc since for headers() in Delete/Patch/Post/PutExchange
See gh-33309
Closes gh-33723
2024-10-16 18:11:29 +02:00
rstoyanchev ca820c914f Polishing contribution
Closes gh-33715
2024-10-16 13:06:22 +01:00
Yanming Zhou f35ed8d044 Improve check whether to lowercase scheme
See gh-33715

```
Map has no value for 'thescheme'
java.lang.IllegalArgumentException: Map has no value for 'thescheme'
	at org.springframework.web.util.UriComponents$MapTemplateVariables.getValue(UriComponents.java:348)
	at org.springframework.web.util.UriComponents.expandUriComponent(UriComponents.java:263)
	at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:436)
	at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:53)
	at org.springframework.web.util.UriComponents.expand(UriComponents.java:161)
	at org.springframework.web.util.UriComponentsBuilder.buildAndExpand(UriComponentsBuilder.java:364)
```
2024-10-16 12:54:33 +01:00
rstoyanchev bdcfbee7df Merge branch '6.1.x' 2024-10-16 12:11:23 +01:00
rstoyanchev 23656aebc6 Use Locale.ROOT consistently for toLower/toUpperCase
See gh-33708
2024-10-16 12:05:54 +01:00
Juergen Hoeller fb6a6892ef Merge branch '6.1.x' 2024-10-16 11:36:30 +02:00
Juergen Hoeller feb6a5f52d Polishing 2024-10-16 11:35:23 +02:00
rstoyanchev c261ca3102 Ensure scheme not lowercased if URI variable
Closes gh-33699
2024-10-15 20:50:01 +01:00
Brian Clozel f204f4962d Document XML parser usage against security false positives
Prior to this commit, our XML parser usage would be already haredened
against XXE (XML External Entities) attacks. Still, we recently received
several invalid security reports claiming that our setup should be
hardened.

This commit documents a few usages of XML parsers to add some more
context and hopefully prevent future invalid reports.

Closes gh-33713
2024-10-15 18:59:02 +02:00
Sébastien Deleuze 60978ff4c7 Polish WebRequest Javadoc
See gh-33698
2024-10-14 17:07:07 +02:00
Tran Ngoc Nhan e191c34078 Polishing
Closes gh-33681
2024-10-14 16:44:42 +02:00
海子 Yang 3984266295 Remove unused method in UriComponentsBuilder
This commit removes HierarchicalUriComponents#checkSchemeAndHost
unused private method.

Closes gh-33684
2024-10-14 14:02:31 +02:00
Simon Baslé 12134e8619 Merge branch '6.1.x' 2024-10-14 11:57:39 +02:00
Simon Baslé 8da31e1db7 Reject CORS request with 403 if Origin header is malformed
When assessing if a request is a CORS request, both mvc and reactive
`DefaultCorsProcessor` now catch `IllegalArgumentException` and turn
this into a 403 rejection rather than letting the exception propagate
into a 500 response.

Closes gh-33688
2024-10-14 11:50:19 +02:00
Sangmin Park ae32227b50 Polish ServletWebRequest
Closes gh-33698
2024-10-14 11:38:24 +02:00
rstoyanchev 8520fa5e2a Reduce warnings in WhatWgUrlParser 2024-10-09 13:29:49 +01:00
rstoyanchev f4967f202e Revise URI template handling in WhatWgUrlParser
Closes gh-33673
2024-10-09 13:29:49 +01:00
rstoyanchev 1f4743af54 Lenient handling of malformed query in ServletServerHttpRequest
Closes gh-30489
2024-10-09 13:29:49 +01:00
Simon Baslé ef77b4064f Keep DefaultServerHttpRequestBuilder-mutated headers case-insensitive
This change avoids the trap of creating a copy of `HttpHeaders` using a
case-sensitive `MultiValueMap` by mistake. Since mutability is always
desirable, we make a mutable copy by using `addAll` on an empty
`HttpHeaders`.

We can't simply rely on HttpHeaders' map-based constructor to detect
read-only header in this particular case, because the container's
original headers representation might in some cases be read-only.

Closes gh-33666
2024-10-09 11:39:33 +02:00
rstoyanchev c4b6a02091 Polishing contribution
Closes gh-33594
2024-10-08 13:32:33 +01:00
Johnny Lim 1ec9a115a8 Replace RFC 7807 with RFC 9457 in documentation
See gh-33594
2024-10-08 13:32:33 +01:00
rstoyanchev 000b8a699c Auto-detect Reactor Netty client in RestClient
Closes gh-33635
2024-10-08 10:56:43 +01:00
rstoyanchev a84a41fa43 Polishing contribution
Closes gh-33638
2024-10-08 10:56:42 +01:00
Dariusz Jędrzejczyk a78385f8e5 Handle X-Forwarded-Prefix parsed by Reactor Netty
See gh-33638
2024-10-08 10:56:42 +01:00
rstoyanchev b13f86cf46 Fix failing tests in spring-test after recent changes
See gh-33639
2024-10-07 21:09:10 +01:00
rstoyanchev 2389748e25 Parameterize URI parsing tests
Closes gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev d6fcad9ad7 Add logging to RfcUriParser
See gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev ef0a21ec7a Update documentation for URI parsing types
See gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev 6c62965cbb Remove regular expressions from UriComponentsBuilder
See gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev bbb53d03c4 Pluggable URI parsing, use RFC parser by default
See gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev 52805da733 Add URI parser based on syntax in RFC 3986
See gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev 10f45223aa Rename UrlParser to WhatWgUrlParser
See gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev 6ba3bb54a0 Add efficient isUnreservedOrSubDelimiter method
isUnreserved and isSubDelimiter are usually checked together. It helps
to have a shortcut with an efficient lookup.

See gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev e04b115a7e Remove test for IPv4 compatible IPv6 address
An example of this can be found in RFC 2732, but it is obsoleted by
RFC 3986 whose syntax for IPv6address does not allow dots.

Also, Appendix D of RFC 3986:

As [RFC2732] defers to [RFC3513] for definition of an IPv6 literal
address, which, unfortunately, lacks an ABNF description of
IPv6address, we created a new ABNF rule for IPv6address that matches
the text representations defined by Section 2.2 of [RFC3513].

See gh-33639
2024-10-07 18:35:03 +01:00
rstoyanchev 92308ac83f Polishing in UrlParser 2024-10-07 18:35:02 +01:00
Juergen Hoeller c10a7f300c Merge branch '6.1.x' 2024-10-07 10:20:38 +02:00
Juergen Hoeller 3dac274d20 Avoid synchronization for delegate initialization
Closes gh-33656
2024-10-07 10:19:16 +02:00
Khyojun f86bc1cbe8 Polish CorsConfiguration
Closes gh-33650
2024-10-07 09:11:36 +02:00
Simon Baslé 6c5e63e446 Merge branch '6.1.x' 2024-10-03 16:33:40 +02:00
Simon Baslé b54420f8aa Include argument name in MethodArgumentTypeMismatchException message
Closes gh-33573
2024-10-03 16:32:29 +02:00
Juergen Hoeller 30dc86810e Upgrade to Jackson 2.18
Closes gh-33615
2024-09-30 13:53:22 +02:00
Juergen Hoeller b59d0a396e Add equals/hashCode methods to ServerSentEvent
Closes gh-33606
2024-09-30 11:22:43 +02:00
Juergen Hoeller 8ab965c981 Merge branch '6.1.x'
# Conflicts:
#	spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java
2024-09-30 11:17:55 +02:00
Juergen Hoeller 87157d3200 Polishing 2024-09-30 11:13:50 +02:00
Juergen Hoeller 95f181352f Defensively check MethodParameter.getMethod() in KotlinDelegate
Closes gh-33609
2024-09-30 11:13:26 +02:00
Juergen Hoeller 5326640f79 Initialize application context with initializer-given ServletContext
Closes gh-22319
2024-09-26 18:31:02 +02:00
Yanming Zhou 8941e2876e Replace 'e.g.' with 'for example' in documentation and comments
Closes gh-33515
2024-09-26 14:11:17 +02:00
rstoyanchev dea4f71846 Update contribution
Closes gh-33090
2024-09-25 16:09:01 +01:00
cfredri4 883f123583 Use only one timeout in JdkClientHttpRequest
Previously, a timeout was set both on HttpRequest, and used on
httpClient.sendAsync().get(). This leads to inconsistent behaviour
depending on which timeout gets triggered first.

See gh-33090
2024-09-25 16:09:01 +01:00
rstoyanchev 7051cddcf7 Align OutputStreamPublisher's
Align internal handling and contracts. The core copy could do without
those contracts, but it helps with alignment, and it's internal to
the implementation.

Closes gh-33592
2024-09-25 11:42:26 +01:00
rstoyanchev f6c31bb6c3 Align OutputStreamPublisher's
Update constructors to match and drop unnecessary factory methods.

See gh-33592
2024-09-25 11:42:26 +01:00
rstoyanchev 113b430fab Align OutputStreamPublisher's
Apply recent nullability changes, and formatting differences.

See gh-33592
2024-09-25 11:42:26 +01:00
Sébastien Deleuze 81a66a0334 Add an AbstractGenericHttpMessageConverter constructor
This commit adds a new
AbstractGenericHttpMessageConverter(Charset, MediaType...)
constructor, similar to the one present in
AbstractHttpMessageConverter.

Closes gh-33563
2024-09-24 19:40:15 +02:00
Sam Brannen f6fcf15745 Merge branch '6.1.x' 2024-09-24 12:33:58 +02:00
Sam Brannen af3a26ab06 Clean up warnings in Gradle build 2024-09-24 12:33:35 +02:00
Sam Brannen 66a518abd5 Merge branch '6.1.x' 2024-09-24 12:23:47 +02:00
Sam Brannen 88905ea20d Upgrade to Apache HttpClient 5.4
This commit also updates the external Javadoc link to avoid the following
warning in the build.

URL https://hc.apache.org/httpcomponents-client-5.2.x/current/httpclient5/apidocs/package-list was redirected to https://hc.apache.org/httpcomponents-client-5.4.x/current/httpclient5/apidocs/package-list

Closes gh-33587
2024-09-24 12:20:44 +02:00
Tran Ngoc Nhan c85050eb43 Consistently use CharSequence.isEmpty() for emptiness checks
Closes gh-33577
2024-09-23 17:10:21 +02:00
Sam Brannen 8931b75b95 Polishing 2024-09-20 10:58:37 +02:00
Johnny Lim 3ba9d35e22 Polish
Closes gh-33566
2024-09-20 10:58:37 +02:00
rstoyanchev 4706ebc81e Minor refactoring in UrlHandlerFilter
See gh-33565
2024-09-19 11:55:53 +01:00
rstoyanchev 2090ece62a UrlHandlerFilter ignores trailing slash in contextPath
Closes gh-33565
2024-09-19 11:55:25 +01:00
Simon Baslé c832d5f496 Polishing contribution
Fixes gh-33556
2024-09-18 11:44:29 +02:00
Carl Magnuson 453e7961a8 Add read timeout setter on HttpComponentsClientHttpRequestFactory
This commit adds support for HttpComponentsClientHttpRequestFactory to
set a read timeout, used on the underlying client as a RequestTimeout.

This brings the HttpComponentsClientHttpRequestFactory into alignment
with JDK, Jetty, OkHttp3, Reactor and SimpleClient
ClientHttpRequestFactory implementations.

See gh-33556
2024-09-18 11:44:29 +02:00
Sébastien Deleuze d3755aba06 Add RestClient.Builder#messageConverters(List)
This commit also introduces the validation of the RestClient
message converters for both variants.

Closes gh-33536
2024-09-13 16:00:38 +02:00
Brian Clozel 0a001482c3 Merge branch '6.1.x' 2024-09-13 15:53:18 +02:00
Brian Clozel 5efb385e64 Read Expires cookie attribute in HttpComponents connector
Prior to this commit, the HttpComponents implementation for the
`WebClient` would only consider the max-age attribute of response
cookies when parsing the response. This is not aligned with other client
implementations that consider the max-age attribute first, and then the
expires if the former was not present. The expires date is then
translated into a max-age duration. This behavior is done naturally by
several implementations.

This commit updates the `HttpComponentsClientHttpResponse` to do the
same.

Fixes gh-33157
2024-09-13 15:49:06 +02:00
Juergen Hoeller 042346aa6a Harmonize Reactor client class names within the http.client package
Closes gh-33382
2024-09-11 16:27:56 +02:00
rstoyanchev 1ff2678147 Add UrlHandlerFilter for WebFlux
Closes gh-32830
2024-09-11 11:51:21 +01:00
rstoyanchev 5671744a94 Refactoring in UrlHandlerFilterTests 2024-09-11 11:51:21 +01:00
rstoyanchev 9d57c0ba89 Add compare method to ETag
Closes gh-33385
2024-09-10 12:29:33 +01:00
rstoyanchev 19700d07b1 Quote ETag if not quoted in HttpHeaders#setETag
This aligns HttpHeaders with other places like ServletWebRequest and
DefaultWebExchange where an ETag is accepted as input.

It also allows us to remove quoting from places that delegate to
HttpHeaders#setETag since it now does that internally.

Closes gh-33412
2024-09-10 09:17:56 +01:00
rstoyanchev 3dd4a8350a Update more places to use quoteETagIfNecessary
Closes gh-33412
2024-09-10 08:56:03 +01:00
rstoyanchev 1b26122e64 Polishing and minor refactoring
Update checks whether quoting is needed to be more complete
than what we've used so far, making sure the there is both
opening and closing quotes independent of each other.

See gh-33412
2024-09-10 08:56:01 +01:00
hyunmin0317 80b264ba82 Refactor eTag formatting into utility method
See gh-33412
2024-09-10 08:55:39 +01:00
Sébastien Deleuze cc3f4b87ff Update mime.types
This commit updates mime.types based on revision 1918129 of
https://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types.

Closes gh-33512
2024-09-09 19:23:57 +02:00
Sébastien Deleuze 413cbca2c0 Remove commented entries from mime.types
See gh-33512
2024-09-09 18:59:29 +02:00
Sam Brannen eff19ec972 Sync MockHttpServletRequest implementations 2024-09-09 15:42:21 +02:00
rstoyanchev d2b25c0378 Merge branch '6.1.x' 2024-09-09 11:56:21 +01:00
rstoyanchev 3d1bf28445 Refine how async request state lock is obtained
Rather than waiting indefinitely, keep checking if the state
changed from ASYNC (e.g. to ERROR).

Closes gh-33421
2024-09-09 11:54:38 +01:00
Sébastien Deleuze 5e3c5d466f Avoid collecting Flux elements in KotlinSerializationJsonEncoder
Closes gh-33428
2024-09-05 14:47:49 +02:00