Commit Graph

720 Commits

Author SHA1 Message Date
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
Rossen Stoyanchev
8be791c4ff Add reactive WebSocketClient and RxNetty implementation
Issue: SPR-14527
2016-12-18 10:49:52 -05:00
Rossen Stoyanchev
bcf6f6e75f Refactoring in reactive WebSocketSession and adapters
The WebSocketHander adapters are now neutral for client vs server-side
use with the adapters for RxNetty and Reactor Netty (server-side only)
completely removed.

A new HandshakeInfo carries information about the handshake including
URI, headers, and principal from the upgrade strategy, to the adapter,
and then to the session.

WebSocketSession exposes the HandshakeInfo as well reducing its overall
number of methods.
2016-12-18 10:49:52 -05:00
Rossen Stoyanchev
edcf04911f Refactoring in reactive WebSocketMessage
Move WebSocketMessage factory methods to the WebSocketSession which
has the bufferFactory() needed to create message payloads.

WebSocketMessage is left with one public constructor.

WebSocketMessage exposes convenience retain/releasePayload methods.
2016-12-18 10:49:47 -05:00
Rossen Stoyanchev
6cd92c69cf Refactoring in reactive WebSocketSession hierarchy
Expose bufferFactory() at the WebSocketSession level for creating
payloads like ReactiveHttpOutputMessage does.

Promote getId(), getUri(), and bufferFactory() to the base class
WebSocketSessionSupport.
2016-12-18 10:46:28 -05:00
Rossen Stoyanchev
140ff7ce8f Polish reactive WebSocket integration tests 2016-12-18 10:41:05 -05:00
Rossen Stoyanchev
9376748c9c Apply getAcceptLanguageAsLocale and encodeUrl
Apply the new HttpHeaders#getAcceptLanguageAsLocale() in places where
it was hardcoded or defaulting.

Apply ServerHttpResponse.encodeUrl in RequestContext.

Issue: SPR-15024
2016-12-16 17:33:39 -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
Juergen Hoeller
8a7467020f Polishing 2016-12-15 15:44:16 +01:00
Arjen Poutsma
36a6580638 Remove copyright notice from package-info.java files. 2016-12-15 13:22:11 +01:00