Commit Graph

495 Commits

Author SHA1 Message Date
Arjen Poutsma
13a7563ddd Added form support to Body[Inserter|Extractor]
- Added BodyInserter for MultiValueMap form data in BodyInserters
 - Added BodyExtractor to MultiValueMap in BodyExtractors

Issue: SPR-15144
2017-01-18 15:36:10 +01:00
Sebastien Deleuze
be45de0571 Polish Kotlin Web functional DSL
Issue: SPR-15065
2017-01-17 23:04:58 +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
Arjen Poutsma
88c5f5981f Added DataBuffer Encoder/Decoder
This commit adds a DataBuffer Encoder and Decoder, and uses it in
the annotation-based processing model.

Note that these codecs are not used in the functional processing model,
since the BodyInserter/BodyExtractor already have methods for
writing/reading DataBuffers.

Issue: SPR-15148
2017-01-17 16:46:43 +01: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
Sebastien Deleuze
02409f74b9 Polish Kotlin routing DSL
This commit changes RouterFunctionDsl {...} (request)
to route(request) {...}, remove uneeded methods, add
missing ones and add tests useful to validate the
DSL syntax and behavior.

Issue: SPR-15065
2017-01-13 23:32:30 +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
Arjen Poutsma
d724644588 Expose WebSession on ServerRequest
This commit exposes the WebSession on ServerRequest.
2017-01-12 11:37:48 +01:00
Sebastien Deleuze
b503e4679c Add reactive ScriptTemplateView
For now if sharedEngine is set to false, a new
ScriptEngine instance is created for each request.

Issue: SPR-15063
2017-01-09 19:47:07 +01:00
Sam Brannen
9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Juergen Hoeller
fc629bb508 Polishing 2016-12-29 22:39:36 +01:00
Rossen Stoyanchev
e4d39bb86f Refactor Undertow WebSocket client configuration model
This commit removes the statically created XnioWorker which is an
"active" component and should not be created automatically and could
lead to resource leaks. Instead XnioWorker is now required at
construction aligning better with WebSocketClient#connectionBuilder
which also does not have a "default" worker option.

Since the XnioWorker is the main input for creating a ConnectionBuilder
we now create the ConnectionBuider in a protected method and then allow
a Consumer<ConnectionBuilder> to configure it further as opposed to the
Function<URI, ConnectionBuilder> used previously.

This commit also removes default SSL context initialization for RxNetty
to better align with other client implementations.

Issue: SPR-14527
2016-12-27 16:02:40 -05:00
Rossen Stoyanchev
a77da869a6 Custom request headers for JettyWebSocketClient
Issue: SPR-14527
2016-12-23 22:11:17 -05:00
Rossen Stoyanchev
22a57b9aed Polish 2016-12-23 21:55:40 -05:00
Rossen Stoyanchev
1b8cdb8924 Paramaterize WebSocket tests by client and server
Issue: SPR-14527
2016-12-23 21:20:42 -05:00
Violeta Georgieva
d49ab90187 Jetty/Standard/UndertowWebSocketClient headers test 2016-12-23 17:23:22 -05:00
Violeta Georgieva
b4b7b163d1 Add WebSocketClient for Undertow
Issue: SPR-14527
2016-12-23 17:23:22 -05:00
Violeta Georgieva
30ee71ea1a Add WebSocketClient for Java WebSocket (JSR-356)
Issue: SPR-14527
2016-12-23 17:23:22 -05:00
Violeta Georgieva
bd09a76a1e Add WebSocketClient for Jetty
Issue: SPR-14527
2016-12-23 17:23:22 -05:00
Sebastien Deleuze
fbf88d19da Allow to specify hints with the functional web API
The most common use case is specifying JSON views.

ServerResponse.BodyBuilder#hint(String, Object) allows to
specify response body serialization hints.

ServerRequest#body(BodyExtractor, Map) allows to specify
request body extraction hints.

Issue: SPR-15030
2016-12-23 17:58:34 +01:00
Rossen Stoyanchev
3d1b6fd362 Add WebSocket integration test 2016-12-22 22:07:02 -05:00
Rossen Stoyanchev
00387c3bbd Re-enable Reactor WebSocket integration tests 2016-12-21 12:39:56 -05:00
Sebastien Deleuze
7b183048b8 Introduce SSE support in WebClient
Issue: SPR-14539
2016-12-21 17:24:45 +01:00
Stephane Maldini
804935a8eb try less log and increase timeout 2016-12-21 00:48:29 +00:00
Rossen Stoyanchev
3b987c263c Sub-protocol negotiation for reactive WebSocket support
Issue: SPR-14527
2016-12-20 12:22:24 -05:00
Rossen Stoyanchev
5fd600d2ad Fix failing test 2016-12-19 15:29:00 -05:00
Rossen Stoyanchev
1243556047 Add Reactor Netty WebSocketClient support
Issue: SPR-14527
2016-12-19 14:57:10 -05:00
Rossen Stoyanchev
14068d5274 Refactor reactive WebSocketClient contract
Switch from returning Mono<WebSocketSession> to take a WebSocketHandler
and return Mono<Void> for the entire session handling.

The WebSocketHandler callback delimits the stard and end of protocol
handling and forces the handler to operate within the scope of the
Reactor operators.

Give the full duplex nature of WebSockets, the symmetry between client
and server (each now using WebSocketHandler) also seems appropriate.

Issue: SPR-14527
2016-12-19 12:09:47 -05:00
Sebastien Deleuze
e0c43c4fcb Disable also reactor-netty WebSocket integration tests 2016-12-19 10:48:44 +01:00
Rossen Stoyanchev
558d7f3f3e Fix package cycle
HandshakeInfo has been promoted to the top-level socket package next to
WebSocketSession which exposes it.
2016-12-18 20:37:05 -05:00
Rossen Stoyanchev
8be791c4ff Add reactive WebSocketClient and RxNetty implementation
Issue: SPR-14527
2016-12-18 10:49:52 -05:00
Rossen Stoyanchev
140ff7ce8f Polish reactive WebSocket integration tests 2016-12-18 10:41:05 -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
Arjen Poutsma
97558ab4de Move Body[Inserter|Extractor] to web.reactive.function 2016-12-15 13:22:11 +01:00
Arjen Poutsma
aac20b3fd1 Move functional web framework to web.reactive.function.server 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
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
Rossen Stoyanchev
2633b4e9ec RedirectView applies encodeUri + polish 2016-12-14 05:54:53 -05:00
Rossen Stoyanchev
d421112af3 Polish ServerWebExchange builder and ServerHttpResponse
Remove duplicated ServerHttpResponse#setComplete also declard in the
parent ReactiveHttpOutputMessage interface.

Also rename:
ServerWebExchange.MutativeBuilder --> ServerWebExchange.Builder
2016-12-13 17:59:51 -05:00
Brian Clozel
ba47d06cbb Update integration tests for reactor-netty
Now that reactor/reactor-netty#12 is fixed, we can restore the
previously ignored integration tests.
New tests are hanging, so this commit is converting the `StepVerifier`
`verify()` calls to using actual timeouts.

Issue: SPR-14975
2016-12-13 21:34:13 +01:00
Stephane Maldini
6922a1c534 Sync with latest reactor netty changes 2016-12-13 17:22:40 +00:00
Rossen Stoyanchev
885e76bdd0 Synchronized lazy start in JettyRequestUpgradeStrategy
Issue: SPR-14527
2016-12-12 21:10:59 -05:00
Violeta Georgieva
08edec006b Refactor AbstractListenerWebSocketSession
- Added suspended flag to indicate whether the ReceivePublisher
is able to process the incoming messages.
- Use buffer strategy for the incoming messages.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Violeta Georgieva
a2053a516e Initial reactive, WebSocket Jetty support
Issue: SPR-14527
2016-12-12 17:56:47 -05:00
Violeta Georgieva
80040ef43b Initial reactive, WebSocket Undertow support
Issue: SPR-14527
2016-12-12 17:56:47 -05:00
Violeta Georgieva
46b39f4372 Initial reactive, WebSocket Tomcat support
Issue: SPR-14527
2016-12-12 17:56:47 -05:00
Brian Clozel
933f1501e8 Do not include URL hash in resource paths
When getting the lookup path of a resource, both query params and hashes
should be removed from the request path.

This commit fixes the public path resolution for paths like
`/resources/main.svg#icon-hamburgermenu`.

Issue: SPR-14928
2016-12-12 15:14:50 +01:00
Juergen Hoeller
66e6b35e9f Reliable content length check in ResourceHandlerFunctionTests 2016-12-12 09:57:57 +01:00
bedrin
8315a4033f Add consumes attribute to @GetMapping
Issue: SPR-14988
2016-12-07 17:45:43 -05:00