Commit Graph

502 Commits

Author SHA1 Message Date
Rossen Stoyanchev 1f283acb98 Add path extension and parameter ContentTypeResolver's 2016-04-18 17:43:20 -04:00
Rossen Stoyanchev 9ffc0b5e65 Update FileExtensionContentTypeResolver
Rename to MappingContentTypeResolver and replace "fileExtension" with
"key" in methods to be more general (e.g. file extension or query
param). Also switch from List to Set for the return values.
2016-04-18 17:43:20 -04:00
Stephane Maldini 7d60c2767d Normalize returns with Scheduler factories in SchedulerGroup 2016-04-18 21:26:12 +01:00
Rossen Stoyanchev 0f44fedd19 Complete RequestMappingHandlerMapping
This commit adds RequestMappingInfoHandlerMapping and
RequestMappingHandlerMapping with support equivalent to that in
spring-webmvc.
2016-04-18 13:07:23 -04:00
Stephane Maldini 0e5a892bad Use ByteBuf instead of Buffer in reactor-netty 2016-04-18 17:49:32 +01:00
Stephane Maldini ad9d8c28fe Polish reactor-ipc/netty contracts 2016-04-17 14:50:20 +01:00
Stephane Maldini 0a3396c5b2 Polish contracts 2016-04-16 01:05:30 +01:00
Stephane Maldini 9a4b98d2e9 Update HttpClient with Inbound/Outbound contract split 2016-04-15 23:23:54 +01:00
Stephane Maldini 4431a76a05 Update addCookie signature and improve client cookie 2016-04-15 21:25:56 +01:00
Rossen Stoyanchev b2ca216498 Add RequestCondition hierarchy
A pretty complete equivalent to the same in spring-webmvc except for
CORS checks, and custom HTTP methods. Another notable difference is
that the "params" condition works on query params strictly.
2016-04-15 16:21:46 -04:00
Rossen Stoyanchev 641c6428e8 Add ContentTypeResolver strategy
A starting point for an alternative to the existing
ContentNegotiationStrategy but for use with ServerWebExchange.
2016-04-15 16:21:46 -04:00
Rossen Stoyanchev 09c5711862 Polish ServerHttpRequest
Consistent initialization of HttpHeaders and the cookies map.
 - allow sub-classes to create instance
 - make unmodifiable
2016-04-15 16:21:46 -04:00
Rossen Stoyanchev a7f32cd528 Add getQueryParams to ServerHttpRequest 2016-04-15 16:21:46 -04:00
Rossen Stoyanchev 61136e614e Fix issue with Cookies in ReactorServerHttpResponse 2016-04-15 16:20:55 -04:00
Stephane Maldini 4ddd9d2895 fix change issue on HttpChannel#writeHeaders to sendHeaders 2016-04-15 20:04:52 +01:00
Stephane Maldini 4a0adc2b2d Sync with reactor-netty and reactor-ipc 2016-04-15 19:55:33 +01:00
Rossen Stoyanchev 33a7b91e57 Add abstract case class HandlerMappings
This commit adds AbstractHandlerMethodMapping, a starting point for
AbstractHandlerMapping, and HttpRequestPathHelper with a similar
purpose to UrlPathHelper but based with ServerWebExchange as input.
2016-04-15 04:08:19 -04:00
Rossen Stoyanchev 341f23e0e6 Add "result" package under ~.web.reactive
The new package is parallel to the "mvc" package under spring-webmvc
and a place to hold the various programming model styles.
2016-04-14 16:15:44 -04:00
Rossen Stoyanchev 3460e577ad Polish "simple" handler support
- correct name of HttpHandlerHandlerAdapter to WebHandlerHandlerAdapter
- shorten SimpleHandlerResultHandler to SimpleResultHandler
- add HandlerResult constructor without Model
- update tests
2016-04-14 15:17:28 -04:00
Stephane Maldini ff6b639cf9 sync with dispatchOn change in reactor-core 2016-04-11 16:04:01 +01:00
Brian Clozel a3b371bf4b Accept all media types in StringDecodere
This commit adds the "*/*" media type in the list of compatible media
types for the StringDecoder. This allows this decoder to decoder
payloads of any media type as long as the target type is String.

Fixes #87
2016-04-08 22:18:46 +02:00
Stephane Maldini da2276a954 First wave scheduler contract migration 2016-04-08 03:09:32 +01:00
Sebastien Deleuze 87ce5d641c Update dependencies
- Spring Framework 4.2.3.RELEASE -> 4.3.0.RC1
 - Netty 4.1.0.CR3 -> 4.1.0.CR6
 - Jackson 2.6.2 -> 2.7.3
 - Jetty 9.3.5.v20151012 -> 9.3.8.v20160314
 - Undertow 1.3.5.Final -> 1.3.20.Final
2016-04-07 20:26:38 +02:00
Brian Clozel 023dafa903 Support "text/*" media types in StringDecoder 2016-04-07 16:06:56 +02:00
Brian Clozel e3f87b3e3a Polish 2016-04-07 16:06:56 +02:00
Brian Clozel 09327181c4 Improve ClientHttpRequestFactory javadoc
This commit underlines the fact that the request created by a
ClientHttpRequestFactory should be augmented with a message body using
the `ClientHttpRequest#setBody` method before it is executed.

See #82
2016-04-07 16:06:56 +02:00
Brian Clozel ddf996cfeb Polish HttpRequestBuilder API
This commit makes messageEncoders a required argument for building a
client request - those are needed to actually encode the body object as
a reactive stream to be written to the HTTP request body.

Removed raw types usage in DefaultHttpRequestBuilder.

DefaultHttpRequestBuilder now uses a UriTemplateHandler to expand URI
templates + variables into a concrete URI.

Fixes #80, fixes #85, fixes #86
2016-04-07 16:06:56 +02:00
Brian Clozel 8ed2925ce3 Propagate Errors in DefaultHttpRequestBuilder
This commit introduces the new `WebClientException` for wrapping
client-side exceptions.
This exception is now thrown when now message encoder can be found for
writing the request body as an HTTP request message.

Fixes #83
2016-04-07 16:06:56 +02:00
Brian Clozel e2a07659ab Add generics support for WebResponseExtractors
This commit adds generics support for WebResponseExtractors.
Types should be described using a ResolvableType, which can be
created with static methods like:

    // for the type Event<Registration>
    ResolvableType.forClassWithGenerics(Event.class, Registration.class)

Fixes #89
2016-04-07 16:06:56 +02:00
Sebastien Deleuze 24a63f1d90 Upgrade RxNetty to 0.5.2-SNAPSHOT and Tomcat to 8.0.33 2016-04-07 16:04:39 +02:00
Brian Clozel 04fae44163 Switch back to reactor-core SNAPSHOT versions
Some important issues have been fixed in recent SNAPSHOT versions.

See #78 and #70
2016-04-07 15:10:49 +02:00
Arjen Poutsma 75399814cd Improve Jaxb2Decoder
- Introcuces XmlEventDecoder which decodes from DataBuffer to
  javax.xml.stream.events.XMLEvent. It uses the Aalto async XML API if
  available, but falls back to a blocking default if not.

- Refacors Jaxb2Decoder to use said XmlEventDecoder, and split the
  stream of events into separate substreams by using the JAXB annotation
  value, one stream for each part of the tree that can be unmarshaled to
  the given type.

- Various improvements in the JAXB code.
2016-04-06 16:22:49 +02:00
Arjen Poutsma a8f27af5fb Polishing. 2016-04-06 16:20:08 +02:00
Mark Paluch 9e79b344ca Implement review feedback.
Remove empty string optimization. Simplify test to use only Mono/Flux/TestSubscriber instead of mixing with RxJava.
2016-04-04 09:49:22 +02:00
Rob Winch fd6fc30eea Add RequestPostProcessor
Fixes gh-81
2016-03-31 12:33:45 -05:00
Mark Paluch c4b9d94c33 Use CharsetDecoder to decode a DataBuffer into a String. 2016-03-31 16:39:39 +02:00
Arjen Poutsma 75d006d2f9 Improve StringDecoder. 2016-03-31 11:31:02 +02:00
Lukas Krecan 23f3fff367 Replacing potentionally slow and infinite while loop by a latch 2016-03-29 10:33:21 +02:00
Arjen Poutsma d9d76ecd19 Polishing 2016-03-24 09:39:58 +01:00
Arjen Poutsma 35e511b03f Resolved comments from review
This commit resolves a few comments brought forward during a review
meeting, specifically:

- It renames AbstractResponseBodyPublisher to
  AbstractRequestBodyPublisher.
- It separates out registration logic into a register method.
- It moves the RequestBodyPublisher and ResponseBodySubscriber for the
  Servlet 3.1 support back into ServletHttpHandlerAdapter.
2016-03-23 17:04:18 +01:00
Arjen Poutsma d20b0003c6 Refactoring of Servlet 3.1 and Undertow support
- Introduce abstract base class for Servlet 3.1 and Undertow support
- Simplify Undertow support
2016-03-23 16:02:44 +01:00
Arjen Poutsma f7c6c69e51 Improve JacksonJsonEncoder
This commit removes the need for the custom Subscriber in
JsonObjectEncoder, and replaces it with higher-level Flux and Mono-based
solution.
2016-03-21 11:37:51 +01:00
Arjen Poutsma 7f786ce4d7 Added DataBufferAllocator property to ReactiveHttpOutputMessage, and use that to pass on to Encoder.encode(). 2016-03-18 16:14:33 +01:00
Arjen Poutsma 1836b2825b Added DataBufferAllocator parameter to Encoder.encode, and use that instead of AbstractAllocatingEncoder base class. 2016-03-18 16:05:30 +01:00
Arjen Poutsma e56dda1864 Make JsonObjectDecoder use allocator property on DataBuffer. 2016-03-18 14:11:25 +01:00
Arjen Poutsma b838fdab88 Added allocator property to DataBuffer 2016-03-18 12:16:23 +01:00
Arjen Poutsma 273c1b85e6 Reduced batch size to 1, so that we don't block on init. 2016-03-18 11:58:55 +01:00
Arjen Poutsma 2c52731417 Various test improvements 2016-03-18 10:02:28 +01:00
Arjen Poutsma 5519428d43 Replaced DataBufferPublisherInputStream with JDK equivalent. 2016-03-18 10:02:28 +01:00
Rossen Stoyanchev 72dbe9012e Add cookies to ClientHttpRequest/Response 2016-03-17 21:04:50 -04:00
Rossen Stoyanchev e19abf9c90 Rename ServerCookie to ResponseCookie
HttpCookie-ResponseCookie follows HttpEntity-ResponseEntity and also
avoids use of "Server" outside of server sub-package.
2016-03-17 15:28:55 -04:00
Rob Winch ececec21f7 Update to Gradle 2.12 2016-03-17 10:11:28 -05:00
Rob Winch 62753102dc Ensure a consistent netty version
Currently there are clashes between io.netty:netty-common:4.1.0.Beta7 and
io.netty:netty-all:4.1.0.CR3 which can cause errors in the build related
to "VerifyError: Bad type on operand stack".

One solution would be to exclude the jars that duplicate the classes.
However, this can be fragile since additional dependencies may be added
that bring in the dependency transitively.

This commit locks the version for any artifiact with the group "io.nettty"
to ensure the correct version of netty is used.
2016-03-17 10:11:12 -05:00
Arjen Poutsma 10a04b0769 Test improvements. 2016-03-17 10:21:04 +01:00
Stephane Maldini 530c817287 sync reactor-netty 2016-03-12 01:16:49 +00:00
Stephane Maldini 13ddfb4aab update package 2016-03-11 22:15:11 +00:00
Stephane Maldini f02492e15f sync with reactor-core and reactor-io 2016-03-11 20:02:34 +00:00
Rossen Stoyanchev e97a55ad54 WebClient supports Void response body
WebResponseExtractor uses Mono.when with the response status, headers,
and the decoded body. However when the response body stream is empty
then when completes empty too.

This change adds defaultIfEmpty handling for en empty response body.
2016-03-07 17:07:12 -05:00
Rossen Stoyanchev b2648f84ad DefaultWebSessionManager supports multiple sessions
Issue: #64
2016-03-07 11:20:51 -05:00
Stephane Maldini 1eadee5655 integration build with Reactor Core 2.5.0.M2 2016-03-07 13:57:27 +00:00
Rossen Stoyanchev ca7aeaae35 WebSessionIdResolver now returns List of ids
Issue: #64
2016-03-03 22:32:03 -05:00
Rossen Stoyanchev dbc6478b8a Refactor HTTP Cookie support
There is now an HttpCookie (simple name-value pair) and separately a
ServerHttpCookie sub-class with additional attributes that a server
can send to clients.

HttpHeaders is no longer the place to access cookies. Instead there is
a read-only HttpCookie map on ServerHttpRequest and a mutable
ServerHttpCookie map on ServerHttpResponse.

Cookies are stored in a map that preserves their order.
2016-03-03 22:17:39 -05:00
Stephane Maldini a8c777b35f Remove reference to Fluxion 2016-03-04 00:05:35 +00:00
Stephane Maldini ce4a687cf2 remove reactor-stream and related artefacts, update tests 2016-03-03 23:57:03 +00:00
Sebastien Deleuze 379ce6354e Update for latest Reactor Core Snapshot 2016-03-01 22:19:54 +01:00
Sebastien Deleuze dc52d4c31f Update for latest Reactor Core Snapshot 2016-03-01 22:07:54 +01:00
Stephane Maldini 14948d4241 sync reactor 2016-03-01 20:50:55 +00:00
Stephane Maldini 4197f002d8 Arrange WriteWithOperator to save some allocation cost with the same technique used by RSC and Reactor 2016-02-28 11:49:00 +00:00
Stephane Maldini 423a4852c5 use EmptySubscription 2016-02-28 11:29:46 +00:00
Stephane Maldini fc1b2e96f7 Introduce Mono#justOrEmpty(T) 2016-02-28 00:56:10 +00:00
Stephane Maldini 999dfe3925 Sync BaseSubscriber 2016-02-27 23:18:22 +00:00
Stephane Maldini 24d9e99de1 Sync toCompletableFuture 2016-02-27 21:36:31 +00:00
Stephane Maldini cc77a338b1 Sync reactor-core jdk8 bump 2016-02-27 13:34:15 +00:00
Stephane Maldini 4c477189a6 revert module Reactor Fluxion to Reactor Stream 2016-02-27 11:06:07 +00:00
Stephane Maldini 9f94f8c88e Sync to Fluxion to remove Stream confusion 2016-02-26 21:42:52 +00:00
Arjen Poutsma 361707c448 Servlet 3.1 support cleanup
Claneup of the Servlet 3.1 support:

 - moved RequestBodyPublisher to ServletServerHttpRequest
 - moved ResponseBodySubscribera to ServletServerHttpResponse
 - response body is now copied to ServletOutputStream in chunks, rather
   than one big byte[]
2016-02-23 14:35:49 +01:00
Arjen Poutsma 2fcbeb6595 Fixed issue with DefaultDataBuffer.asInputStream() 2016-02-23 14:14:34 +01:00
Stephane Maldini f920d2ce1e sync with reactor-stream update 2016-02-23 09:39:49 +00:00
Arjen Poutsma 51a90465d4 Polishing 2016-02-23 10:24:18 +01:00
Arjen Poutsma f036f745a6 Improved RxNetty support. 2016-02-18 15:49:45 +01:00
Brian Clozel d68ff29e9b Use default buffer allocator in RequestMappingHandlerAdapter
This commit removes RequestMappingHandlerAdapter's hard dependency on
Netty by switching to the DefaultDataBufferAllocator.
2016-02-10 23:16:48 +01:00
Sebastien Deleuze 628ae2fda8 Use Flux instead of Stream in Publisher based integration tests 2016-02-09 18:02:02 +01:00
Sebastien Deleuze 36788207f3 Polish RequestMappingIntegrationTests 2016-02-09 17:53:26 +01:00
Rossen Stoyanchev 971ca6beb8 Add HTML rendering integration test 2016-02-08 18:13:42 -05:00
Rossen Stoyanchev 29db80c3e8 Add FreeMarker View, ViewResolver and basic hierarchy 2016-02-08 18:13:42 -05:00
Rossen Stoyanchev 55d37c0522 Add View, ViewResolver, and ViewResolverResultHandler
This commit adds a View and ViewResolver contracts to support HTML
template based rendering.

ViewResolverResultHandler applies view resolution by iterating the
resolvers to resolve to a view and then use it to render.
2016-02-08 18:13:37 -05:00
Rossen Stoyanchev 14997eccf3 Support Model as method argument and in HandlerResult
A model is created and passed to argument resolvers including a new
ModelArgumentResolver. The model is then exposed for result handling
as a field in HandlerResult.
2016-02-08 18:04:07 -05:00
Rossen Stoyanchev e92174c772 Update HandlerResult
Rename result to returnValue and resultType to returnValueType to
reflect what they represent.

The returnValue getter is also wrapped as Optional since the value
returned from a handler may be null (e.g. void method, null value).
2016-02-07 21:50:56 -05:00
Stephane Maldini b7b423a003 Remove Stream#toBlockingQueue use 2016-02-08 00:25:52 +00:00
Arjen Poutsma 4a24979181 Various DataBuffer utility enhancements
- Javadoc for DataBufferUtils
 - Introduction of DataBufferTestUtils, containing methods for dumping
   the entire contents of a buffer
2016-02-05 14:31:48 +01:00
Stephane Maldini 52292cafae sync reactor-core scheduler 2016-02-04 03:08:26 +00:00
Brian Clozel 7ab92cfccf Add WebResponseExtractor impl for RxJava1
This commit adds `RxJava1WebResponseExtractors`, a static factory of
`WebResponseExtractor`s that are based on the RxJava1 composition API.
All extracted types are based on the `Single` and `Observable` types.
2016-02-02 14:06:02 +01:00
Brian Clozel 69ce33e1ee Add WebClient and its WebResponseExtractor API
This commit adds the `WebClient`, which relies on several parts of our
infrastructure:
* a `ClientHttpRequestFactory` to drive the underlying client library
* a `HttpRequestBuilder` builder API to create the client request
* a `WebResponseExtractor` to extract the "low-level"
`ClientHttpResponse` into a higher level representation such as a
decoded body

The `WebResponseExtractors` helper class contains many extractor
implementations all based on the `Flux`/`Mono` composition API.
2016-02-02 14:06:02 +01:00
Brian Clozel f63960af0a Add client Request/Response impl. for RxNetty
This commit adds the `ClientHttpRequest` and `ClientHttpResponse`
implementations for the RxNetty HTTP client.
This client library is based on the `Single` and `Observable`
composition API, so this has to be converted to the `Flux`/`Mono`
variants.
2016-02-02 14:06:01 +01:00
Brian Clozel 255d2de553 Add client Request/Response impl. for Reactor-Net
This commit introduces the `ClientHttpRequest` and `ClientHttpResponse`
implementations for the Reactor-Net HTTP client. This client is already
based on the `Flux` and `Mono` contracts.

This commit also adds a `AbstractClientHttpRequest` to support the
`ClientHttpRequest` implementations; it mirrors the
`AbstractServerHttpResponse` contract with a `beforeCommit` to register
`Supplier`s that should be notified before the request is committed.
2016-02-02 14:06:01 +01:00
Brian Clozel a6469baa4f Add HttpRequestBuilder default implementation
This commit adds a `DefaultHttpRequestBuilder` and its companion static
builders in `HttpRequestBuilders`. This allows to build client requests
with a friendly builder API, inspired by Spring's MockMvc API.
2016-02-02 14:06:01 +01:00
Brian Clozel 0983d302c7 Add base contracts for the Web client
This commit adds the base contracts for the Web client.
The "Reactive" prefixes of the previously commited contracts has been
removed to match the server ones.

Both the `ClientHttpRequest` and the `ServerHttpResponse` extend
`ReactiveHttpOutputMessage`, which now has a `beforeCommit` method,
necessary in both client and server implementations.

`HttpRequestBuilder` will be used by the developers to create requests
with a nice builder API. `ClientHttpRequestFactory` will provide support
for many HTTP client libraries in this new client.
2016-02-02 14:06:01 +01:00
Arjen Poutsma a4be950e37 Polishing 2016-02-02 13:57:02 +01:00
Stephane Maldini 199252cda6 sync 2016-01-28 20:57:24 +00:00
Stephane Maldini 44f4930e29 sync 2016-01-28 20:36:29 +00:00
Stephane Maldini 9204fdc371 fix timer issues
sync reactor-core
2016-01-28 18:59:56 +00:00
Stephane Maldini 28dcf2e78f fix compile test issue 2016-01-28 18:29:54 +00:00
Sebastien Deleuze ee9c5833f5 Update our tests to use TestSubscriber 2016-01-28 10:24:05 +01:00
Rossen Stoyanchev b9f4698b69 Remove license from package infos 2016-01-27 17:45:54 -05:00
Rossen Stoyanchev 381855aaf3 Refine names in web.server and polish Javadoc
WebServerExchange -> ServerWebExchange

Follows the same convention as in the http package also better allowing
the possibility for a client equivalent in the future.

WebToHttpHandlerBuilder -> WebHttpHandlerBuilder
WebToHttpHandlerAdapter -> WebHttpHandlerAdapter

More consistent with Spring conventions.
2016-01-27 17:05:07 -05:00
Rossen Stoyanchev e59b927fd1 Refine web.server package structure
Introduce adapter and handler sub-packages under web.server following a
review prompted by the addition of the session package and the package
cycle it brought in based on dependency on session.WebSessionManager.
2016-01-27 16:26:47 -05:00
Rossen Stoyanchev 407d11a58a Server-side session support
This commit adds initial support for a maintaining a server-side
session with attributes across HTTP requests. The WebSession
abstraction can be accessed via WebServerExchange from a WebFilter or
the target WebHandler.

The session sub-package contains additional abstractions for creating
and managing sessions providing a basis for extensibility (e.g. Spring
Session). Those include WebSessionManager, SessionIdStrategy, and
SessionStore along with a cookie-based session id strategy and an
in-memory session store in use by default.

Note that the current API does not provide a way to invalidate or
re-create the session from server side code.
2016-01-27 16:24:20 -05:00
Rossen Stoyanchev 3744549a3e Add setComplete + beforeCommit to ServerHttpResponse
setComplete replaces writeHeaders as a more general lifecycle method
to perform any kind of handling at the end of request processing, for
example to ensure headers are written if not already.

beforeCommit provides an extension point for an action to be invoked
just before the response is committed, e.g. adding headers/cookies.
2016-01-27 16:24:20 -05:00
Stephane Maldini 03e6d7dabf minor sync 2016-01-27 20:49:18 +00:00
Stephane Maldini 8a6fa02887 Sync with RSC move graph to flow 2016-01-27 17:42:05 +00:00
Sebastien Deleuze dc91c81fc4 Polishing 2016-01-27 17:04:08 +01:00
Sebastien Deleuze 506c4bc27b Finish to cleanup Reactor Buffer usages
We use it only for Reactor Net support now.
2016-01-27 17:01:17 +01:00
Arjen Poutsma c84ef6cbf3 Incorporated misc. suggestions from the PR. 2016-01-27 16:07:02 +01:00
Arjen Poutsma 66c424daf9 Removed DataBufferAllocator.allocateHeapBuffer and allocateDirectBuffer in favor of allocateBuffer. 2016-01-27 16:04:03 +01:00
Arjen Poutsma b8f2388d60 Removed unused classes 2016-01-27 16:04:03 +01:00
Arjen Poutsma 225179bc6f Updated http and web packages to use DataBuffer 2016-01-27 16:04:03 +01:00
Arjen Poutsma 2981b5e6e8 Updated Encoder and Decoder to use DataBuffer 2016-01-27 16:04:03 +01:00
Arjen Poutsma 38ab47f8a0 Added DataBuffer abstraction
Added DataBuffer and DataBufferAllocator, and provided a default NIO
ByteBuffer-based implementation of those, as well as a Netty
ByteBuf-based version.
2016-01-27 16:04:03 +01:00
Stephane Maldini 641a57ec93 no need to convert to array list with last zip signature 2016-01-27 14:59:19 +00:00
Stephane Maldini 10f4f64e6f sync updates with mono 2016-01-26 23:15:55 +00:00
Arjen Poutsma 21fff02dbd Fixing the build that bad boy @smaldini broke 2016-01-26 12:43:59 +01:00
Stephane Maldini ac94bf1120 sync with reactor-stream package-scope change 2016-01-25 09:05:40 +00:00
Stephane Maldini a907898910 fix signature 2016-01-22 23:11:31 +00:00
Stephane Maldini 0ba5e1d21c sync update on reactor-io Buffer move 2016-01-21 11:59:59 +00:00
Rossen Stoyanchev 30b007dc26 Based on fix in core for SPR-13876 2016-01-20 18:01:32 -05:00
Stephane Maldini 4e162122af sync update on reactor-core 2016-01-20 20:50:28 +00:00
Stephane Maldini 7b3e9e0950 move queue.disruptor and packagescope RingBufferUtils/RequestTask 2016-01-20 18:01:07 +00:00
Sebastien Deleuze 4572cfa38c Fix RxJava1Converter -> RxJava1ObservableConverter 2016-01-20 11:45:18 +01:00
Rossen Stoyanchev 2dd9c92267 Update reactor converter package 2016-01-19 21:34:28 -05:00
Stephane Maldini 198e316412 demote cyclic dependency under reactor-core reactor package
-> reactor.Mono : reactor.core.publisher.Mono
-> reactor.Flux : reactor.core.publisher.Flux
-> reactor.Processors : reactor.core.publisher.Processors
-> reactor.Timers : reactor.core.timer.Timers
-> reactor.Subscribers : reactor.core.subscriber.Subscribers
2016-01-19 20:18:47 +00:00
Stephane Maldini 53b76e90fc move BackpressureUtils to subscription 2016-01-19 19:57:34 +00:00
Stephane Maldini bdfdd64db7 merge core.processor and core.publisher 2016-01-19 19:46:46 +00:00
Stephane Maldini 386dfb0881 update DependencyUtils package 2016-01-19 19:30:20 +00:00
Sebastien Deleuze de300e8c00 Fix the Javadoc external links by using a page without frames 2016-01-14 20:01:38 +01:00
Sebastien Deleuze 9436dd7412 Polish Javadoc 2016-01-14 19:18:38 +01:00
Sebastien Deleuze 398eb0b478 Polish packages documentation 2016-01-14 18:54:17 +01:00
Sebastien Deleuze ae6912086a Add packages documentation 2016-01-14 18:45:43 +01:00
Sebastien Deleuze 2cdce62c3d Update README with the Javadoc link 2016-01-14 16:15:34 +01:00
Sebastien Deleuze 14cb20a9f1 Disable uniqueVersion in order to get a reliable Javadoc link 2016-01-14 16:12:27 +01:00
Sebastien Deleuze 22bea1da01 Add sources and Javadoc to the build 2016-01-14 15:38:35 +01:00
Stephane Maldini 89da87a3e5 Async test case to explore jetty/tomcat issues 2016-01-14 12:38:21 +00:00
Sebastien Deleuze 72e5aa39ec Polish @RestController support 2016-01-14 11:06:04 +01:00
Stephane Maldini 1e28dee608 add streaming test, commented due to issue with a tomcat and jetty 2016-01-14 03:59:15 +00:00
Stephane Maldini 0f432f735a use reactor cookie support 2016-01-14 03:34:25 +00:00
Rossen Stoyanchev da90f03f4c Support type-level @ResponeBody (and @RestController) 2016-01-13 18:12:36 -05:00
Rossen Stoyanchev 437c127b62 Log and handle unresolved exceptions
Before this change use of ExceptionHandlingWebHandler did ensure no
error signals are allowed to escape (hence relying on runtime
behavior).

This change ensures the same is done even when
ExceptionHandlingWebHandler is not configured for use, at the lowest
level which is the WebToHttpHandlerAdapter.
2016-01-13 18:06:42 -05:00
Brian Clozel cf6ceeed62 Allow Splitting/aggregation operations in Decoders
When decoding buffers as plain strings, the StringDecoder returns a
Publisher that may produce one or more `onNext` events.
This is perfectly valid, but leads to errors when trying to convert the
resulting Publisher into a `reactor.Mono` or `rx.Single`.

If the original Publisher emits 2 or more `onNext` signals,
converting to:
* `rx.Single` will throw an error saying that the underlying Observable
"emitted too many elements"
* `reactor.Mono` may contain only the first emitted element

This commit adds a `AbstractRawByteStreamDecoder` that takes a
`SubscriberBarrier` to apply splitting/aggregation operations on the
received elements.
The `StringDecoder` class now inherits from this abstract class and
uses one of the provided `SubscriberBarrier` implementations to
buffer all received elements in a single buffer.
2016-01-13 12:23:47 +01:00
Sebastien Deleuze 99e51a9101 Replace Reactor Stream by Flux in tests when possible 2016-01-12 15:27:02 +01:00
Sebastien Deleuze d9b67f5e72 Use Mono semantics for JSON object/array serialization
Before this commit, a handler method returning a stream with a JSON
content-type was producing a JSON object for single element streams
or a JSON array for multiple elements streams.

This kind of dynamic change of the output based on the number of
elements was difficult to handle on client side and not consistent
with Spring MVC behavior.

With this commit, we achieve a more consistent behavior by using
the Mono semantics to control this behavior. Mono (and Promise/Single)
are serialized to JSON object and Flux (and Observable/Stream) are
serialized to JSON array.
2016-01-12 11:31:18 +01:00
Rossen Stoyanchev c3cde84e6b Polish cookie support
HttpCookie is now immutable with factory methods to create a client
cookie (name-value) vs a server cookie (name-value + attributes)
including a builder for the latter.
2016-01-11 22:54:46 -05:00
Sebastien Deleuze ae4b35ced7 Add Mono and Flux support in @RequestMapping handler methods 2016-01-11 13:02:36 +01:00
Rossen Stoyanchev 1faeb0ec87 Add HttpCookie + server support through HttpHeaders 2016-01-10 22:36:45 -05:00
Rossen Stoyanchev f8ef2e0220 Add base classes for ServerHttpRequest/Response impls 2016-01-10 15:46:56 -05:00
Rossen Stoyanchev eedc90818f Re-introduce writeHeaders() in ServerHttpResponse
This commit brings back the writeHeaders method on ServerHttpResponse
that was once added (2a6a4f) and then removed (9c7151).

This version is a little simpler since writeHeaders doesn't explicitly
flush/send headers which runtimes are expected to do by default.
Instead the main purpose of writeHeaders now is to ensure changes made
via HttpHeaders are applied to the underlying runtime response at some
point and we now do that once at the very end.

This approach provides the most flexibility (vs keeping HttpHeaders in
sync) because it allows a full and consistent set of mutative
operations for both headers and cookies (to be added) regardless of the
API exposed by the underlying runtime.
2016-01-10 06:25:12 -05:00
Rossen Stoyanchev 4f614fa0fd Add WebServerExchange
This change adds a WebServerExchange and updates all contracts at the
the same level (i.e. org.springframework.web.server) as well as the
org.springframework.web.reactive level to use it so that all
framework-related code will have access to server-side processing
features such as request attributes (and others to come).
2016-01-08 12:30:13 -05:00
Rossen Stoyanchev 54e4e012b2 Separate out web.server from http.server.reactive
This change separates out lower-level HTTP adapter code from the more
(framework-specific) HTTP processing into a separate package under
org.springframework.web.server (not under org.springframework.http).
2016-01-08 12:29:04 -05:00
Stephane Maldini 94be412327 Remove last Stream reference 2016-01-07 23:41:48 +00:00
Stephane Maldini b4c3a67d2c Use Stream instead of Streams and uncomment reactor test 2016-01-07 23:29:16 +00:00
Rossen Stoyanchev 97af9998d5 Refine exception handling
Refine exception handling responsibilities between the
DispatcherHandler and the HandlerAdapter.
2016-01-07 18:26:27 -05:00
Stephane Maldini 70b8848492 fix Streams to Stream in test 2016-01-07 22:28:35 +00:00
Rossen Stoyanchev 9a1492e401 Polish 2016-01-07 17:09:49 -05:00
Rossen Stoyanchev a712f43654 Polish 2016-01-07 15:26:11 -05:00
Rossen Stoyanchev c3a8bf4d17 Revert "Remove mandatory dependency on Reactor Stream"
This reverts commit d5e6f70483d4a6c8af3cc5e97e52a54e98199169.
2016-01-07 15:23:55 -05:00
Sebastien Deleuze 318092cfd0 Use Mono#defaultIfEmpty instead of Flux#defaultIfEmpty 2016-01-07 15:58:46 +01:00
Sebastien Deleuze 327c420409 Remove mandatory dependency on Reactor Stream with JarJar 2016-01-07 14:51:43 +01:00
Sebastien Deleuze 8ef7e2ff77 Use Reactor 2.5 Flux and Mono Rx light API
Flux and Mono are used both for implementation and exposed at API
level to express 1 versus N semantic and to provide default Rx
operators:
- Flux<T> for multiple values Publisher (issue #48)
- Mono<T> for single value Publisher (issue #50)
- Mono<Void> for Publisher with no value (issue #49)
2016-01-07 11:14:12 +01:00
Rossen Stoyanchev 8ef2ce44f4 Temporarily remove Reactor from integration tests
https://github.com/spring-projects/spring-reactive/issues/57
2015-12-31 13:18:13 -05:00
Rossen Stoyanchev 0aade73c88 Update Servlet + Undertow req & resp implementations
For those runtimes that don't directly support Reacitve Streams this
commit separates more formally Reactive Streams bridge code out of
the request and response implementations which become simple adapters
to the ServerHttpRequest/Response contracts like their RxNetty and
Reactor Net counterparts.
2015-12-31 12:55:09 -05:00
Rossen Stoyanchev 869f6bef40 Polish server request & response implementations 2015-12-31 12:27:40 -05:00
Rossen Stoyanchev 6b05d17248 Response headers always in sync with native response
ServerHttpResponse implementations now immediately propagate
HttpHeaders changes as they so there is no need to call applyHeaders().

The writeHeaders from ServerHttpResponse is also removed. RxNetty and
Reactor Net both support implicitly completing if the handler
completes without explicitly writing the headers or the response body.
2015-12-29 23:13:21 -05:00
Rossen Stoyanchev 34eb6d5426 Add support for @ExceptionHandler methods 2015-12-29 23:13:21 -05:00
Rossen Stoyanchev 8c89b478d9 Add operator for deferred writes 2015-12-29 23:13:21 -05:00
Rossen Stoyanchev 9789db23d2 Rename HandlerResult fields from value to result 2015-12-29 23:13:21 -05:00
Rossen Stoyanchev 84e3ad342b Remove @Ignore from 404 status code tests 2015-12-29 23:13:21 -05:00
Rossen Stoyanchev 9eb07b7780 Update package for reactor Signal 2015-12-29 23:13:21 -05:00
Rossen Stoyanchev a12c172ceb Switch to rxnetty-http dependency
The "rxnetty" artifact is old (October 2015). There is now rxnetty-http
and other modules that have more recent snapshots (December 2015).
2015-12-29 23:13:21 -05:00
Stephane Maldini da4e4aab39 test operator log 2015-12-18 16:56:17 +00:00
Stephane Maldini 15185c75a3 use Publishers.onErrorResumeNext 2015-12-17 13:34:09 +00:00
Rossen Stoyanchev 69973d984d Fix test failure 2015-12-16 12:30:15 -05:00
Rossen Stoyanchev 623874b4d0 Constant HandlerNotFoundException 2015-12-16 11:08:41 -05:00
Rossen Stoyanchev 1b3289d0d5 Add InternalServerErrorExceptionHandler 2015-12-15 17:04:53 -05:00
Rossen Stoyanchev f2cd92a243 Fix imports 2015-12-15 12:09:23 -05:00
Rossen Stoyanchev c13a8c9bb4 DispatcherHandler maps errors to ResponseStatusException
The DispatcherHandler now has an errorMapper property that is a
function for transforming errors. By default this property is set to an
instance of DispatcherHandlerExceptionMapper which wraps "standard"
framework exceptions and @ResponseStatus-annotated exceptions as
ResponseStatusException.

This makes it easy to handle the exceptions downstream uniformly.
2015-12-15 12:08:13 -05:00
Rossen Stoyanchev 1f15b7e074 Add ResponseStatusException
This change adds a ResponseStatusException to associate an exception
with a status code at runtime. Along with that is an
ResponseStatusExceptionHandler that handles ResponseStatusException
by setting the response status.
2015-12-15 12:06:53 -05:00
Rossen Stoyanchev 5231e7da7b Fix failing test 2015-12-10 16:50:28 -05:00
Rossen Stoyanchev a0018d13e1 Add DispatcherHandlerErrorTests
The tests demonstrate failures at various phases of request processing
and the resulting error signals.
2015-12-10 16:35:40 -05:00
Rossen Stoyanchev 4ba3d0736f Add HttpExceptionHandler 2015-12-10 16:35:40 -05:00
Rossen Stoyanchev 448aac813a Add MockServerHttpRequest/Response 2015-12-10 16:35:40 -05:00
Sebastien Deleuze 78454f5a2e Add a link to Spring Reactive Playground 2015-12-09 11:18:50 +01:00
Rossen Stoyanchev ef3560a55a Add HttpHandlerDecorator and fix test package 2015-12-08 22:50:25 -05:00
Rossen Stoyanchev 1dcaff8a5c Updates to Javadoc 2015-12-08 22:50:24 -05:00
Stephane Maldini fbb0c702c9 minor reactor server impl to fulfill core introspection 2015-12-09 01:58:53 +00:00
Rossen Stoyanchev ad4be9462b Drop use of WebApplicationContext in tests
It brings along Servlet imports.
2015-12-08 14:33:23 -05:00
Stephane Maldini 4616938525 Prepare for a future change to downstream() inner method in reactor-core 2015-12-08 13:21:35 +00:00
Rossen Stoyanchev 45706422dd InvocableHandlerMethod and arg resolution updates
General improvements e.g. make use of Java 8 Stream. The main reason
for the refactoring however to tighten error handling. To that extent:

InvocableHandlerMethod turns all exceptions into Reactive Streams
error signals, in effect never allowing any Exceptions to bubble up.

HandlerMethodArgumentResolver may throw an Exception for sync resolution
or produce an error signal via the returned Publisher. Either way the
exception is consistently wrapped with helpful method argument details.
For the latter case using a custom mapError operator.

HandlerMethodArgumentResolver no longer needs to return Optional for
nullable argument values. Instead (for now) the defaultIfEmpty operator
of reactor.rx.Stream operator is used to ensure a default constant value
(called "NO_VALUE") is produced. That way an argument resolver may
produce 0..1 values where 0 means it did not resolve to any value and
that results in null passed as the argument value.

If a HandlerMethodArgumentResolver produces more than one value, all
additional values beyond the first one will be ignored with the help
of a custom "first" operator.

As HandlerMethod is invoked within the map operator, checked exceptions
are not allowed but instead of wrapping it in a runtime exception what
we really need is to unwrap the target exception for exception
resolution purposes. To this end concatMap is used to produce a nested
Publisher or an error Publisher with the unwrapped target exception.

Related to that InvocableHandlerMethod now returns
Publisher<HandlerResult> instead of Publisher<Object> so that no longer
needs to be externally mapped from Object to HandlerResult.

InvocableHandlerMethodTests provides tests for the above scenarios and
verifies the details of resulting error signals.
2015-12-07 17:36:58 -05:00
Sebastien Deleuze ce0bd2efc2 Improve Gradle dependencies version management
This commit also updates to the following dependencies:
 - Spring Framework 4.2.3.RELEASE
 - RxJava 1.1.0
2015-12-07 11:35:00 +01:00
Rossen Stoyanchev da98becf72 Move http.server to http.server.reactive 2015-12-02 17:46:07 -05:00
Rossen Stoyanchev 382c98f968 Remove isolated use of Reactor Buffer 2015-12-01 18:19:14 -05:00
Rossen Stoyanchev df80ffbf28 Spring-consistent naming in server.http package
This change also removes reactor-stream variants of the request and
response since the request and response aren't used directly by
application code and get passed through reactor.Publishers anyway.
2015-12-01 18:09:53 -05:00
Stephane Maldini b9a52d5f7c Change to Definitive generic signature for Publishers.zip 2015-12-01 16:51:52 +00:00
Stephane Maldini 9ce5c7416b compiler issue ? 2015-12-01 15:01:34 +00:00
Rossen Stoyanchev 71d1d11fac Non-blocking HandlerMapping chain 2015-12-01 07:34:35 -05:00
Stephane Maldini b26e746120 Use Publishers.zip instead of Streams.zip 2015-12-01 10:43:41 +00:00
Sebastien Deleuze 91c2b7afad Support handler methods returning void, Observable<Void>, etc. 2015-11-30 15:35:58 +01:00
Rossen Stoyanchev 57dc8199fb Add ReactiveHttpFilter 2015-11-25 13:11:01 -05:00
Sebastien Deleuze 0f8a4bf706 Polish imports 2015-11-25 10:42:23 +01:00
Sebastien Deleuze b18919d111 Improve Javadoc for HandlerAdapter and HandlerMapping 2015-11-25 10:35:09 +01:00
Rossen Stoyanchev d319edba28 HandlerMapping is now asynchronous 2015-11-24 17:36:44 -05:00
Sebastien Deleuze dc57e2621c Move HttpServer related classes back to src/main/java
This is needed in order to be able to use Spring Reactive in standalone
applications. These are temporary classes that will return in
src/test/java when Spring Boot support for Reactive applications will
be implemented.
2015-11-24 18:11:44 +01:00
Rossen Stoyanchev 4a3c0bc3b6 Remove top-level org.springfamework.reactive package
reactive.codec -> core.codec
reactive.io    -> util

These may very well not be the final locations. For now they simply
express that there are classes that belong somewhere in core, i.e.
they are lower level dependencies than web.
2015-11-22 15:02:18 -05:00
Rossen Stoyanchev 911d376922 Improve MimeType -> MediaType handling
This change adds an Encoder-to-MediaType lookup in
ResponseBodyResultHandler to avoid MimeType to MediaType creation at
runtime.
2015-11-22 14:41:59 -05:00
Rossen Stoyanchev 8d30722f21 Remove @MVC test with multiple matches
RequestMappingHandlerMapping currently picks the first match and does
have logic to deal with selecting the best match. This caused a
random test failure depending on which controller method was matched
first. This change removes the test.
2015-11-20 13:17:10 -05:00
Rossen Stoyanchev e9e4bcdc59 Move ~.web.reactive.server to ~.http.server 2015-11-20 13:10:44 -05:00
Rossen Stoyanchev 81867fa423 Refactor package structure for web
The web related code is now under org.springframework.web.reactive.
This is parallel to org.springframework.web (the top-level package of
spring-webmvc).
2015-11-13 17:49:31 -05:00
Rossen Stoyanchev 54ce20a5e0 Rename field in HandlerResult 2015-11-13 17:23:00 -05:00
Sebastien Deleuze c6713c23e3 Add a ResolvableType field to HandlerResult
This change allows to be able to check generic type on the return value
at HandlerAdapter and ResultHandler level. For example, it allows to do
a Publisher<Void> check in SimpleHandlerResultHandler.
2015-11-13 17:09:02 -05:00
Rossen Stoyanchev 5d4201d500 Fix "Content-Type" and "Accept" header processing
"Content-Type" is just a single MediaType.

For the response, the MediaType must be fully selected before
selecting and encoder.

The ResponseBodyResultHandler now includes actual content negotiation
with a potential 406 response.
2015-11-13 16:47:52 -05:00
Rossen Stoyanchev 2de127ad4a Polish 2015-11-13 15:55:50 -05:00
Sebastien Deleuze bdc5b38cb1 Refactor codecs
This commit introduces the following changes:
 - MessageToByteEncoder/Decoder renamed to Encoder/Decoder
 - JsonObjectEncoder/Decoder are now used directly in
   JacksonJsonEncoder/Decoder
 - Codec uses MimeType instead of MediaType since they
   are not specific to HTTP
 - Default MimeType are now managed thanks to
   Encoder/Decoder#getSupportedMimeTypes()
 - AbstractEncoder/Decoder takes care of generic MimeType related behavior
2015-11-13 15:01:02 -05:00
Rossen Stoyanchev 141d75791d Polish 2015-11-12 11:52:06 -05:00
Marek Hawrylczak f1bec5f1e4 referencing fields of a class using this 2015-11-07 16:37:40 +01:00
Marek Hawrylczak 9126fd9dec Indentation using tabs 2015-11-07 16:02:09 +01:00
Marek Hawrylczak 4c84117155 undertow support using non-blocking API’s 2015-11-07 15:52:47 +01:00
Rossen Stoyanchev a48c9b6305 Replace DefaultConversionService in spring-reactive 2015-10-30 17:58:59 -04:00
Rossen Stoyanchev c0dff3d2bb Comply with Spring Framework code style
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style
2015-10-30 17:22:19 -04:00
Rossen Stoyanchev 0989c8b3c2 HandlerMethodArgumentResolver is now asynchronous 2015-10-30 16:04:49 -04:00
Rossen Stoyanchev 6b73993a38 HandlerAdapter is asynchronous again 2015-10-30 15:02:54 -04:00
Sebastien Deleuze 01ae961820 Make DefaultConversionService usable by the upcoming client 2015-10-30 11:03:49 +01:00
Sebastien Deleuze a257a4a37d Polishing 2015-10-30 11:02:40 +01:00
Arjen Poutsma b2bf18dd3d Removed Closeable implementation 2015-10-30 09:39:46 +01:00
Arjen Poutsma 5f2e958fae Removed IOException declaration 2015-10-30 09:38:29 +01:00
Arjen Poutsma bd472af37e Updated Copyright notices 2015-10-30 09:26:34 +01:00
Arjen Poutsma 6006fa6ec2 Optimized imports 2015-10-30 09:24:53 +01:00
Arjen Poutsma e121f7ecd4 Improved documentation on setBody() 2015-10-29 16:44:13 +01:00
Arjen Poutsma 45a88974bc Changed addBody() to setBody() 2015-10-29 16:28:22 +01:00
Arjen Poutsma 5727abc82d Resolved merge conflicts 2015-10-29 16:08:10 +01:00
Arjen Poutsma bab3b6fd1c Introduce HttpMessage hierarchy
This commit introduces "reactive" sub-interfaces of the HttpMessage
interface found in the Spring Framework.
2015-10-29 15:45:28 +01:00
Stephane Maldini 3864fc24ff Fix JSON encoding issue 2015-10-29 11:10:38 +01:00
Stephane Maldini fd52ae999b Update to latest reactor-net
Latest reactor-net doesn't depend on reactor-stream anymore (neither reactor-codec and reactor-bus, it only depends on reactor-core).
2015-10-29 11:10:19 +01:00
Sebastien Deleuze adc50bbfb9 Add handler method parameter and result converters
This commit introduces the following changes:
 - Publisher -> Observable/Stream/etc. conversion is now managed
    in a dedicated ConversionService instead of directly in
    RequestBodyArgumentResolver and ResponseBodyResultHandler
 - More isolated logic that decides if the stream should be
    serialized as a JSON array or not
 - Publisher<ByteBuffer> are now handled by regular
   ByteBufferEncoder and ByteBufferDecoder
 - Handle Publisher<Void> return value properly
 - Ensure that the headers are properly written even for response
   without body
 - Improve JsonObjectEncoder to autodetect JSON arrays
2015-10-29 10:50:06 +01:00
Sebastien Deleuze cf2c1514af Use latest Reactor core capabilities
No need for rxjava-reactive-streams dependency and
 CompletableFutureUtils anymore.
2015-10-19 11:15:03 +02:00
Sebastien Deleuze cb09e58a82 Fix SimpleHandlerResultHandler by using Publishers.completable() 2015-10-19 11:01:24 +02:00
Sebastien Deleuze 3ad765556d Polish ByteBufferPublisherInputStream exception handling 2015-10-16 15:35:16 +02:00
Sebastien Deleuze 8ca04b8425 More accurate ResponseBodyResultHandler error message 2015-10-16 09:13:44 +02:00
Stephane Maldini 06a1ddbe93 Eliminate need for reactor stream in CompletableFutureUtils + fixes 2015-10-16 09:11:22 +02:00
Stephane Maldini 80f9a21b9d Tweaks to ByteBufPubInputStream to use available blockingQueue facilities 2015-10-16 09:10:07 +02:00
Stephane Maldini b11bef7a26 Eliminate need for rxJava in Json Encoder 2015-10-16 09:07:51 +02:00
Stephane Maldini 985640b6ce Fix ReactorHttpServer with latest changes on shutdown behavior 2015-10-12 11:22:28 +02:00
Sebastien Deleuze 0042a65c53 Await properly Reactor server start/stop
The goal is to try to fix #32
With this change de Reactor test seems to execute slowly.
2015-10-09 11:38:35 +02:00
Sebastien Deleuze 07374f48d6 Move server related classes from src/test to src/main 2015-10-07 14:06:26 +02:00