Commit Graph

675 Commits

Author SHA1 Message Date
Rossen Stoyanchev
ae034e9afe Polish content disposition 2017-01-25 17:19:30 -05:00
Rossen Stoyanchev
c8f98ecd8d Add MockPart to spring-test
Issue: SPR-14252
2017-01-25 17:05:25 -05:00
Rossen Stoyanchev
f2e293aadf UriComponents allows "+" in a query param
Issue: SPR-14828
2017-01-18 21:04:37 -05:00
Rossen Stoyanchev
b609f3a546 WebHttpHandlerBuilder supports @Order on beans
Issue: SPR-15074
2017-01-18 20:55:29 -05:00
Rossen Stoyanchev
9faaa22fd4 Enable reactive web integration tests 2017-01-18 20:55:29 -05:00
Brian Clozel
a0427209d8 Upgrade to Reactor Aluminium SNAPSHOT 2017-01-18 22:30:28 +01:00
Juergen Hoeller
ad5386773e ContentCachingRequestWrapper supports content cache limit
Issue: SPR-14829
2017-01-17 20:42:19 +01:00
Rossen Stoyanchev
9819558cba Support encoded query string in reactive requests
In addition to the updates from PR#1297 this commit adds an integration
test and fixes for the resulting failures with RxNetty, Reactor Netty,
and Undertow.

Also replaced use of URLDecoder which is not for decoding URIs with use
of UriUtils for decoding query parameters.

Issue: SPR-15140
2017-01-17 12:46:05 -05:00
Eiichi Sato
613e65f043 Fix URL decoding issue in reactive @RequestParam
%-encoded strings were injected undecoded into @RequestParam variables,
which does not coincide with spring-webmvc behaviour. This commit
fixes AbstractServerHttpRequest.getQueryParams() to correctly return
decoded name-value pairs.

Issue: SPR-15140
2017-01-17 12:46:05 -05:00
Juergen Hoeller
047786acef Revised InvocableHandlerMethod exception messages (controller vs endpoint vs handler)
Introduces dedicated MethodArgumentResolutionException for spring-messaging invocations.

Issue: SPR-15139
2017-01-16 21:14:46 +01:00
Vedran Pavić
83beb9d57d Set MockSessionCookieConfig#maxAge default to -1
Issue: SPR-15142
2017-01-16 03:17:54 +01:00
Rossen Stoyanchev
ba3cc535f1 Refactor reactive mock request and response support
MockServerHttpRequest and MockServerHttpResponse now extend the same
abstract base classes that server-specific implementations do and
therefore approximate their behavior more closely.

As an immediate consequence MockServerHttpRequest is read-only after
it is created. Instead it now exposes static builder methods similar
to those found in RequestEntity. This enforces more strictness as well
as recycling of requests in tests and provides nicer builder methods.

To simplify tests DefaultServerWebExchange now offers a constructor
with just a request and response, and automatically creating a
DefaultWebSessionManager.

The spring-test module now also contains client-side reactive mock
request and response implementations. The mock client request extends
the same AbstractClientHttpRequest as client-specific implementations
do. There is no abstract base class for client responses.

Issue: SPR-14590
2017-01-13 15:23:06 -05:00
Juergen Hoeller
743ce2cda6 Polishing 2017-01-12 23:30:38 +01:00
Juergen Hoeller
02d727fd7c MockHttpServletRequestBuilder supports multiple locales
Includes revised content type handling.

Issue: SPR-15116
2017-01-12 21:17:54 +01:00
Sebastien Deleuze
aa43472f2e Fix error handling in Jackson2JsonDecoder
Issue: SPR-15112
2017-01-09 14:51:16 +01:00
Sam Brannen
9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Brian Clozel
afd93a0b52 Disable streaming when reading to Resources in RestTemplate
Prior to this commit, the `ResourceHttpMessageConverter` would support
converting from an `HttpInputMessage` to a `InputStreamResource`. This
is valid when reading resources on the server side, but it's not
compatible with the way `RestTemplate` works.

The API exposed by `RestOperations` imply that the HTTP server response
should be fully consumed and properly closed by the time the `exchange`
method returns. In other words, this HTTP client does not support
streaming the HTTP response.

This commit allows the `ResourceHttpMessageConverter` to be configured
to disable read streaming when used in `RestTemplate`.

Issue: SPR-14882
2017-01-05 14:48:35 +01:00
Rob Winch
df98d304fd Fix ForwardedHeaderFilter with non-empty contextPath
Issue: SPR-15088
2017-01-03 14:51:31 -06:00
Brian Clozel
1ab0916bed Fix default content-type for ResourceRegion HTTP responses
Prior to this commit, the `ResourceRegionHttpMessageConverter` would
rely on the default implementation of `getDefaultContentType` to guess
the default Content-Type of the resource region to be written to the
HTTP response. That implementation fetches the first media type
provided in the HTTP request "Accept" header.

This behavior is not correct when converting resources and this commits
aligns this converter with the `ResourceHttpMessageConverter` which uses
JAF to guess the correct Content-Type of the given resource, or just
returns "application/octet-stream" as a default value.

Issue: SPR-15041
2017-01-02 22:04:20 +01:00
Juergen Hoeller
311522bc86 Run reactive integration tests only as part of performance group 2016-12-29 22:41:23 +01:00
Juergen Hoeller
ef5c797569 Polishing 2016-12-23 21:23:30 +01:00
Brian Clozel
54901ab865 Avoid explicit DecoratedObjectFactory setup in JettyRequestUpgradeStrategy
Align Jetty support on spring-websocket module.

Issue: SPR-14940
2016-12-21 17:27:27 +01:00
Sebastien Deleuze
69b69442bc Add ServerSentEventHttpMessageReader
This HTTP message reader parse incoming Server-Sent
Events and turn them into Flux<String>, Flux<Pojo>
or Flux<ServerSentEvent>.

Issue: SPR-14539
2016-12-21 17:07:41 +01:00
Sebastien Deleuze
419d2b4e0a Polish ServerSentEventHttpMessageWriterTests 2016-12-21 16:46:43 +01:00
Juergen Hoeller
b54aee27be Polishing 2016-12-21 14:42:43 +01:00
Sebastien Deleuze
712a63205c Add HttpHeaders#setAcceptLanguageAsLocale(Locale)
Issue: SPR-15024
2016-12-20 22:33:09 +01:00
Stephane Maldini
241d5f7a3b Sync reactor-netty client response update and uncomment in tests 2016-12-20 14:37:32 +00:00
Sebastien Deleuze
7bde85ae55 Fix previous commit 2016-12-19 10:21:36 +01:00
Sebastien Deleuze
879b387954 Disable temporarily reactor-netty integration tests 2016-12-19 09:55:58 +01:00
Rossen Stoyanchev
bd8af55bc7 getAcceptLanguageAsLocale(s) returns most preferred Locale
An update on the last commit switching from:
List<Locale> getAcceptLanguageAsLocales() to
Locale getAcceptLanguageAsLocale()

This best supports the scenario for the most preferred Locale.
If there is a need to look at the prioritized list of languages it's
best to use Locale.filter with the LocaleRange's.

This is explained in the Javadoc for getAcceptLanguage().

Issue: SPR-15024
2016-12-16 17:15:43 -05:00
Rossen Stoyanchev
fa56361ad2 Add getAcceptLanguageAsLocales
The use of Locale.LanguageRange for the Accept-Language header makes
sense as it gives the most flexibility for a client to set a weighted
list and for a server to do filtering via Locale#filter.

This commit adds an additional convenience method that turns
the LangugeRange list to a list of Locale's also filtering out a
wildcard (i.e. "*"). A List<Locale> is the most basic way to access
prefered languages and needed when filtering is not required.

Issue: SPR-15024
2016-12-16 16:20:06 -05:00
Stephane Maldini
7d9e8def44 uncomment reactor-netty in tests 2016-12-16 20:09:32 +00:00
Rob Winch
db2ebd30da Add Support for ForwardedHeaderFilter sendRedirect
Previously ForwrdedHeaderFilter did not ensure that
HttpServletResponse.sendRedirect worked properly based on
X-Forwarded-* headers.

This commit updates ForwardedHeaderFilter to overrided the
HttpServletResponse.sendRedirect method to ensure
X-Forwarded-* headers are honored.

Issue SPR-15020
2016-12-15 17:04:57 -05:00
Rossen Stoyanchev
96474405dc Refactor ServerWebExchange/ServerHttpRequest builders
ServerWebExchange.Builder has an additional Consumer-style shortcut
method that accepts a builder for modifying the request.

ServerWebExchange and ServerHttpRequest builders have fewer methods,
more use-case focused vs matching directly to properties.
2016-12-15 17:02:05 -05:00
Rossen Stoyanchev
6119415427 Support for "request parameters"
ServerWebExchange now provides access to "requestParams" as a
MulitValueMap with query parameters and form data combined.

The combined map is then used for the params condition of
@RequestMapping purposes () and also for @RequestParam arguments.

Issue: SPR-15000
2016-12-15 14:24:39 -05:00
Sebastien Deleuze
36da299f96 Add set/getContentLanguage() to HttpHeaders
Issue: SPR-14536
2016-12-15 17:30:53 +01:00
Sebastien Deleuze
9764d57433 Add set/getAcceptLanguage() to HttpHeaders
Issue: SPR-15024
2016-12-15 17:19:37 +01:00
Arjen Poutsma
97558ab4de Move Body[Inserter|Extractor] to web.reactive.function 2016-12-15 13:22:11 +01:00
Arjen Poutsma
aa8f531526 Move WebClient to web.reactive.function.client 2016-12-15 13:22:11 +01:00
Sebastien Deleuze
dfcd5b9ed9 Add a test to validate Reactor Netty automatic flushing
Issue: SPR-14992
2016-12-15 13:08:36 +01:00
Stephane Maldini
c201a14ea2 Temp disabling reactor-netty to unblock pipeline 2016-12-15 04:11:34 +00:00
Rossen Stoyanchev
4738a61e98 Early registration of ReadListener
This is similar to the WriteListener changes on the ServerHttpResponse
where we are more naturally exposed to a delayed write. Nevertheless
we could also have a delayed read and should be consistent. The early
initialization of the RequestBodyPublisher also simplifies the
internal implementation a bit.
2016-12-14 16:17:46 -05:00
Juergen Hoeller
29543856ec OkHttpClientHttpRequestFactory allows POST request without body
Issue: SPR-15015
2016-12-14 22:05:34 +01:00
Rossen Stoyanchev
5a29069798 Refactor AsyncListener registration + polish
Instead of registering an AsyncListener in ServletHttpHandlerAdapter
we now register an AsyncListener in each of the request and response
where the events need to be handled anyway. This allows removing the
package private delegation methods in the request and response.
2016-12-14 15:34:58 -05:00
Rossen Stoyanchev
70f14c14c8 Polish Undertow reactive server support 2016-12-14 14:51:33 -05:00
Arjen Poutsma
582e625fcf Allow HandlerFunction to return Mono<ServerResponse>
This commit makes it possible for handler functions to return
asynchronous status codes and headers, by making HandlerFunction.handle
return a Mono<ServerResponse> instead of a ServerResponse. As a
consequence, all other types that deal with HandlerFunctions
(RouterFunction, HandlerFilterFunction, etc.) had to change as well.

However, when combining the above change with method references (a very
typical use case), resulting signatures would have been something like:

```
public Mono<ServerResponse<Mono<Person>>> getPerson(ServerRequest request)
```

which was too ugly to consider, especially the two uses of Mono. It was
considered to merge ServerResponse with the last Mono, essentialy making
ServerResponse always contain a Publisher, but this had unfortunate
consequences in view rendering.

It was therefore decided to drop the parameterization of ServerResponse,
as the only usage of the extra type information was to manipulate the
response objects in a filter. Even before the above change this was
suggested; it just made the change even more necessary.

As a consequence, `BodyInserter` could be turned into a real
`FunctionalInterface`, which resulted in changes in ClientRequest.

We did, however, make HandlerFunction.handle return a `Mono<? extends
ServerResponse>`, adding little complexity, but allowing for
future `ServerResponse` subtypes that do expose type information, if
it's needed. For instance, a RenderingResponse could expose the view
name and model.

Issue: SPR-14870
2016-12-14 16:52:36 +01:00
Sebastien Deleuze
4021d239ab Fix JsonObjectDecoder with '[' starting chunk
Issue: SPR-15013
2016-12-14 14:53:12 +01:00
Rossen Stoyanchev
c66dd01724 Equal MockServerHttpResponse in spring-test and -web 2016-12-14 05:54:53 -05:00
Sebastien Deleuze
4519c236d6 Restore reactor-netty test in FlushingIntegrationTests 2016-12-14 11:05:18 +01:00
Sebastien Deleuze
1829adecb7 Disable temporarily reactor-netty in FlushingIntegrationTests 2016-12-14 09:34:19 +01:00