Commit Graph

3885 Commits

Author SHA1 Message Date
Juergen Hoeller 47a7abee8f Polishing 2024-05-21 12:28:48 +02:00
Juergen Hoeller 8323c87ea2 Polishing 2024-05-14 13:31:30 +02:00
Arjen Poutsma b3724ebf84 Fix guard against multiple subscriptions
This commit changes the guard against multiple subscriptions, as the
previously used doOnSubscribe hook could not function as guard in
certain scenarios.

See gh-32727
Closes gh-32728
2024-04-30 16:20:54 +02:00
Juergen Hoeller 0c307b513e Polishing 2024-04-23 16:41:52 +02:00
yhao3 ceeb55291a Update links to HttpOnly documentation at OWASP in ResponseCookie
See gh-32663
Closes gh-32668

(cherry picked from commit 7f27ba3902)
2024-04-18 12:01:30 +02:00
Brian Clozel 7678286fb3 Refine UriComponentsBuilder parsing
This commit refines the expressions for the scheme, user info, host and
port parts of the URL in UriComponentsBuilder to better conform to
RFC 3986.

Fixes gh-32618
2024-04-11 08:50:46 +02:00
Juergen Hoeller f7f1028428 Remove superfluous @NonNull declarations 2024-03-16 14:39:58 +01:00
rstoyanchev 297cbae299 Extract reusable checkSchemeAndPort method
Closes gh-32440
2024-03-14 08:49:55 +00:00
Juergen Hoeller 274fba47f3 Additional unit tests for operations on empty UriTemplate
See gh-32432

(cherry picked from commit 54a6d89da7)
2024-03-13 18:34:17 +01:00
Kasper Bisgaard 5dfec09edd Allow UriTemplate to be built with an empty template
Closes gh-32438
2024-03-13 17:38:27 +01:00
rstoyanchev b8b1f5b6be Add missed merge changes from last commit
See gh-32342
2024-03-05 12:28:54 +00:00
rstoyanchev 99e38ecf41 Backport tests for wrapping of response for async requests
This is a backport of commits 4b96cd and ef0717.

Closes gh-32342
2024-03-05 12:11:55 +00:00
rstoyanchev e668e7767c Wrap PrintWriter in StandardServletAsyncWebRequest
Closes gh-32342
2024-03-03 18:38:40 +00:00
rstoyanchev 30c75ffe8e Avoid locking if not handling asynchronously
Avoid the overhead of locking in the ServletOutputStream wrapper
if it is not an asynchronous request.

See gh-32342
2024-03-03 18:38:05 +00:00
rstoyanchev dd5fe68522 Dispatch again after disconnected client error
Dispatching was prevented for disconnected client errors after
recent reports like #32042 when running on Tomcat, and the
async request was completed from the onError notification.
This has the side effect of not allowing exception resolvers
to take final action even if the response is not writeable.

After all updates for this issue, it appears the dispatch no
longer causes issues. Tomcat actually does not do the dispatch,
but it doesn't seem to cause any issues, and on other servers
like Jetty where the dispatch works, applications can have a
chance to handle the exception.

This change removes the disconnected client checks and allows
dispatching again. After the change DisconnectedClientHelper
is no longer needed in the 5.3.x branch.

See gh-32342
2024-03-03 18:37:21 +00:00
rstoyanchev 2aca714010 Add locking in StandardServletAsyncWebRequest
The lock protects against race between onError/onComplete notifications
and operations on the ServletOutputStream.

See gh-32342
2024-03-01 18:21:59 +00:00
rstoyanchev 3b7c435134 Polishing
See gh-32342
2024-03-01 15:57:16 +00:00
rstoyanchev 6432b13a4c Add state and response wrapping to StandardServletAsyncWebRequest
The wrapped response prevents use after AsyncListener onError or completion
to ensure compliance with Servlet Spec 2.3.3.4.

See gh-32342
2024-03-01 14:31:41 +00:00
rstoyanchev 3478a702e5 Improve concurrent handling of result in WebAsyncManager
1. Use state transitions
2. Increase synchronized scope in setConcurrentResultAndDispatch

See gh-32342
2024-02-29 20:43:31 +00:00
rstoyanchev b31550fd85 Align 5.3.x with 6.1.x
In preparation for a larger update, start by aligning with
6.1.x, which includes changes for gh-32042 and gh-30232.

See gh-32342
2024-02-29 17:48:09 +00:00
Juergen Hoeller ce385d136d Consistent nullability for internal field access 2024-02-28 21:12:57 +01:00
Arjen Poutsma e44f84e8ee Restore Jetty 10 compatibility in JettyClientHttpResponse
Closes gh-32337
2024-02-28 13:33:18 +01:00
Sam Brannen 464fa7ea0e Do not cache Content-Type in ContentCachingResponseWrapper
Based on feedback from several members of the community, we have
decided to revert the caching of the Content-Type header that was
introduced in ContentCachingResponseWrapper in 375e0e6827.

This commit therefore completely removes Content-Type caching in
ContentCachingResponseWrapper and updates the existing tests
accordingly.

To provide guards against future regressions in this area, this commit
also introduces explicit tests for the 6 ways to set the content length
in ContentCachingResponseWrapper and modifies a test in
ShallowEtagHeaderFilterTests to ensure that a Content-Type header set
directly on ContentCachingResponseWrapper is propagated to the
underlying response even if content caching is disabled for the
ShallowEtagHeaderFilter.

See gh-32039
See gh-32317
Closes gh-32322
2024-02-28 11:13:59 +01:00
Sam Brannen 6e1f583c06 Polish ShallowEtagHeaderFilterTests 2024-02-28 11:06:55 +01:00
Sébastien Deleuze 57646a092e Refine *HttpMessageConverter#getContentLength null safety
Closes gh-32332
2024-02-27 15:50:06 +01:00
Sam Brannen 380f5d5ea4 Honor Content-[Type|Length] headers from wrapped response again
Commit 375e0e6827 introduced a regression in
ContentCachingResponseWrapper (CCRW). Specifically, CCRW no longer
honors Content-Type and Content-Length headers that have been set in
the wrapped response and now incorrectly returns null for those header
values if they have not been set directly in the CCRW.

This commit fixes this regression as follows.

- The Content-Type and Content-Length headers set in the wrapped
  response are honored in getContentType(), containsHeader(),
  getHeader(), and getHeaders() unless those headers have been set
  directly in the CCRW.

- In copyBodyToResponse(), the Content-Type in the wrapped response is
  only overridden if the Content-Type has been set directly in the CCRW.

Furthermore, prior to this commit, getHeaderNames() returned duplicates
for the Content-Type and Content-Length headers if they were set in the
wrapped response as well as in CCRW.

This commit fixes that by returning a unique set from getHeaderNames().

This commit also updates ContentCachingResponseWrapperTests to verify
the expected behavior for Content-Type and Content-Length headers that
are set in the wrapped response as well as in CCRW.

See gh-32039
See gh-32317
Closes gh-32322
2024-02-25 18:08:12 +01:00
Sam Brannen 1acc1c3a27 Polish ContentCachingResponseWrapper[Tests] 2024-02-25 18:02:59 +01:00
Juergen Hoeller 452973fbbd Consistent Lock field declaration (instead of ReentrantLock field type)
(cherry picked from commit b4153618a4)
2024-02-13 11:31:55 +01:00
rstoyanchev 7ec5c994c1 Update user info pattern
Closes gh-32211
2024-02-13 07:18:50 +00:00
Juergen Hoeller 60035b5e39 Polishing 2024-02-01 17:41:50 +01:00
Arjen Poutsma 186d6e370d Guard against multiple body subscriptions
Before this commit, the Jetty connector did not have any
safeguard against multiple body subscriptions. Such as check has now
been added.

See gh-32100
Closes gh-32101
2024-01-24 14:05:06 +01:00
Juergen Hoeller 732642d8ad Declare allowPrivateNetwork as available since 5.3.32
See gh-28546
See gh-31974
2024-01-24 12:22:51 +01:00
Juergen Hoeller d7649d088d Polishing 2024-01-24 12:20:35 +01:00
Juergen Hoeller 7ac66eff4d Consistent nullability for concurrent result
(cherry picked from commit b92877990d)
2024-01-24 12:05:33 +01:00
Juergen Hoeller f22bdf4734 Polishing 2024-01-19 17:29:16 +01:00
Arjen Poutsma a0f24cf485 Handle Content-Length in ShallowEtagHeaderFilter more robustly
This commit ensures that setting the Content-Length through
setHeader("Content-Length", x") has the same effect as calling
setContentLength in the ShallowEtagHeaderFilter. It also filters out
Content-Type headers similarly to Content-Length.

See gh-32039
Closes gh-32051
2024-01-18 16:07:02 +01:00
rstoyanchev fd240b3b86 Double-checked lock in ChannelSendOperator#request
Closes gh-31865
2024-01-12 17:18:19 +00:00
Sébastien Deleuze df1bec9e97 Polishing
See gh-31974
2024-01-08 12:23:23 +01:00
Sébastien Deleuze cfec88bfa8 Add CORS support for Private Network Access
This commit adds CORS support for Private Network Access
by adding an Access-Control-Allow-Private-Network response
header when the preflight request is sent with an
Access-Control-Request-Private-Network header and that
Private Network Access has been enabled in the CORS
configuration.

See https://developer.chrome.com/blog/private-network-access-preflight/
for more details.

Closes gh-31974

(cherry picked from commit 318d460256)
2024-01-08 11:49:00 +01:00
Juergen Hoeller b2bdc7de30 Polishing 2023-12-30 15:51:05 +01:00
Brian Clozel 687676ea47 Fix ordering of releasing resources in JSON Encoder
Prior to this commit, the Jackson 2.x encoders, in case of encoding a
stream of data, would first release the `ByteArrayBuilder` and then the
`JsonGenerator`. This order is inconsistent with the single value
variant (see `o.s.h.codec.json.AbstractJackson2Encoder#encodeValue`) and
invalid since the `JsonGenerator` uses internally the
`ByteArrayBuilder`.

In case of a CSV Encoder, the codec can buffer data to write the column
names of the CSV file. Writing an empty Flux with this Encoder would not
fail but still log a NullPointerException ignored by the reactive
pipeline.

This commit fixes the order and avoid such issues at runtime.

Fixes gh-31657
2023-11-22 21:35:16 +01:00
Arjen Poutsma d3ec9395e1 Guard for empty FileItems in CommonsFileUploadSupport
This commit ensures that a FileItem is not empty before its value is
read.

Closes gh-31564
2023-11-08 15:35:17 +01:00
Sébastien Deleuze 75faf698af Refine CORS documentation for wildcard processing
This commit refines CORS wildcard processing Javadoc to
provides more details on how wildcards are handled for
Access-Control-Allow-Methods, Access-Control-Allow-Headers
and Access-Control-Expose-Headers CORS headers.

For Access-Control-Expose-Headers, it is not possible to copy
the response headers which are not available at the point
when the CorsProcessor is invoked. Since all the major browsers
seem to support wildcard including on requests with credentials,
and since this is ultimately the user-agent responsibility to
check on client-side what is authorized or not, Spring Framework
continues to support this use case.

See gh-31168
2023-09-11 18:15:07 +02:00
Sam Brannen 88c3a788f3 Update copyright headers 2023-08-21 15:12:54 +02:00
Juergen Hoeller df066d8190 Fix accidental javadoc references to jakarta packages 2023-08-16 13:03:23 +02:00
Juergen Hoeller 340b32a3cb Polishing 2023-07-19 23:31:38 +02:00
Juergen Hoeller a7b7466274 Polishing 2023-07-19 01:17:25 +02:00
rstoyanchev 1cd994d3a8 Encapsulate full path initialization 2023-07-11 11:45:23 +01:00
Juergen Hoeller da814e01c7 Polishing 2023-07-04 21:52:36 +02:00
Juergen Hoeller 5d4c2846d9 Polishing 2023-07-04 16:43:29 +02:00