Commit Graph

730 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
Juergen Hoeller
d21b6e596f Revised Charset handling and common StringUtils.uriDecode delegate
Issue: SPR-14492
2017-01-18 00:09:06 +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
Daniel Fernández
8b7f3a65ed Fix exception if no RequestDataValueProcessor is present
This modification fixes the way AbstractView retrieves the
RequestDataValueProcessor bean, correctly returning null if there
is no bean of such type at the Application Context.

This avoids an exception in RedirectView (which extends AbstractView)
when trying to post-process the URL generated for redirection, when
no RequestDataValueProcessor exists.

Issue: SPR-15136
2017-01-17 10:10:46 -05:00
Juergen Hoeller
c42d44a42c Polishing and documentation fixes 2017-01-17 12:47:04 +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
b7471e7fca Add a Kotlin Web functional DSL
This commit introduces a router DSL for RouterFunctions
and RouterFunction in order to be able to write idiomatic
Kotlin code as below:

fun route(request: ServerRequest) = RouterFunctionDsl {
    accept(TEXT_HTML).apply {
            (GET("/user/") or GET("/users/")) { findAllView() }
            GET("/user/{login}") { findViewById() }
    }
    accept(APPLICATION_JSON).apply {
            (GET("/api/user/") or GET("/api/users/")) { findAll() }
            POST("/api/user/") { create() }
            POST("/api/user/{login}") { findOne() }
    }
 } (request)

Issue: SPR-15065
2017-01-11 14:54:31 +01:00
Sebastien Deleuze
b04b41b93b Add bodyToMono/Flux<Foo>() Kotlin extensions
Issue: SPR-15128
2017-01-11 08:59:10 +01:00
Sebastien Deleuze
0a988fd2b1 Remove object wrappers in Kotlin extensions
This commit also improve significantly Kotlin extensions
documentation.

Issue: SPR-15127
2017-01-11 08:52:01 +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
08cc92176a Enable compilation on Eclipse 4.6 2017-01-07 02:15:02 +01:00
Sam Brannen
9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Brian Clozel
87f498195c Fix RequestUpgradeStrategy impl. class loading
Issue: SPR-15106
2017-01-06 23:19:51 +01:00
Juergen Hoeller
fc629bb508 Polishing 2016-12-29 22:39:36 +01:00
Rossen Stoyanchev
4a380b8401 Add RequestDataValueProcessor in spring-web-reactive
Issue: SPR-15001
2016-12-27 17:42:01 -05: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
384e851bd1 Polish reactive WebSocketClient implementations 2016-12-27 13:44:59 -05:00
Sebastien Deleuze
6a850ee688 Polishing 2016-12-27 10:08:12 +01:00
Sebastien Deleuze
3626a1c7f9 Add Kotlin extensions for function Web API
Issue: SPR-15054
2016-12-27 08:47:58 +01: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
Rossen Stoyanchev
12f80be1f0 AbstractListenerWebSocketSession handles Mono<Void>
The HandlerSubcriber from each listener session implementation is now
consolidated into AbstractListenerWebSocketSession since the handling
of onComplete or onError in any case is about delegating to the
session.

This also allows for the UndertowWebSocketHandlerAdapter to become
simply an (Undertow) AbstractReceiveListener.

Issue: SPR-14527
2016-12-23 18:04:53 -05:00
Rossen Stoyanchev
935577f00b Replace WebSocketHandlerAdapterSupport with delegation
This commit removes the base class WebSocketHandlerAdapterSupport which
was mainly a container for properties. Instead we use a
java.util.Function to create the WebSocketSession which differs in any
way by client and server, which in turn allows  HandshakeInfo to become
a simple immutable container once again.

Also for Undertow the WebSocketConnectionCallback implementation has
been moved into the server.upgrade package since it is for server-side
use only.

Issue: SPR-14527
2016-12-23 17:23:23 -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
Violeta Georgieva
113d1b6970 Polishing 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
3719f75d3b Minor refactoring + polish
- RxNettyWebSocketSession filters out WebSocketCloseFrame again
- add before/afterHandshake helper methods in WebSocketClientSupport
- log request headers on server and response headers on client
- polish 400 request handling in HandshakeWebSocketService
2016-12-22 16:18:15 -05:00
Rossen Stoyanchev
0d0d461903 Use WebSocketFrameAggregator for Reactor and RxNetty
WebSocket frames are now aggregated through a Netty decoder so that
we always receive fully assembled messages by default capped at 64K.

Issue: SPR-14527
2016-12-21 14:14:37 -05:00
Rossen Stoyanchev
00387c3bbd Re-enable Reactor WebSocket integration tests 2016-12-21 12:39:56 -05: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
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
30df137273 HandshakeWebSocketService detects upgrade strategies
Issue: SPR-14527
2016-12-19 18:30:14 -05:00
Rossen Stoyanchev
47e141675f Minor refactoring + polish reactive WebSocket support
Rename classes not specific to Tomcat:
TomcatWebSocketSession -> StandardWebSocketSession
TomcatWebSocketHandlerAdapter -> StandardWebSocketHandlerAdapter

WebSocketSessionSupport is renamed to AbstractWebSocketSession since it
actually is a WebSocketSession and pre-implements a number of methods.

ServerEndpointRegistration is now package private (mainly for use in
upgrade strategies) and renamed to DefaultServerEndpointConfig.
2016-12-19 18:16:36 -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