Commit Graph

694 Commits

Author SHA1 Message Date
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
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
Juergen Hoeller
b366e159f8 Fine-tuned handling of running state
Issue: SPR-14527
2016-12-14 21:59:49 +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
Juergen Hoeller
5169c51a6c Polishing 2016-12-13 13:02:23 +01:00
Brian Clozel
52f664139f Improve VersionResourceResolve javadoc
The `pathPatterns` args are relative to the patterns configured for the
resource handler.

Issue: SPR-14817
2016-12-13 10:43:27 +01:00
Rossen Stoyanchev
885e76bdd0 Synchronized lazy start in JettyRequestUpgradeStrategy
Issue: SPR-14527
2016-12-12 21:10:59 -05:00
Rossen Stoyanchev
d6895aa098 Consistently extend WebSocketHandlerAdapterSupport
The WebSocketHandler adapters for all runtimes now extend
WebSocketHandlerAdapterSupport, which now also exposes
a shared DataBufferFactory property initialized from the response.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
5829e1c141 Polish method and field declaration order 2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
f32a41933e Polish 2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
db5bc4a24e Minor refactoring of suspend/resumeReceiving
suspend/resumeReceiving in the AbstractListenerWebSocketSession are
now abstract methods. In Tomcat/Jetty these methods are no-op
implementations that are then coupled with a buffering strategy via
Flux#onBackpressureBuffer. In Undertow they rely on flow control for
receiving WebSocket messages.

Issue: SPR-14527
2016-12-12 17:56:48 -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
Rossen Stoyanchev
d1411d9fc2 Simple refactorings in AbstractListenerWebSocketSessionSupport
Dropped "Support" from the name since it not only provides support
methods but actually implements WebSocketSession.

Renamed inner classes:
WebSocketMessagePublisher -> WebSocketReceivePublisher
WebSocketMessageProcessor -> WebSocketSendProcessor

Add protected getter for sendProcessor.

Reduce scoping:
WebSocketReceivePublisher -> private
WebSocketSendProcessor -> protected
WebSocketSendProcessor#setReady -> public (class is still protected)

A few more method name alignments and Javadoc updates.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Rossen Stoyanchev
fe7ee5ff33 Rename "Request/ResponseBody" publisher/processor
AbstractRequestBodyPublisher and AbstractResponseBodyProcessor are now
used for WebSocket messages too and have been renamed more generally to
AbstractListenerReadPublisher and AbstractListenerWriteProcessor.

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
Rossen Stoyanchev
1b0e95d7d8 Support for RequestUpgradeStrategy + Lifecycle
Issue: SPR-15527
2016-12-07 17:03:56 -05:00