Commit Graph

1137 Commits

Author SHA1 Message Date
Rossen Stoyanchev a234b90abb Explicit content-type for resources
BodyInserters.ofResource now respects the Content-Type, if specified on
the client request or server response.

Closes gh-24366
2020-01-20 17:09:47 +00:00
Rossen Stoyanchev b1d93bb307 Polishing contribution
See gh-24367
2020-01-16 16:01:31 +00:00
Jacob Severson 8e67b7b2cf Expose proxyPing Reactor Netty WebSocket
See gh-24331
2020-01-16 16:01:31 +00:00
Sébastien Deleuze bc7d010485 Update CORS support
This commit updates CORS support in order to check Origin header
in CorsUtils#isPreFlightRequest which does not change how Spring
MVC or WebFlux process CORS request but is more correct in term
of behavior since it is a public API potentially used in another
contexts.

It also removes an unnecessary check in
AbstractHandlerMethodMapping#hasCorsConfigurationSource and processes
every preflight request with PreFlightHandler.

Closes gh-24327
2020-01-13 08:33:14 +01:00
Brian Clozel a31a4f8148 Copy strategiesConfigurers when cloning WebClient.Builder
This commit fixes the missing `strategiesConfigurers` copy when the
`WebClient.Builder` is cloned.

Fixes gh-24329
2020-01-10 15:59:59 +01:00
Rossen Stoyanchev 34d32402d3 Return 500 if producible attribute present
When a request is mapped through a producible condition on an
@RequestMapping, then a failure to find a converter/decoder should be
a 500 because the return type + media type pair were declared by the
controller and that should be possible to render.

Closes gh-23287
2020-01-09 11:10:44 +00:00
Sam Brannen ef6b1ba034 Update copyright date 2020-01-07 17:15:23 +01:00
stsypanov c480a99a77 Trim line from LineInfo only once 2020-01-07 14:44:09 +01:00
Brian Clozel ffc1f960f9 Polish
See gh-24238
2020-01-07 09:05:49 +01:00
Brian Clozel f9c1565f4e Remove Content-* response headers for error handling
Prior to this commit, when WebFlux handlers added `"Content-*"` response
headers and an error happened while handling the request, all those
headers would not be cleared from the response before error handling.

This commit clears those headers from the response in two places:
* when invoking the handler and adapting the response
* when writing the response body

Not removing those headers might break HTTP clients since they're given
wrong information about how to interpret the HTTP response body: the
error response body might be very different from the original one.

Fixes gh-24238
2020-01-06 16:55:08 +01:00
Sam Brannen 081b3d304d Move JavaUtilLoggingConfigurer to spring-core test fixtures
See gh-23550
2020-01-03 14:34:29 +01:00
Sam Brannen 7b6d83a106 Use Gradle test fixture support for spring-web
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 7cd4ddf5fc Rename test fixture package in spring-beans
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 4260c34b47 Rename test fixture package in spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 61d4ee594d Use Gradle test fixture support for spring-beans and spring-context
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Brian Clozel 75fd391fc7 Remove quality parameter from selected media type
Prior to this commit, WebFlux application would keep the quality
parameter from the "Accept" request header when selecting a media type
for the response. It would then echo it back to the client.

While strictly not wrong, this is unnecessary and can confuse HTTP
clients. This commit aligns WebFlux's behavior with Spring MVC.

Fixes gh-24239
2020-01-02 11:29:04 +01:00
Rossen Stoyanchev a1b8b18282 Polishing logPrefix Javadoc in ClientRequest|Response
Closes gh-23791
2019-12-20 09:27:40 +00:00
Rossen Stoyanchev 7456fb9c65 Add failing test to be fixed
See gh-23791
2019-12-20 09:15:44 +00:00
Arjen Poutsma 09b6730f3d Expose logPrefix in ClientResponse
This commit exposes the logPrefix field in the ClientResponse interface.

Closes gh-24146
2019-12-13 10:59:53 +01:00
Rossen Stoyanchev dd9b6287b4 Expose ClientCodecConfigurer in WebClient.Builder
Using Consumer<ClientCodecConfigurer> instead of
Consumer<ExchangeStrategies> eliminates one level of nesting that is
also unnecessary since codecs are the only strategy at present.

Closes gh-24124
2019-12-12 21:58:14 +00:00
Rossen Stoyanchev 11e321b8e7 Add register methods to CodecConfigurer.CustomCodecs
The new register methods replace the now deprecated
encoder, decoder, reader, and writer methods, and also offer a choice
to opt into default properties such maxInMemorySize, if configured.

See gh-24124
2019-12-12 21:58:14 +00:00
Rossen Stoyanchev 1b172c1d20 Expose localAddress in WebFlux server
Closes gh-24174
2019-12-10 15:10:13 +00:00
Rossen Stoyanchev 828fe39523 Consistently use releaseBody in DefaultWebClient
See gh-24125
2019-12-04 18:19:52 +00:00
Rossen Stoyanchev 3a48682226 Replace ReadCancellationException with takeWhile
Closes gh-24125
2019-12-04 18:19:52 +00:00
Rossen Stoyanchev fcbc437825 Polishing (follow-up on acfeb7) 2019-12-02 17:14:13 +00:00
Rossen Stoyanchev 50ac8ad8b7 Fix checkstyle violation 2019-12-02 14:25:00 +00:00
Rossen Stoyanchev acfeb77d41 Polishing
See gh-23961
2019-12-02 14:12:59 +00:00
Brian Clozel d4209392d2 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-23961
2019-12-02 14:12:59 +00:00
Brian Clozel 1560bbd81e Revert "Allow ExchangeStrategies customizations in WebClient"
This reverts commit b3020bc484.
2019-12-02 10:39:53 +01:00
Juergen Hoeller 567c7695dd Polishing 2019-12-01 00:20:00 +01:00
Brian Clozel b3020bc484 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-23961
2019-11-29 22:26:52 +01:00
Rossen Stoyanchev b44daa8b71 Remove the few remaining usages of UriTemplate
Also update Javadoc of UriTemplate to point to UriComponentsBuilder and
UriBuilderFactory as more flexible options.

See gh-24094
2019-11-28 11:28:49 +00:00
Rossen Stoyanchev 70a3dbff24 WebSession creation does not block
Closes gh-24027
2019-11-26 10:48:39 +00:00
Arjen Poutsma a79eaded5d Javadoc 2019-11-25 16:23:27 +01:00
Sébastien Deleuze 6c7250b0ae Make Kotlin DSL class constructors internal
Closes gh-24059
2019-11-22 16:10:42 +01:00
Sébastien Deleuze 712eac2915 Refine Coroutines annotated controller support
This commit refines Coroutines annotated controller support
by considering Kotlin Unit as Java void and using the right
ReactiveAdapter to support all use cases, including suspending
functions that return Flow (usual when using APIs like WebClient).

It also fixes RSocket fire and forget handling and adds related tests
for that use case.

Closes gh-24057
Closes gh-23866
2019-11-22 14:13:17 +01:00
Arjen Poutsma e8b81ffc16 Improve documentation of WebClient.Builder::filter
Closes gh-23342
2019-11-20 11:55:25 +01:00
Arjen Poutsma 9f7dd9f352 Add test for usage of bodyToMono in WebClient.ResponseSpec::onStatus
See gh-23365
2019-11-19 10:22:54 +01:00
Sam Brannen d38b07b450 Move JavaUtilLoggingConfigurer to web.reactive.fixtures package 2019-11-14 15:50:04 +01:00
Sam Brannen 7991066345 Fix classpath 2019-11-14 15:25:26 +01:00
Sam Brannen 89b3a9cef2 Introduce JavaUtilLoggingConfigurer to configure JUL for tests 2019-11-14 14:30:21 +01:00
Sébastien Deleuze 6fa9871a70 Provide orNull extensions for WebFlux ServerRequest
Closes gh-23761
2019-11-13 17:59:51 +01:00
Arjen Poutsma a7a88371e7 Allow for decode method to return null in AbstractJackson2Decoder
Prior to this commit, the decoder did not allow for a null value
returned from the Jackson object reader.

Closes: gh-23935
2019-11-11 16:48:30 +01:00
Biju Kunjummen 5ee990e045 Use Function.identity
Closes gh-2024
2019-11-11 15:04:29 +00:00
Sam Brannen d03ab79531 Polish contribution
See gh-23970
2019-11-11 15:16:07 +01:00
Andy Wilkinson f7bc8c8268 Tidy up classpath pollution caused by resource creation in the tests
Previously, spring-webmvc and spring-webflux both contained tests
that would create gzipped files, write them to the filesystem
alongside the project's compiled test classes, and configure them to
be deleted on JVM exit. The output location placed the files on the
classpath, polluting it for every subsequent test that used the same
ClassLoader. The test-sources plugin combined with Gradle's use of
worker JVMs, broadens the scope of this pollution to other, downstream
projects in the same build. For example, the tests for
spring-websocket will have a different classpath depending on whether
or not the tests for spring-webmvc have already been run on the same
worker as part of the current build.

This commit updates the spring-webmvc and spring-webflux modules to
introduce a new JUnit Jupiter extension, GzipSupport. This extension
allows gzipped files to be created via an injectable GzippedFiles
class and automatically deletes each created file in an after-each
callback. This ensures that a gzipped file only exists on the
classpath for the duration of the test that needs it, avoiding the
pollution of the classpath of any subsequent tests.

Closes gh-23970
2019-11-11 15:11:10 +01:00
Rossen Stoyanchev 0e1a237139 Polishing 2019-11-08 09:17:25 +00:00
Johnny Lim 91f5f42d13 Add tests for PrincipalMethodArgumentResolver 2019-11-08 08:48:56 +00:00
Rossen Stoyanchev 203977972b Fix issue with path matching options
Closes gh-23907
2019-11-06 17:54:39 +00:00