Commit Graph

566 Commits

Author SHA1 Message Date
Brian Clozel
084daa7fb5 Document media type registration for appcache files
Since appcache manifests can have various file extensions, developers
should register the (file extension, media type) mapping in their Spring
MVC / Reactive Web configuration.

This commit adds javadoc on both `AppCacheManifestTransformer` variants
to explain how to do that.

Issue: SPR-14510
2016-09-16 12:04:56 +02:00
Juergen Hoeller
6de4b12992 Adapted recent tests to pass on Windows 2016-09-15 14:12:49 +02:00
Rossen Stoyanchev
33d90747a1 Asynchronous ResourceResolver + ResourceTransformer
Issue: SPR-14521
2016-09-13 18:04:40 -04:00
Juergen Hoeller
915350d0ce Reliable last-modified timestamp tests on Windows 2016-09-13 21:41:11 +02:00
Arjen Poutsma
360ef5f5e3 Remove accidentally added ModelAndView class
Removed accidentally added ModelAndView class.
2016-09-13 20:16:41 +02:00
Sebastien Deleuze
fc52ddcd97 Polish 2016-09-13 15:03:13 +02:00
Arjen Poutsma
61bf6a25b7 Renamed 'and' to 'andSame' and 'andOther' to 'and'
In RoutingFunction, renamed 'and' to 'andSame', and 'andOther' to
'and' to make the commonly used method name shorter.
2016-09-12 15:41:58 +02:00
Arjen Poutsma
96ec18a9aa Merged all Response implementations into one
Merged all *Response implementations into one DefaultResponses class
2016-09-12 15:41:04 +02:00
Arjen Poutsma
35b93b2948 Add template rendering support
This commit introduces template rendering support in the web.reactive
package, through a Response.render method and a Rendering interface.
2016-09-12 15:39:49 +02:00
Sebastien Deleuze
aaba53f76a Allow to pass hints parameter in HttpMessageReader/Writer
Issue: SPR-14557
2016-09-12 11:13:27 +02:00
Sebastien Deleuze
b91867cf45 Update Codec API to use Map<String, Object> for hints
Issue: SPR-14557
2016-09-12 11:08:01 +02:00
Brian Clozel
1881aa5b5b Change default appcache manifest file extension
This commit changes the default file extension configured with
`AppCacheManifestTranformer`. This ResourceTransformer was previously
considering `.manifest` files by default, but this has been changed in
the official spec to `appcache`, in order not to clash with Microsoft's
unregistered application/manifest type.

Issue: SPR-14687
2016-09-09 22:11:20 +02:00
Brian Clozel
4588b6c9f4 Rename ResolvedResource to HttpResource
`ResolvedResource` is a rather generic name - changing the extended
interface to something more meaningful: `HttpResource`.
For now, implementations are linked with the resource handling chain,
but this aspect has been removed from the interface documentation.

Issue: SPR-14264
2016-09-09 18:18:09 +02:00
Arjen Poutsma
5f941c1dd1 Fix using system default charset in view rendering
Prior to this commit, FreeMarkerView used the system default charset to
render. This commit switches this by defaulting to UTF-8, if no charset
is specified in the content type.

 - Add contentType parameter to AbstractView.renderInternal, used to
 determine the charset contained therein
 - Adds a defaultCharset property to AbstractView and
 ViewResolverSupport.
2016-09-09 15:22:22 +02:00
Arjen Poutsma
a746c3c54e Changed View.render method to take Map<String, ?>
Changed View's render method from taking a HandlerResult to taking a
Map<String, ?>, in order to facilitate scenarios where a HandlerResult
is not available (i.e. web.reactive.function).
2016-09-09 15:22:21 +02:00
Arjen Poutsma
ecf5a9f34e Added Response.build(Publisher<Void>) 2016-09-09 12:19:51 +02:00
Arjen Poutsma
f4ae831f7f Polishing
- Changed Response.sse methods to allow for specific Publisher types to
 be returned in Response.
2016-09-09 10:53:45 +02:00
Arjen Poutsma
10e157a5a2 Removed unnecessary Driver file 2016-09-07 17:24:34 +02:00
Arjen Poutsma
f8ac17f278 Polishing
Two changes to web.reactive.function:

 - Changed Response.stream method to allow for specific Publisher types
 to be returned in Response.

 - Router now stores HttpMessageReader|Writer retrieved from
 Configuration in the attributes as supplier, not as stream, to allow
 for multiple reads.
2016-09-07 15:29:20 +02:00
Arjen Poutsma
bebaee9799 Removed attributes() from Request
Removes attributes() method from Request, as it exposes a mutable map.
2016-09-07 10:10:40 +02:00
Brian Clozel
ccb3c44dbc Add ResolvedResource in resource handling chain
Prior to this commit, the resource handling chain and its
`ResourceResolvers` would use specific `Resource` implementations in
order to add resource metadata to the HTTP response. For example,
`VersionedResource` and `EncodedResource` are both adding specific HTTP
response headers.

This commit aims at making this mechanism more stable and reusable,
since the previous implementation would fail in case a resolved resource
would be both a `VersionedResource` wrapping a `EncodedResource` (or the
other way arount). Only one of the specific implementations would
contribute its metadata since the code supporting that in
`ResourceHttpRequestHandler` would only check for `instanceof` tests,
whereas those implementations are acutally delegating calls to
the wrapped resource.

Now both `VersionedResource` and `EncodedResource` have been replaced by
specific implementations of `ResolvedResource`, which directly provides
those HTTP response headers as part of `getResponseHeaders()`.

This commit applies the same changes for the web reactive
implementations and its `ResourceWebHandler`.

Issue: SPR-14264
2016-09-07 09:52:33 +02:00
Brian Clozel
72e4fac28d Fix missing resources in GzipResourceResolverTests 2016-09-06 15:39:28 +02:00
Rossen Stoyanchev
4346d15cb5 Resource handling configuration
Issue: SPR-14521
2016-09-05 21:59:22 -04:00
Rossen Stoyanchev
1ae64bfbd3 Resource handling support for Spring Web Reactive
A straight-forward port of the resource handling support in
spring-webmvc to spring-web-reactive. Primarily adapting contracts and
implementations to use the reactive request and response and the
reactive ResourceHttpMessageWriter.

Issue: SPR-14521
2016-09-05 21:59:22 -04:00
Brian Clozel
01bd8b9e01 Fix null body handling in ResponseEntityResultHandler
This commit fixes `ResponseEntityResultHandler` so that it only tries to
call `writeBody` if the `ResponseEntity` is not null. In case the
response entity body is null, the response is flushed right away and the
request is signaled as handled.

Issue: SPR-14663
2016-09-02 23:01:16 +02:00
Rossen Stoyanchev
73752c295d Refactor location of MockServerHttpRequest/Response
This change puts the MockHttpServerRequest/Response under
org.springframework.mock.http.server.reactive.test which
mirrors the arrangement we have with the Servlet mock equivalents
and sets up the addition of MockHttpServerRequest/Response in
spring-test.

Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Rossen Stoyanchev
e17132c217 Polish MockServerHttpRequest
Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Rossen Stoyanchev
0681519255 Add checkNotModified support for view resolution
Issue: SPR-14522
2016-09-01 18:07:23 -04:00
Rossen Stoyanchev
638e6cc7f8 Add checkNotModified support for ResponseEntity
Issue: SPR-14522
2016-09-01 17:44:51 -04:00
Rossen Stoyanchev
9f8791ac01 Add ServerWebExchangeArgumentResolver
Issue: SPR-14658
2016-09-01 17:44:51 -04:00
Sebastien Deleuze
48d67a245b Add support for RxJava 2
This commit adds support for RxJava 2 Completable,
Single, Observable and Flowable types (io.reactivex package).

Issue: SPR-14628
2016-09-01 14:48:16 +02:00
Sebastien Deleuze
b4641b2306 Polishing 2016-09-01 14:48:16 +02:00
Arjen Poutsma
f1319f58ec Introduce new functional web API
This commit introduces a new, functional web programming model in the
org.springframework.web.reactive.function package. The key types
are:

 - Request and Response are new Java 8-DSLs for access to the HTTP
   request and response
 - HandlerFunction represents a function to handle a request to a
   response
 - RoutingFunction maps a request to a HandlerFunction
 - FilterFunction filters a routing as defined by a RoutingFunction
 - RequestPredicate is used by Router to create RoutingFunctions
 - RequestPredicates offers common RequestPredicate instances
2016-09-01 14:38:13 +02:00
Arjen Poutsma
16b525f698 Refactored SseEvent to ServerSentEvent
- Renamed SseEvent to ServerSentEvent to make the name less redundant.
 - ServerSentEvent is now immutable, having a builder to create new instances.
 - Realigned the class properties to more closely match the events
   described in the spec, so that `reconnectTime` becomes `retry`, and
   `name` becomes `event`.
2016-09-01 13:47:50 +02:00
Juergen Hoeller
e08b1b75b6 @PathVariable supports 'required' attribute (for model attribute methods)
Issue: SPR-14646
2016-08-31 14:43:39 +02:00
Juergen Hoeller
31c5644691 ResponseStatusExceptionHandler in web.server.handler (plus related polishing) 2016-08-30 23:58:14 +02:00
Rossen Stoyanchev
391752abc2 Polish and update reactive getting started reference
This commit updates the instructions on getting started with
Spring Web Reactive and also updates constructors and setters to
streamline the getting started procedure.

Issue: SPR-14640
2016-08-30 14:36:19 -04:00
Brian Clozel
960d335c35 Don't wrap resolver exceptions in InvocableHandlerMethod
Prior to this commit, exceptions thrown by the
`HandlerMethodArgumentResolver` would be wrapped into
`IllegalStateException`s.

This commit makes sure that a DEBUG log is written with the relevant
information and that the root cause is not wrapped into another
exception, so that the appropriate `ExceptionHandler` can be used to
deal with this error.

Issue: SPR-14618
2016-08-30 11:50:40 +02:00
Sam Brannen
d6d05e8ca0 Remove trailing whitespace in Java source code 2016-08-29 15:25:10 +02:00
Rossen Stoyanchev
cc288a0c4a Switch back to Reactor 3.0 snapshots 2016-08-08 16:42:30 -04:00
Sebastien Deleuze
5531e80724 Anticipate reactor.test.TestSubscriber removal
reactor.test.TestSubscriber will not be part of Reactor Core
3.0.0 since it needs to be refactored to fit all the needs
expressed by the users. It is likely to be back later in one
of the Reactor Core 3.0.x releases.

This commit anticipate this removal by temporarily copying
TestSubscriber in spring-core test classes. As soon as
the new TestSubscriber will be available in Reactor Core,
Spring Framework reactive tests will use it again.
2016-08-08 11:24:21 +02:00
Rossen Stoyanchev
460ed307ed Shorten getter for ReactiveAdapterRegistry 2016-07-27 17:03:56 -04:00
Rossen Stoyanchev
143b5c89dd Add support for rx.Completable as return value 2016-07-27 17:00:27 -04:00
Rossen Stoyanchev
79bc227c9d Remove SimpleResultHandler
There is really no need for a result handler dedicated to a void
return value and it's actually problematic to have it.

Each result handler treats void as necessary. For an @ResponseBody
method it means an empty body. For view resolution it means no specific
value was returned and we should procede with selecting a default view
name. Having a dedicated void result handler can interfere with this
especially since view resolution needs to be last in order.

At the same time there are cases when no result handling is needed
and the response is fully handled within the HandlerAdapter. This is
the case with WebHandler and the SimpleHandlerAdapter. For that case
we simply return mono.then(aVoid -> Mono.empty()) which effectively
returns an empty Mono and no result handling follows. The
HandlerAdapter already says you can return no values at all if the
response is fully handled.
2016-07-27 17:00:27 -04:00
Rossen Stoyanchev
3ab21741f9 Use Jetty again in SseIntegrationTests 2016-07-27 13:26:51 -04:00
Juergen Hoeller
e03dea1d64 Polishing 2016-07-26 17:15:19 +02:00
Juergen Hoeller
c13f8419f9 Minor revision of reactive support layout (ahead of 5.0 M1)
DataSourceUtils moved to main core.io.buffer package.
Consistently named Jackson2JsonDecoder/Encoder and Jaxb2XmlDecoder/Encoder.
Plenty of related polishing.
2016-07-26 15:39:32 +02:00
Rossen Stoyanchev
10c90a677c Move http.converter.reactive to http.codec 2016-07-22 14:14:46 -04:00
Arjen Poutsma
b0d7625e3e Reactor StringEncoder into CharSequenceEncoder
This commit refactors the StringEncoder to a CharSequenceEncoder, in
order to support StringBuilders, Groovy GStrings, etc.

Issue: https://github.com/spring-projects/spring-reactive/issues/120
2016-07-22 12:47:46 -04:00
Rossen Stoyanchev
0f6505e32f Add timeout settings in SseIntegrationTests 2016-07-22 12:42:35 -04:00