Commit Graph

507 Commits

Author SHA1 Message Date
Arjen Poutsma 6457a1556e Javadoc 2017-10-24 10:59:47 +02:00
Arjen Poutsma 40a6fba443 Allow to change URL/method in ClientRequest.Builder
This commit exposes the ClientRequest's URL and HttpMethod fields via a
setter, so that they can be changed more easily in a request that was
created via ClientRequest.from(ClientRequest).

Issue: SPR-16093
2017-10-23 16:39:33 +02:00
Rossen Stoyanchev 1cc5afe24b Fix lines over 120 characters
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style#line-wrapping
2017-10-20 16:42:26 -04:00
Juergen Hoeller e17ad551f3 Latest dependency updates (RxJava 1.3.3, Hibernate ORM 5.2.12, Hibernate Validator 5.4.2 & 6.0.3) 2017-10-20 16:16:06 +02:00
Juergen Hoeller d1fac36e3e SchedulingConfigurer and JmsListenerConfigurer respect @Order
Issue: SPR-16090
2017-10-20 16:10:12 +02:00
Rossen Stoyanchev 48eb416ecc Fix failing tests 2017-10-19 21:42:31 -04:00
Rossen Stoyanchev ab92754a2e @MatrixVariable resolvers for WebFlux
The information was already parsed and available in a request attribute
but until now there were no argument resolvers to expose it.

Issue: SPR-16005
2017-10-19 21:01:38 -04:00
Rossen Stoyanchev d8a7b96b46 WebFlux support for "request handled" in controller
Issue: SPR-16087
2017-10-18 21:07:27 -04:00
Rossen Stoyanchev 950edf888a Support for Map method argument in WebFlux
Issue: SPR-16086
2017-10-18 11:41:46 -04:00
Rossen Stoyanchev 32d78e60b6 Update information on WebApplicationContext hierarchy
Issue: SPR-16041
2017-10-17 21:49:57 -04:00
Rossen Stoyanchev 94c4a7f941 Shortcut factory method in MockServerWebExchange
MockServerWebExchange now has a second factory method that accepts a
MockServerHttpRequest.BaseBuilder.

Issue: SPR-16079
2017-10-17 12:23:12 -04:00
Juergen Hoeller 3890d4c9eb AbstractServerHttpResponse stores HTTP status code as integer value
Issue: SPR-16073
2017-10-16 15:34:09 +02:00
Arjen Poutsma faa74988c4 WebClient.mutate() should not impact future .mutate() invocations
Before this commit, when adding filters to a builder obtained via
`WebClient.mutate()`, the filters were added both to the original client
as well as the mutated builder. This commit fixes that.

Issue: SPR-16059
2017-10-13 11:23:10 +02:00
Brian Clozel 3febec3df6 ResourceWebHandler signals error for missing resources
Prior to this commit, the `ResourceWebHandler` would itself handle the
response with an HTTP 404 in many cases, including a missing static
resource.

This does not give a chance to `WebExceptionHandler` instances to handle
that error and, for example, display an error page.

See spring-projects/spring-boot#8625

Issue: SPR-16023
2017-10-10 23:28:03 +02:00
Rossen Stoyanchev 48c41049b1 Correct package for MockServerWebExchange
Discovered late, but not too late. MockServerWebExchange is now in the
proper package matching to the location of ServerWebExchange.
2017-09-29 17:03:23 -04:00
Rossen Stoyanchev 223e27d53d Package private request and response implementations
Concrete server and client, reactive request and response
implementations should not have to be accessed outside their package.
They could be seen as private to their HttpHandler adapters and
ClientHttpConnector's respectively.

The one exception, WebSocket upgrades in spring-webflux, is an internal
framework use case, accommodated via downcast + accessors in the
abstract base classes.
2017-09-29 13:04:03 -04:00
Arjen Poutsma 69945f4185 WebClient throws ClassCastException for bodyToMono(ParameterizedTypeReference)
Prior to this commit, the `WebClient` always throws a `ClassCastException`
when an error occurs in `bodyToMono(ParameterizedTypeReference)``, and
not the expected exception, as set up by `onStatus`

Issue: SPR-16025
2017-09-29 10:15:40 +02:00
Rossen Stoyanchev d332e06f6c Update reference after removal of ClientResponse.close() 2017-09-28 16:11:48 -04:00
Rossen Stoyanchev 869b818e96 WebFlux support for LocaleContext related arguments
Issue: SPR-15998
2017-09-27 22:03:42 -04:00
Brian Clozel 126ac849e5 Fix behavior of ClientResponse#bodyTo** with Void
Prior to this commit, asking for a `Void` type using any of the
`ClientResponse#bodyTo*` methods would immediately return an empty
`Publisher` without consuming the response body.

Not doing so can lead to HTTP connection pool inconsistencies and/or
memory leaks, since:

* a connection that still has a response body being written to it cannot
be properly recycled in the connection pool
* incoming `DataBuffer` might not be released

This commit detects when `Void` types are asked as body types and in
those cases does the following:

1. Subscribe to the response body `Publisher` to allow the connection to
be returned to the connection pool
2. `cancel()` the body `Publisher` if the response body is not empty; in
that case, we choose to close the connection vs. consume the whole
response body

Those changes imply that `ClientHttpResponse` and other related
contracts don't need a `close()` method anymore.

Issue: SPR-16018
2017-09-28 00:58:38 +02:00
Juergen Hoeller ec345bf162 Revised handling of missing data class arguments
Includes unified detection of Kotlin's optional parameters in MethodParameter.isOptional(), reduces BeanUtils.findPrimaryConstructor to Kotlin semantics (for reuse in AutowiredAnnotationBeanPostProcessor), and finally introduces a common KotlinDetector delegate with an isKotlinType(Class) check.

Issue: SPR-15877
Issue: SPR-16020
2017-09-28 00:31:12 +02:00
Rossen Stoyanchev 6ee1af27c6 WebFlux supports HTTP HEAD
Issue: SPR-15994
2017-09-27 15:25:29 -04:00
Brian Clozel 10139d42fc Revisit meaning of response.close() in HTTP client
Prior to this issue, SPR-15920 added this new `close()` method which was
supposed to be called to clean resources after response processing.

This commit changes the meaning of that method: calling `close()` will
close the underlying HTTP connection. This has to be called if the
response body is not consumed by the application, since at that point
the underlying connection might be in an inconsistent state if shared in
a connection pool.

Issue: SPR-15993
2017-09-27 14:03:55 +02:00
Rossen Stoyanchev 41b53de644 DispatcherHandler.getHandlerMappings() is also final
Issue: SPR-15934
2017-09-26 15:35:17 -04:00
Sebastien Deleuze 14cba15296 Open router and bean Kotlin DSL to allow building custom ones 2017-09-26 16:31:16 +02:00
Brian Clozel 80979e7592 Polish 2017-09-26 11:00:34 +02:00
Brian Clozel 3d37c889fa Un-ignore RequestMapping test for handling "" paths
Issue: SPR-15653
2017-09-26 10:59:21 +02:00
Rossen Stoyanchev bdde0f1ea0 WebFlux supports UriBuilder, UriComponentsBuilder args
Issue: SPR-15997
2017-09-25 16:41:30 -04:00
Rossen Stoyanchev 2da2c17fbb WebFlux supporst HttpHeaders return values
Issue: SPR-16006
2017-09-25 16:09:28 -04:00
Arjen Poutsma 1a3cc3df94 Moved fromServerRequest to ServerRequest itself
This commit moves WebFluxUriComponentsBuilder.fromServerRequest to the
ServerRequest interface itself.

Consequently, the WebFluxUriComponentsBuilder is removes itself, as it
contained no other methods.

Issue: SPR-15953
2017-09-25 11:29:07 +02:00
Juergen Hoeller e2882fe1db Build against EE 8 API level wherever possible
Upgrade to JAXB 2.3, JAX-WS 2.3, Annotations 1.3.1, Interceptor 1.2.1.
Also includes Log4J 2.9.1 and Asciidoctor 1.5.6.
2017-09-24 17:18:21 +02:00
Juergen Hoeller 9190b76ab9 Latest dependency updates (POI 3.17, Rome 1.8, EhCache 3.4, Caffeine 2.5.6, RxJava 2.1.4, Tomcat 8.5.21, JRuby 9.1.13, Rhino 1.7.7.2) 2017-09-23 11:28:19 +02:00
Rossen Stoyanchev ed10cab9d3 Remove DispatcherHandler static factory methods
The typical way to load DispatcherHandler is to use
WebHttpHandlerBuilder#applicationContext which also detecs filters,
exception handlers, as well as other beans that are injected into every
ServerWebExchange -- custom session manager, localecontext resolver,
codecs for form data, multipart data, etc

WebHttpHandlerBuilder is the preferred and way so removing the ones on
DispatcherHandler. They could always be added back later.
2017-09-22 16:24:39 -04:00
Rossen Stoyanchev c28a6357c5 DispatcherHandler alignment with DispatcherServlet
Issue: SPR-15934
2017-09-22 15:44:12 -04:00
Rossen Stoyanchev 816a58fcf9 RouterFunctionMapping provides getter for RouterFunction
Issue: SPR-15991
2017-09-22 15:15:41 -04:00
Rossen Stoyanchev 31619b3ffb DispatcherHandler orders HandlerMappings correctly again
Issue: SPR-15991
2017-09-22 15:06:23 -04:00
Juergen Hoeller 7ae59d0c2a Nullability refinements on private and static methods
Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
2017-09-22 18:22:14 +02:00
Arjen Poutsma 4fbf86e5ce Javadoc 2017-09-22 14:17:51 +02:00
Arjen Poutsma 2841ef5d05 Introduce RouterFunction visitor
This commit introduces a visitor for router functions
(RouterFunctions.Visitor), allowing to iterate over all the components
that make up a router function.

This commit also introduces a ToStringVisitor, which creates a nicely
formatted string for use with toString().

Issue: SPR-15711, SPR-15711
2017-09-22 14:03:09 +02:00
Jason Yu 78434c8e20 Release DataBuffers in FreeMarkerView
When template processing throws an exception, we must ensure that
`DataBuffers` are properly released to avoid memory leaks.

Issue: SPR-15966
2017-09-22 10:08:18 +02:00
Rossen Stoyanchev 819ca0dbd4 Expose getters for the configured HandlerMapping's
Issue: SPR-15934
2017-09-21 09:46:26 -04:00
Arjen Poutsma a7617a2641 Introduce WebFluxUriComponentsBuilder
This commit introduces the WebFluxUriComponentsBuilder, with a single
method that creates a UriComponentsBuilder for a ServerRequest. More
methods to be added by @rstoyanchev.

Issue: SPR-15953
2017-09-15 14:14:39 +02:00
Arjen Poutsma 2fb3eeba6f Introduce ServerRequest.methodName()
This commit introduces a methodName() method to the ServerRequest,
returning the String name of the method. This method is useful for
non-standard HTTP methods.
2017-09-15 14:14:39 +02:00
Sebastien Deleuze 1bc93e3d0f Revisit nullability annotations
This commit introduces the following changes.

1) It adds a new Spring @NonNull annotation which allows to apply
@NonNullApi semantic on a specific element, like @Nullable does.
Combined with @Nullable, it allows partial null-safety support when
package granularity is too broad.

2) @Nullable and @NonNull can apply to ElementType.TYPE_USE in order
to be used on generic type arguments (SPR-15942).

3) Annotations does not apply to ElementType.TYPE_PARAMETER anymore
since it is not supported yet (applicability for such use case is
controversial and need to be discussed).

4) @NonNullApi does not apply to ElementType.FIELD anymore since in a
lot of use cases (private, protected) it is not part for the public API
+ its usage should remain opt-in. A dedicated @NonNullFields annotation
has been added in order to set fields default to non-nullable.

5) Updated Javadoc and reference documentation.

Issue: SPR-15756
2017-09-15 13:26:41 +02:00
Brian Clozel 81125de697 Fix error responses handling in WebClient
This commit fixes a typo in the `DefaultWebClient` implementation.
Instead of forwarding resolved `WebClientException` instances as error
signals, the `bodyToMono(ParameterizedTypeReference)` variant would just
forward those exceptions as `onNext` signals.

Issue: SPR-15946
2017-09-14 14:15:05 +02:00
Brian Clozel 98b6491f0c Send error signal also for empty server responses
Prior to that commit, the `ResponseSpec` `WebClient` would process error
responses (4xx, 5xx HTTP status) and transform those into error signals
with a `WebClientResponseException`. But this would only work if the
HTTP response would have a non-empty response body.

An empty error response would not send an error signal and only
translate in an `onComplete` signal.

This commit fixes this behavior and makes sure that this error signal is
sent in all cases.

Issue: SPR-15946
2017-09-13 10:56:57 +02:00
Brian Clozel aa19912e00 Polish 2017-09-13 10:51:13 +02:00
Rossen Stoyanchev e214d69350 Remove jetbrains annotations inserted by IDE 2017-09-11 09:31:43 -04:00
Rossen Stoyanchev f76ac5bb32 WebFlux support for @SessionAttributes
Issue: SPR-15887
2017-09-09 17:40:59 -04:00
Rossen Stoyanchev bc470fca30 Polish 2017-09-09 17:40:59 -04:00
Juergen Hoeller fd0132c7e6 Polishing 2017-09-08 16:56:22 +02:00
Juergen Hoeller 496223a927 WebFlux supports field default/marker parameters for data classes as well
Issue: SPR-15871
2017-09-08 16:55:12 +02:00
Sam Brannen 15ab0ad6e2 Clean up warnings in Gradle build output 2017-09-07 12:25:10 +02:00
Brian Clozel 16f3f8d28f Add close() method on HTTP client response
Before this commit, there was no way to signal the HTTP client that we
were done consuming the response. Without that, the underlying client
library cannot know when it is safe to release the associated resources
(e.g. the HTTP connection).

This commit adds new `close()` methods on both `ClientHttpResponse`
and `ClientResponse`. This methods is non-blocking and its behavior
depends on the library, its configuration, HTTP version, etc.

At the `WebClient` level, `close()` is called automatically if we
consume the response body through the `ResponseSpec` or the
`ClientResponse` itself.

Note that it is *required* to call `close()` manually otherwise; not
doing so might create resource leaks or connection issues.

Issue: SPR-15920
2017-09-06 17:29:18 +02:00
Arjen Poutsma 02a2c400c7 Move URL transform methods from ServerHttpResponse to ServerWebExchange
This commit moves `encodeUrl` and `registerUrlEncoder` from
ServerHttpResponse to ServerWebExchange.

It also renames `encodeUrl` to `transformUrl` and `registerUrlEncoder`
to `addUrlTransformer` to make it clearer that these methods do not
perform actual URL encodings (i.e. they do not replaceinvalid
characters).
The `add` prefix (instead of `register`) makes it clearer that each
function is added in addition to the previous one.

Issue: SPR-15924
2017-09-06 14:39:09 +02:00
Rossen Stoyanchev 03eb6f76db Improve check for actual return value type
Issue: SPR-15910
2017-09-05 16:11:35 -04:00
Rossen Stoyanchev fc0841c60f Adapt to method name change in Mono 2017-09-05 13:57:20 -04:00
Arjen Poutsma 14af5d941a Javadoc
Issue: SPR-15912
2017-08-31 13:55:19 +02:00
Juergen Hoeller b122bc6dcc Upgrade to Hibernate Validator 6.0.2
Includes latest dependency updates (Netty 4.1.15, Undertow 1.4.19)

Issue: SPR-15808
2017-08-29 15:04:17 +02:00
Sebastien Deleuze d2c1b284f3 Polish Kotlin API contracts and documentation
Issue: SPR-15659
2017-08-29 00:56:39 +02:00
Brian Clozel 397fd24849 Revert "Leverage Kotlin plugin dependency management"
This reverts commit 3e2f6c848a.
2017-08-22 21:29:39 +02:00
Sebastien Deleuze 3e2f6c848a Leverage Kotlin plugin dependency management 2017-08-22 17:35:57 +02:00
Stephane Nicoll 5a51351fa4 Relax test assertion when Jacoco is enabled
This commit changes the resolveMethod to take a method name as
instrumentation may add additional methods to the test object.

Issue: SPR-15888
2017-08-22 10:26:19 +02:00
Sebastien Deleuze 9abe77670c Sync with reactor-core when() -> zip() change 2017-08-21 19:54:08 +02:00
Brian Clozel cc3d7d2d48 Apply dependency management to selected modules
This commit applies the Dependency Management Plugin to modules that
require it; right now Spring Framework is importing BOMs for Netty and
Reactor dependencies only.

Instead of applying those BOMs to all modules, they're applied only
where they're needed.

Issue: SPR-15885
2017-08-21 14:42:03 +02:00
Brian Clozel 2eeb428e95 Move modules to independent build files
The main `build.gradle` file contains now only the common build
infrastructure; all module-specific build configurations have
been moved to their own build file.

Issue: SPR-15885
2017-08-21 14:41:55 +02:00
Stephane Nicoll f6e7fef236 Polish 2017-08-19 10:50:41 +02:00
Juergen Hoeller 47a7475898 Resolve remaining nullability warnings
Issue: SPR-15869
2017-08-18 00:15:46 +02:00
Sebastien Deleuze 73cf07e9a4 Fix overridden methods nullability
Issue: SPR-15869
2017-08-17 15:02:59 +02:00
Rossen Stoyanchev 645e3492db Use URLDecoder for query params in WebFlux
Issue: SPR-15860
2017-08-16 13:34:31 +02:00
Sebastien Deleuze f57e5584af Add a reference to KT-18833 in JDK 9 ignored tests 2017-08-14 11:47:08 +02:00
Juergen Hoeller adeb521ce4 Polishing 2017-08-08 17:27:28 +02:00
Rossen Stoyanchev 08dfce2cb5 Dedicated specificity comparator in PathPattern
The PathPattern compareTo method is now consistent with equals when
two patterns are of the same specificity but otherwise different.

Separately PathPattern now exposes a Comparator by specificity that
offers the current functionality of compareTo. This can be used for
actual sorting where we only care about specificity.
2017-08-02 18:11:36 +02:00
Rossen Stoyanchev 62fa20fd6f PathPattern#matchAndExtract minor refactoring
Consistent behavior with matches(PathContainer), the two had slightly
different logic for handling of empty paths.

Make matchAndExtract independantly usable without the need to call
matches(PathContainer) first. Essentially no longer raising ISE if the
pattern doesn't match but simply returning null.
2017-08-02 16:31:06 +02:00
Rossen Stoyanchev dccedd5ad5 Minor refactoring in PathPattern
Rename getPathRemaining to matchStartOfPath since the method does
match and to be more clear about what the method and the return value
intuitively follows.

Remove matchStart which matches the start of the pattern (rather than
the start of the path). It is a use case that does not come up in
request mapping.
2017-08-02 15:05:28 +02:00
Rossen Stoyanchev c060f4f615 Polish PathPattern and parser
Updates to Javadoc
Consistent and separator type neutral naming for trailing slash
PathPattern extracts options from the parser instance
2017-08-02 14:21:16 +02:00
Arjen Poutsma 5394cc0c63 WebClientException should allow access to status code of the response
This commit changes the WebClient so that it now throws a
`WebClientResponseException` for `ResponseSpec.bodyTo`. This newly
introduces exception contains the status code, headers, and body of the
response message.

As a consequence of the above, we had to change `onStatus` so that the
`exceptionFunction` now returns a `Mono<Throwable>` rather than a
`Throwable`, which it was before. The Mono allows for asynchronous
operations, such as reading the contents of the body.

Issue: SPR-15824
2017-08-02 10:20:58 +02:00
Rossen Stoyanchev b1440b6816 Remove ParsingPathMatcher
Now that we also have RequestPath and PathContainer with the latter as
the required input, the ParsingPathMatcher adapter can be removed.
2017-08-01 13:35:21 +02:00
Rossen Stoyanchev 4fc0ce1206 Properly detect null value params in params conditions
Issue: SPR-15831
2017-08-01 13:01:09 +02:00
Rossen Stoyanchev f813a63fd8 PathContainer parses URL paths only
Collapse non-URL vs URL based path parsing into one essentially
supporting URL paths only.
2017-07-31 22:10:08 +02:00
Arjen Poutsma 0b3ea405ab Remove BodyInserters.fromServerSentEvent variants
Removed superfluous `fromServerSentEvent` variants from `BodyInserters`,
as their functionality can also be obtained by passing a stream of
strings or POJOs (to be encoded as JSON) to
`fromPublisher(Publisher, Class)}`, and specifying a `text/event-stream`
Content-Type.

Issue: SPR-15826
2017-07-28 12:37:19 +02:00
Rossen Stoyanchev 6855a85c41 Move RequestPath to parent server package 2017-07-28 12:26:34 +02:00
Sebastien Deleuze 6583f9f754 Use ParameterizedTypeReference instead of Class in Kotlin extensions
This commit also removes WebFlux non-extension functions in favor of
regular Kotlin extensions leveraging ParameterizedTypeReference parameter.

Issue: SPR-15818
2017-07-28 00:22:00 +02:00
Arjen Poutsma 1d86c9c3d1 Use Credentials object instead of 2 attributes for Basic Authentication
This commit changes the usage of two separate attributes (username and
password) into one: a single `Credentials` object.
Additionally, the attributes key under which the credentials are stored
is changed to be specific to Basic Authentication, in order to allow for
other sorts of authentication later.

Issue: SPR-15764
2017-07-27 16:09:09 +02:00
Sebastien Deleuze 3cef5a1294 Add RouterFunctions#toWebHandler(RouterFunction<?>) 2017-07-27 15:25:35 +02:00
Arjen Poutsma eb435f5947 Add ParameterizedTypeReference method variants to ServerRequest/ServerResponse
This commit changes adds overloaded `ParameterizedTypeReference `
variants to body-related methods in `ServerRequest` and
`ServerResponse`.
It also adds a single PTR variant to ClientRequest, which was missing
before.

Issue: SPR-15817
2017-07-27 13:38:35 +02:00
Arjen Poutsma f3975776d4 Use list of HttpMessage[Reader|Writer]s instead of CodecConfigurer
This commit changes all consumers of CodecConfigurer to consume a `List`
of HttpMessageReaders or HttpMessageWriters instead of consuming the
Server- or ClientCodecConfigurer directly.

Issue: SPR-15816
2017-07-26 17:48:36 +02:00
Sebastien Deleuze ed6fe2b723 Upgrade to Kotlin 1.1.4-eap-33
Issue: SPR-15814
2017-07-24 17:29:02 +02:00
Sebastien Deleuze d8a80fc0db Rename RouterFunction Kotlin DSL files 2017-07-20 16:05:00 +02:00
Sebastien Deleuze 0720f9e978 Fix an eventual IndexOutOfBoundsException in RequestPredicates 2017-07-20 16:05:00 +02:00
Rossen Stoyanchev 378c72e9b6 Polish + minor refactoring of ResourceUrlProvider 2017-07-19 23:04:39 +02:00
Juergen Hoeller ac1d3b22c9 Polishing 2017-07-19 22:22:27 +02:00
Juergen Hoeller 46eba3dbfa Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 22:22:20 +02:00
Rossen Stoyanchev 147368eccc Proactively reject URLs without target address
Issue: SPR-15782
2017-07-19 12:37:32 +02:00
Juergen Hoeller 9fc4fb10b0 Nullability fine-tuning around bean properties
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 11:43:58 +02:00
Sebastien Deleuze fb4ddb0746 Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between
getters and setters in order to be able to provide beans
with properties with a common type when type safety is
taken in account like with Kotlin.

It also add a few missing property level @Nullable
annotations.

Issue: SPR-15792
2017-07-19 09:07:56 +02:00
Rossen Stoyanchev 43f2de4671 Defensive checks in WebClient and Reactor connector
Since there is no reason for an exchange to ever complete without a
ClientResponse I've added a switchIfEmpty check at the WebClient level.

Also, temporarily a second check closer to the problem in the
ReactorClientHttpConnector suggesting a workaround and providing a
reference to the Reactor Netty issue #138.

Issue: SPR-15784
2017-07-18 18:13:47 +02:00
Rossen Stoyanchev 56903581d9 ResponseEntity declared as Object in WebFlux controller
Issue: SPR-15785
2017-07-18 17:09:24 +02:00
Rossen Stoyanchev 57221ab15c ContentVersionStrategy has non-blocking contract
Issue: SPR-15773
2017-07-18 15:57:49 +02:00
Rossen Stoyanchev efb5ba5a95 Refactor VersionStrategy in WebFlux
Collapse the base interface VersionPathStrategy into its extension
VersionStrategy and then turn the prefix nad fliename based
implementations into abstract base classes (vs delegate strategies).

It is simpler to have one VersionStrategy hierarchy vs that plus a
separate VersionPathStrategy as a delegate. In practice each
VersionStrategy is suited to be prefix or filename based. Also none
of our code cares about the distinction between those two interfaces.
2017-07-18 15:57:49 +02:00
Brian Clozel a06da0019f Remove PathPatternParser from PatternsRequestCondition
Since `PathPattern.combine` now returns another `PathPattern` instance
(it was previously returning a String instance), we can now safely
remove the parser instance included in `PatternsRequestCondition`.

Issue: SPR-15663
2017-07-18 11:40:30 +02:00
Rossen Stoyanchev b0422d02dc Resource transformers use AsynchronousFileChannel
Issue: SPR-15773
2017-07-18 03:58:21 +02:00
Rossen Stoyanchev 70252a7335 Add tests for SPR-15777 2017-07-17 08:35:58 +02:00
Rossen Stoyanchev 47b63150d1 Refactor DefaultWebSession
Use copy constructor to refresh a session with lastAccessTime and a
save function referencing the current exchange. As a result both fields
are now final and ConfigurableWebSession is no longer needed.
2017-07-14 22:55:56 +02:00
Rossen Stoyanchev 9d04c0424d Allow empty body with no content type in BodyExtractors
Issue: SPR-15758
2017-07-14 14:38:42 +02:00
Rossen Stoyanchev d2c6ea5b1b Polish 2017-07-14 13:23:11 +02:00
Arjen Poutsma 805b7159b0 Add ParameterizedTypeReference variants to bodyTo[Mono|Flux], toEntity[List]
This commit introduces overloaded variants of `bodytoMono`,
`bodyToFlux`, `toEntity`, and `toEntityList` that take a
`ParameterizedTypeReference`. It also adds similar methods to
`WebClient.ResponseSpec`.

Issue: SPR-15725
2017-07-14 13:09:44 +02:00
Sebastien Deleuze f46520e6e8 Add Jackson Smile support to WebFlux
This binary format more efficient than JSON should be useful for server
to server communication, for example in micro-services use cases.

Issue: SPR-15424
2017-07-13 17:57:07 +02:00
Rossen Stoyanchev ed5cc27f7b Support empty body without content type in WebFlux
Issue: SPR-15758
2017-07-13 11:11:34 +02:00
Arjen Poutsma d6c102d1b8 Add apply method to WebClient.Builder
This commit introduces an apply method to `WebClient.Builder`, allowing
users to make multiple changes to the builder in one consumer.

Issue: SPR-15743
2017-07-12 14:53:06 +02:00
Rossen Stoyanchev 9ac71afbda Fix one failing test and @Ignore another
The failures look like older failures possibly exposed by recent
changes in Reactor.

The one in ViewResolutionResultHandler is very old test error.
The one in Jackson2JsonDecoderTests is more recent but went unreported.
2017-07-12 13:16:51 +02:00
Rossen Stoyanchev befacf4a35 ParameterContentNegotiationStrategy uses MediaTypeFactory
Issue: SPR-15649
2017-07-11 17:54:16 +02:00
Arjen Poutsma c9a3b863c4 Move toEntity(List) from WebClient.ResponseSpec to ClientResponse
This commit moves `toEntity(Class<T>)` and `toEntityList(Class<T>)`
from WebClient.ResponseSpec to ClientResponse. The main reason for doing
so is that the newly introduced `onStatus` method (see
2f9bd6e075) does not apply to these two
methods, and the result would be confusing. Also, `ClientResponse` and
`ResponseEntity` represent the same data: status code, headers, and a
body.

Issue: SPR-15724
2017-07-11 17:40:16 +02:00
Arjen Poutsma 51e02c2911 Add status-based error filter
This commit introduces an ExchangeFilterFunction that throws an
exception given a HTTP status predicate.

Issue: SPR-15724
2017-07-11 16:36:47 +02:00
Arjen Poutsma 2f9bd6e075 Add local error handling in WebClient.retrieve
This commit introduces a way to customize the WebClientExceptions, as
thrown by WebClient.ResponseSpec.bodyTo[Mono|Flux]. The first
customization will override the defaults, additional customizations are
simply tried in order.

Issue: SPR-15724
2017-07-11 16:36:40 +02:00
Arjen Poutsma 2ea693bd83 Add ClientRequest.attribute(String)
This commit adds the attribute(String) convenience method to the
ClientRequest class. It also adapts the Basic Authentication filter to
use it.
2017-07-11 15:41:33 +02:00
Arjen Poutsma e11bb17aa6 Change ServerRequest.attribute(String) to return Object
This commit changes `ServerRequest.attribute(String)`` to return
`Optional<Object>` instead of `Optional<T>`, where `T` was infered
from a type parameter.
2017-07-11 15:41:33 +02:00
Rossen Stoyanchev 0e370e0703 Separate out URL path parsing in PathContainer
PathContainer now has separate parsePath and parseUrlPath methods each
creating PathSegment and UrlPathSegment respectively.
2017-07-11 10:56:19 +02:00
Rossen Stoyanchev 2f17c5f3b6 From static to instance-based PathContainer#subPath 2017-07-11 06:05:36 +02:00
Rossen Stoyanchev 9f7d57f933 Encapsulate choice of URI encoding within RequestPath
Currently the URI path is always treated as UTF-8 so we can eliminate
the encoding parameter from RequestPath#parse.
2017-07-11 06:05:36 +02:00
Rossen Stoyanchev fac35ebec2 Remove PathPatternRegistry 2017-07-10 11:37:18 +02:00
Rossen Stoyanchev 9640cedeae Removing remaining use of PathPattern with String path 2017-07-07 19:20:36 +02:00
Arjen Poutsma 3232cb6260 Avoid required uri when using WebClient w/ base url
This commit makes the `uri` step of the WebClient optional, so that
users who have specified a base URL during WebClient config do not need
to provide an empty one (i.e. `url("")`).

The basic idea of this fix is that the HTTP method methods in WebClient
(`get`, `post`, etc.) should be able to "bypass" the uri stage, and skip
straight to defining headers, or even doing an exchange or retrieve
(i.e. call methods on `RequestHeaderSpec` or `RequestBodySpec`).

I have accomplished this by adding two new composed interfaces:
`RequestHeadersUriSpec` and `RequestBodyUriSpec`.
`RequestHeadersUriSpec` extends from the existing `UriSpec` and
`RequestHeaderSpec`, while `RequestBodyUriSpec` extends from `UriSpec`
and `RequestBodySpec`. These types are returned from the HTTP methods
(`get`, `post` etc). The `uri` methods on these types return a plain
`RequestHeaderSpec` and `RequestBodySpec` (i.e. types without the `uri`
methods), so that you can call `uri` once only.

Issue: SPR-15695
2017-07-07 17:07:15 +02:00
Rossen Stoyanchev 4e95378fc6 Remove unused imports 2017-07-06 15:28:32 +02:00
Rossen Stoyanchev 5f9f323b12 Add logging to randomly failing websocket test 2017-07-06 15:07:41 +02:00
Rossen Stoyanchev acd6b9df06 Fix failing test
Explicitly pass the client-side JSR-356 WebSocketContainer to the
TomcatWebSocketClient to prevent the ContainerProvider from finding
the one from undertow-websockets-jsr through the ServiceLoader API.
2017-07-06 14:32:46 +02:00
Arjen Poutsma b0ab84657b Disable "failOnServerError" in ReactorClientHttpRequest
This commit disables the "failOnServerError" feature on the
`HttpClientRequest`, as wrapped by ReactorClientHttpRequest. 5xx errors
are supposed to be dealt with in the WebClient, not in the lower-level
components.

Issue: SPR-15739
2017-07-06 13:37:21 +02:00
Arjen Poutsma 0065bc5ee5 Support null query param values in ServerRequest.queryParam(String)
Issue: SPR-15740
2017-07-06 12:10:55 +02:00
Arjen Poutsma 74b4c02881 Add ClientRequest attributes
This commit introduces client-side request attributes, similar to those
found on the server-side. The attributes can be used, for instance, for
passing on request-specific information to a globally registered
ExchangeFilterFunction.

The client request builder, as well as WebClient.RequestHeadersSpec and
WebTestClient.RequestHeaderSpec, add methods for adding a single
attribute, as well as manipulating the entire attributes map.

The client request itself adds a accessor for the (immutable) attributes
map.

This commit also introduces a new variant of the basic authentication
filter in ExchangeFilterFunctions. This variant takes the username and
password from well-known attributes.

Issue: SPR-15691
2017-07-05 14:52:38 +02:00
Juergen Hoeller a6d616d844 Exception handler methods may receive original as well as cause
Issue: SPR-15701
2017-07-05 13:39:30 +02:00
Brian Clozel 9c93521512 Leverage PathPatternParser in CORS configuration source
Previously `UrlBasedCorsConfigurationSource` was relying on
`PathMatcher` implementations for matching incoming request lookup paths
with the configured path patterns for CORS configuration.

This commit replaces the use of `PathMatcher` with a `PathPatternParser`
that parses the string patterns into `PathPattenr` instances and allows
for faster matching against lookup paths.

Issue: SPR-15688
2017-07-04 16:01:18 +02:00
Violeta Georgieva fd1859c34c Adapt to the changes in Reactor Netty ClientOptions
ClientOptions/HttpClientOptions are now created via Builder
2017-07-04 15:26:29 +02:00
Rossen Stoyanchev f7478446b7 Improve Object return type support in WebFlux
Issue: SPR-15731
2017-07-04 08:19:50 -04:00
Arjen Poutsma f8589d9eca Return MultiValueMap from ServerRequest.queryParams instead of List
This commit changes ServerRequest.queryParams from returning a
List<String> given a String name, to returning a
MultiValueMap<String, String>, which gives more flexibility.
2017-07-03 16:23:33 +02:00
Arjen Poutsma 2ccbc55ffd Use PathContainer in web.reactive.function.server
This commit uses the newly introduced `PathContainer` and `RequestPath`
support in the functional web framework. It exposes the path container
as property in `ServerRequest`, and uses that in the path-based
`RequestPredicates`.
2017-07-03 13:36:30 +02:00
Rossen Stoyanchev 9528c3532d Fix typo 2017-07-01 21:07:08 -04:00
Rossen Stoyanchev 15cf9c1d78 Switch to ContainerPath variants in HandlerMapping's 2017-07-01 20:05:17 -04:00
Rossen Stoyanchev 145eab9c2f Remove PathMatchResultComparator
Follow-up change to the previous commit.
2017-07-01 17:27:54 -04:00
Rossen Stoyanchev a5e54788cc Remove PathPatternComparator
Direct comparison of a pattern (as a String) to the path does not make
much sense now that we deal with URL encoding through PathContainer
which exposes (safely) decoded path segments.

Removing the PathPatternComparator also means we can keep patterns
pre-sorted instead of sorting them all the time. That probably offsets
any benefits from comparing to the lookup path for direct matches and
patterns are still sorted according to specificity.
2017-06-30 18:19:35 -04:00
Rossen Stoyanchev 8581afa621 WebFlux compiles after PathPattern/Container changes 2017-06-30 18:19:35 -04:00
Arjen Poutsma 930f0f1760 Add ServerRequest.cookies()
This commit introduces a cookies() method on ServerRequest, returning a
MultiValueMap<String, HttpCookie>.

Issue: SPR-15715
2017-06-30 16:31:37 +02:00
Juergen Hoeller cc74a2891a @Nullable all the way: null-safety at field level
This commits extends nullability declarations to the field level, formalizing the interaction between methods and their underlying fields and therefore avoiding any nullability mismatch.

Issue: SPR-15720
2017-06-30 01:54:16 +02:00
Rossen Stoyanchev 8f4eb23540 Remove use of Optional in SyncHandlerMethodArgumentResolver
... and a couple more protected methods in WebFlux

Issue: SPR-15718
2017-06-29 17:19:48 -04:00
Rossen Stoyanchev 7de6cfa1df Refactor WebSession#getAttribute options
Issue: SPR-15718
2017-06-29 15:23:36 -04:00
Rossen Stoyanchev 9253facf02 Refactor ServerWebExchange#getAttribute options
Issue: SPR-15718
2017-06-29 14:55:30 -04:00
Stephane Maldini cd643704ad Update to reactor core 3.1.0.B-S with context update for monoSendOperator
Explicit typing for older jvm compilation in BodyExtractor
2017-06-29 10:47:28 -07:00
Rossen Stoyanchev 67330dfc23 Expose mapped handler as an exchange attribute
Issue: SPR-15564
2017-06-29 13:18:39 -04:00
Rossen Stoyanchev 667437e300 Polish 2017-06-27 18:48:45 -04:00
Sebastien Deleuze d728d597f2 Add missing license headers in Kotlin files 2017-06-27 14:39:26 +02:00
Juergen Hoeller 98642c7e29 Consistent ScriptTemplateView locale resolution via request
Issue: SPR-15064
2017-06-26 23:28:49 +02:00