Commit Graph

2069 Commits

Author SHA1 Message Date
Rossen Stoyanchev 9640cedeae Removing remaining use of PathPattern with String path 2017-07-07 19:20:36 +02:00
Juergen Hoeller 00f4c36d7a Nullability fine-tuning (RequestContext, LocaleResolver)
Includes page-level JSTL time zone support for JSP tags.

Issue: SPR-15720
Issue: SPR-15746
2017-07-07 18:46:19 +02:00
Arjen Poutsma e458862849 Reflect recent Reactor changes 2017-07-07 15:24:15 +02:00
Rossen Stoyanchev e0de7754cc Polish 2017-07-07 09:44:02 +02:00
Renato Soppelsa 3dd6069578 Add UTF8 problem+json media type constant
Issue: SPR-15742
2017-07-07 09:42:50 +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 625855c00f Add comment indicating path segment combining in UriComponents.normalize
Issue: SPR-15734
2017-07-06 11:45:13 +02:00
Juergen Hoeller 45d376b6af Polishing 2017-07-05 10:55: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
Brian Clozel baaa84e90f Include port info in HTTP headers for Netty client
This commit adds the port information in the "Host" HTTP request header
for the Netty-based HTTP client.

Issue: SPR-15706
2017-07-04 12:13:06 +02:00
Sebastien Deleuze 7a171c6ae9 Fix Kotlin return types to match @Nullable annotations 2017-07-04 11:27:54 +02:00
Arjen Poutsma de9196bbdc Change from flatMap to map
Changed main tokenbuffer decoding loop from using flatMap to using map.
2017-07-04 10:51:43 +02:00
Brian Clozel 839b6c18d4 Optimize Flux pipeline in ClientHttpRequest 2017-07-04 10:11:56 +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
Sebastien Deleuze 727ca4514a Stream custom types in Jackson2JsonEncoder
Issue: SPR-15727
2017-07-03 10:25:59 +02:00
Sebastien Deleuze 9901c38f9d Improve logging of DefaultCorsProcessor for rejected headers
Issue: SPR-15708
2017-07-03 09:47:43 +02:00
Sebastien Deleuze 1fa8410995 Leverage RFC_1123_DATE_TIME formatter in tests
Issue: SPR-15661
2017-07-02 22:33:43 +02:00
Rossen Stoyanchev 15cf9c1d78 Switch to ContainerPath variants in HandlerMapping's 2017-07-01 20:05:17 -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 850083ca6c Polish 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
Andy Clement 26448a0ebc Rework matching to use PathContainer 2017-06-30 18:19:35 -04:00
Rossen Stoyanchev fc3fcf05fd Refactor PathSegmentContainer -> PathContainer
The new PathContainer represent the path as a series of elements
including separators. This naturally represents leading/trailing
slashes and empty path segments which in turn makes it easier to match
in PathPattern as well as to reconstruct the path.
2017-06-30 18:19:35 -04:00
Violeta Georgieva 5f020d1ee7 Polish - the flag continueProcessing is not needed 2017-06-30 09:59:32 +03: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
Juergen Hoeller c4694c3f5c WebAsyncManager defensively ignores attribute type mismatch
Issue: SPR-15709
2017-06-30 01:53:30 +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
Arjen Poutsma 58a5e7f17b Proper closing of resources
This commit introduces a `doFinally` block that properly signals the
end of input for the non-blocking XML and JSON parsers.
2017-06-29 16:48:53 +02:00
Arjen Poutsma 9d7b8503d0 Delay DataBuffer release until stream is closed
This commit changes the release of data buffers from a finally block
into a `doFinally()` lambda on the returned `Flux<XMLEvent>` stream.

Issue: SPR-15707
2017-06-29 16:19:03 +02:00
Stephane Nicoll b1f06fddd2 Polish
Issue: SPR-14528
2017-06-29 10:26:50 +02:00
Arjen Poutsma 31e0e53750 Leverage Jackson non-blocking parser
This commit introduces the Jackson2Tokenizer as a replacement for the
JsonObjectDecoder. The latter was dropped because of its complexity, and
hard dependency on Netty's ByteBuf.

The new Jackson2Tokenizer leverages the new non-blocking JSON parser,
using it to parse the incoming data buffers into TokenBuffers, each
token buffer representing one JSON object. As with JsonObjectDecoder,
it also supports streaming individual JSON array elements.

Issue: SPR-14528
2017-06-28 16:19:01 +02:00
Arjen Poutsma b778f94a07 Made ObjectMapper field private with protected accessor 2017-06-28 16:19:01 +02: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 87430f3cd3 ListenableFuture provides CompletableFuture adaptation via completable()
Issue: SPR-15696
2017-06-27 00:43:37 +02:00
Rossen Stoyanchev 5b8f7f503f Deprecate adapter classes for async interceptors 2017-06-26 15:34:51 -04:00
Rossen Stoyanchev eb0479dee8 Polish 2017-06-26 14:50:11 -04:00
Violeta Georgieva e0678ba583 Add onError callback to DeferredResult
Issue: SPR-15614
2017-06-26 14:12:56 -04:00
Juergen Hoeller 098ff6f0f8 Compatibility with JDK 9 release candidate build (175)
Includes upgrade to Objenesis 2.6, Gradle 3.5.1, RxJava 2.1.1, JSON Binding API 1.0 final.

Issue: SPR-15686
Issue: SPR-15600
2017-06-26 18:58:59 +02:00
Sebastien Deleuze ba3a12e4cc Use fixed GMT time-zone for WebSession Clock
Issue: SPR-15675
2017-06-26 18:01:21 +02:00
Rossen Stoyanchev 97390fd939 Polish 2017-06-23 17:05:57 -04:00
Rossen Stoyanchev 8fc3b3bc37 Add WebTestClientConfigurer
Issue: SPR-15674
2017-06-23 14:45:46 -04:00
Rossen Stoyanchev c37c59f578 Consumer methods for WebHttpHandlerBuilder
Replace the more limited List-based methods to add filtes and exception
handlers with Consumer<List<?>> variants.
2017-06-23 07:12:10 -04:00
Sebastien Deleuze 5c1d8c7c59 Leverage ZonedDateTime in HttpHeaders
This commit introduces 2 new public methods in HttpHeaders in order
to leverage Java 8 ZonedDateTime in addition to the existing long
(with GMT time zone implied) variants:
 - ZonedDateTime getFirstZonedDateTime(String headerName)
 - void setZonedDateTime(String headerName, ZonedDateTime date)

This commit also leverages Java 8 thread-safe DateTimeFormatter for
HttpHeader implementation instead of SimpleDateFormat. As a consequence
of the usage of DateTimeFormatter.RFC_1123_DATE_TIME, HTTP date header
serialization could change slightly for single digit days from for
example "Thu, 01 Jan 1970 00:00:00 GMT" to
"Thu, 1 Jan 1970 00:00:00 GMT".

Issue: SPR-15661
2017-06-23 00:15:51 +02:00
Arjen Poutsma 0a4d3c14db Jackson2JsonDecoder should support empty JSON array
Before this commit, the Jackson2JsonDecoder was not able to decode an
empty JSON array (`[]`). After this commit, it is.

Issue: SPR-15685
2017-06-21 11:14:34 +02:00
Sebastien Deleuze 1e04cdfa7e Add CorsWebFilter
This new WebFilter implementation is designed to allow initial
CORS support when using WebFlux functional API. More high-level
API may be introduced later.

Issue: SPR-15567
2017-06-21 10:50:09 +02:00
Sebastien Deleuze 59e90943e4 Rename CorsProcessor#processRequest to process 2017-06-21 10:50:09 +02:00
Juergen Hoeller 03133630cb Missing @Nullable annotations in WebFlux, in particular around locale resolution
Issue: SPR-15036
Issue: SPR-15540
2017-06-20 18:08:42 +02:00
Juergen Hoeller 535103cd52 Fine-tune HTTP/RMI Invoker exception handling
Issue: SPR-15684
2017-06-20 16:50:35 +02:00
Juergen Hoeller c244f33f84 Polishing 2017-06-20 16:50:02 +02:00
Sebastien Deleuze 38db64e0d8 Warn when Jackson + Kotlin are used without jackson-module-kotlin
Issue: SPR-15658
2017-06-17 00:07:59 +02:00
Rossen Stoyanchev 4a21fb27fc Fix root path test and add more test cases 2017-06-15 16:14:12 -04:00
Rossen Stoyanchev 67e482aaf8 Fix ROOT_PATH constant to match recent changes
"/" should be 0 segments, isAbsolute=true, hasTrailingSlash=false
2017-06-15 15:40:32 -04:00
Rossen Stoyanchev 53e8ebe6a6 Fix failing test (after previous commit) 2017-06-15 11:07:39 -04:00
Rossen Stoyanchev 97917aa57d Add PathSegmentContainer subPath extracting method 2017-06-14 17:44:56 -04:00
Rossen Stoyanchev 1018bf771b Separate DefaultRequestPath/DefaultPathSegmentContainer 2017-06-14 17:44:56 -04:00
Rossen Stoyanchev 97a97f9bba RequestPath improvements
Static parse methods on PathSegmentContainer and PathSegment plus:

isEmpty() on PathSegmentContainer and PathSegment
isAbsolute() and hasTrailingSlash() on PathSegmentContainer
char[] alternative for valueDecoded() on PathSegment
2017-06-14 17:44:56 -04:00
Juergen Hoeller 7b5f96c804 HttpComponentsAsyncClientHttpRequestFactory supports plain HttpAsyncClient as well
Issue: SPR-15664
2017-06-14 17:10:44 +02:00
Juergen Hoeller 137fc48cc2 Polishing 2017-06-13 20:59:26 +02:00
Sebastien Deleuze 97909f2258 Support date properties in Content-Disposition HTTP header
Issue: SPR-15555
2017-06-13 15:17:48 +02:00
Sebastien Deleuze e0e6736bc5 Introduce LocaleContextResolver in WebFlux
This commit introduces LocaleContextResolver interface, which is used
at ServerWebExchange level to resolve Locale, TimeZone and other i18n
related informations.

It follows Spring MVC locale resolution patterns with a few differences:
 - Only LocaleContextResolver is supported since LocaleResolver is less
   flexible
 - Support is implemented in the org.springframework.web.server.i18n
   package of spring-web module rather than in spring-webflux in order
   to be able to leverage it at ServerWebExchange level

2 implementations are provided:
 - FixedLocaleContextResolver
 - AcceptHeaderLocaleContextResolver

It can be configured with both functional or annotation-based APIs.

Issue: SPR-15036
2017-06-13 15:10:18 +02:00
Juergen Hoeller a0cea9a86f Polishing 2017-06-13 14:20:33 +02:00
Juergen Hoeller 779deb0fa7 Cleanup of duplicate semicolons
Issue: SPR-15654
2017-06-13 11:38:05 +02:00
Stephane Nicoll 58242f2249 Polish 2017-06-13 10:13:14 +02:00
Stephane Nicoll fc64b8040f Polish "Replace relevant code with lambda"
Closes gh-1454
2017-06-13 09:42:20 +02:00
diguage 4b1478d830 Replace relevant code with lambda
See gh-1454
2017-06-13 08:55:38 +02:00
Brian Clozel 233c15b80e Add PathPatternRegistry for handler mapping matching
Previously `HandlerMapping` implementation were heavily relying on
`String` path patterns, `PathMatcher` implementations and dedicated maps
for matching incoming request URL to an actual request handler.

This commit adds the `PathPatternRegistry` that holds `PathPattern`
instances and the associated request handler — matching results are then
shared as `PathMatchResult` instances. `AbstractUrlHandlerMapping` will
use this registry directly, but other components dealing with request
matching (like `PatternsRequestCondition`) will directly use ordered
`PathPattern` collections since ordering is important there.

This opens the door for faster request matching and simplifies the
design of this part.

Issue: SPR-15608
2017-06-12 18:53:05 +02:00
Brian Clozel 1f0d107d37 Enable trailing slash matching by default
This commit enables trailing slash matching in `PathPatternParser` by
default - this mirrors the default configuration in `PathMatcher`
implementations in MVC.
2017-06-12 16:17:18 +02:00
Juergen Hoeller 3ae84d6dd8 Consistent support for Charset/StandardCharsets in UriUtils etc
Issue: SPR-15613
2017-06-12 15:51:45 +02:00
diguage 2efa06237a Use Map#forEach instead of Map#entrySet#forEach
See gh-1449
2017-06-12 14:37:33 +02:00
Arjen Poutsma 9bf82dc18f Add addAll(MultiValueMap)
This commit introduces a new method for MultiValueMap: addAll, which
adds all values of a given map (cf putAll, which replaces existing
values).
2017-06-12 14:12:12 +02:00
diguage c1d44d9a34 Use the diamond syntax
Closes gh-1450
2017-06-12 09:19:06 +02:00
Rossen Stoyanchev 38a12ed4ba Expose RequestPath in ServerHttpRequest
The new structured getPath() method replaces the existing
getContextPath() + getPathWithinApplication().

Issue: SPR-15648
2017-06-11 21:59:24 -04:00
Rossen Stoyanchev 2d17411ec4 Add RequestPath to http/server/reactive
Issue: SPR-15648
2017-06-11 21:59:24 -04:00
Juergen Hoeller e2e0410570 Method-level javadoc on XmlReaderContext etc 2017-06-11 12:03:05 +02:00
Rossen Stoyanchev b65bfdb979 Remove HttpRequestPathHelper
The use of the undecoded URL path by default and the removal of suffix
pattern matching effectively means HttpRequestPathHelper is no longer
needed.

Issue: SPR-15640, SPR-15639
2017-06-09 16:15:38 -04:00
Rossen Stoyanchev 95196e1aee Use undecoded pathWithinApplication in WebFlux
Introduce pathWithinApplication() in ServerHttpRequest and use it for
request mapping purposes instead of LookupPath.

In turn this means that for request mapping purposes:
1) the path is not decoded
2) suffix pattern matching is not supported

Issue: SPR-15640
2017-06-09 16:15:38 -04:00
Andy Clement ff2af660cf PathPatternParser encodes patterns as it parses them
Before this commit there was no special handling for URL encoding
of the path pattern string coming into the path pattern parser. No
assumptions were made about it being in an encoded form or not.

With this change it is assumed incoming path patterns are not
encoded and as part of parsing the parser builds PathPattern
objects that include encoded elements. For example parsing "/f o"
will create a path pattern of the form "/f%20o". In this form
it can then be used to match against encoded paths.

Handling encoded characters is not trivial and has resulted in
some loss in matching speed but care has been taken to
avoid unnecessary creation of additional heap objects.  When
matching variables the variable values are return in a
decoded form. It is hoped the speed can be recovered, at least
for the common case of non-encoded incoming paths.

Issue: SPR-15640
2017-06-09 13:08:07 -07:00
Sebastien Deleuze 86580b2358 Polishing 2017-06-09 01:49:56 +03:00
Sebastien Deleuze 8579ae66fc Add comprehensive tests of Kotlin extensions
This commit also removes extensions hidden by Java API (varargs).
2017-06-09 01:01:16 +03:00
Juergen Hoeller fd53d2a51a Consistent use of @Nullable in spring-test
This commit also removes nullability from two common spots: ResolvableType.getType() and TargetSource.getTarget(), both of which are never effectively null with any regular implementation. For such scenarios, a non-null empty type/target is the cleaner contract.

Issue: SPR-15540
2017-06-08 22:52:59 +02:00
Juergen Hoeller 7eaedf2916 Debug-level log entry for any Jackson exception during canConvert
Issue: SPR-15582
2017-06-07 18:33:19 +02:00
Juergen Hoeller f813712f5b Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments.

Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit.

Issue: SPR-15540
2017-06-07 14:19:15 +02:00
Andy Clement 77576ed6fe Fix PathPattern comparator result for wildcard suffix usage
Without this change the comparator thinks "/{foo}"
is more specific than "/{foo}.*". The minimal fix here
to address it is to copy what the AntPathMatcher
comparator does which is to consider '.*' as *not*
a usage of a wildcard. See PatternInfo#initCounters()
for the AntPathMatcher handling of this.

This change ensures the PathPattern comparator now produces
the expected result but suffix usage in general needs more
thought at some point.

Issue: SPR-15597
2017-06-02 15:40:16 -07:00
Rossen Stoyanchev 4244df740b Consolidate matrix vars parsing in HttpRequestPathHelper
Restore matrix variable parsing code not resorting to the use of
WebUtils which brings Servlet API dependencies with it.

Instead the parsing logic is now exposed through HttpRequestPathHelper
which already contained the decoding logic and also the knowledge of
whether to decode the parsed variables or not.

Issue: SPR-15397
2017-06-02 15:52:44 -04:00
Rossen Stoyanchev d2685dfe67 Add static factory/accessor methods to LookupPath
Issue: SPR-15397
2017-06-02 15:15:42 -04:00
Rossen Stoyanchev a7020e419a Polish use of LookupPath 2017-06-02 14:46:34 -04:00
Brian Clozel 74fb2645fd Fix LookupPath parsing
Issue: SPR-15397
2017-06-02 09:26:35 +02:00
Rossen Stoyanchev 4d52590964 Improve docs on forwarded headers
Issue: SPR-15612
2017-06-01 22:36:12 -04:00
Rossen Stoyanchev 895fa2ea7b Add removeOnly mode to ForwardedHeaderFilter
Issue: SPR-15610
2017-06-01 15:39:19 -04:00
Brian Clozel cf1bc81199 Introduce LookupPath in WebFlux request routing
This commit adds the `LookupPath` class that contains the full
request path relative to the web context; the application can
get from it various information, including the file extension
and path parameters (if any).

Since that operation is done multiple times for each request, this
object is stored as an attribute at the `ServerWebExchange` level.

Issue: SPR-15397
2017-06-01 18:31:04 +02:00
Brian Clozel 0557404715 Throw exception for illegal PathMatch configurations
With the new `ParsingPathMatcher` implementation, new patterns are now
allowed, such as `"/foo/{*bar}". The `"{*bar}"` segment will capture
everything until the end of the given path. Adding other elements after
that segment is illegal and will throw exceptions.

One can configure on a `PathMatchConfigurer` various options like
`useTrailingSlashMatch` and `useSuffixPatternMatch`; those options, when
enabled, will try to append suffixes like `".*"` and `"/"` to existing
path patterns. In case of a "capture the rest" pattern segment, those
options won't be honored.

This is why this commit ensures that an exception is thrown at the start
of the application if an illegal configuration is applied to the
`PathMatchConfigurer`.

Issue: SPR-15303, SPR-15558
2017-06-01 18:30:18 +02:00
Rossen Stoyanchev b93579a43e Polish 2017-06-01 09:28:55 -04:00
Violeta Georgieva e8d2c6c74b AbstractListenerWriteProcessor/AbstractListenerWriteFlushProcessor error handling
When an exception happens while writing/flushing, the exception handling
for Servlet 3.1 based implementation will happen when
WriteListener#onError and AsyncListener#onError events are received
2017-06-01 09:19:45 -04:00
Violeta Georgieva 23a052c160 Clear the buffer provided by Undertow before reading the request
When reading more that once for a given request, the position/limit of
the buffer provided by Undertow should be reset in order to use the
full capacity of the buffer.
2017-06-01 15:14:25 +03:00
Arjen Poutsma 7894efdd1e Allow for null values in ExtractingResponseErrorHandler.hasError
This commit fixes the implementation of
ExtractingResponseErrorHandler.hasError to allow for null values,
indicating an override of the behavior inherited from
DefaultResponseErrorHandler.

Issue: SPR-15544
2017-06-01 11:44:08 +02:00
Rossen Stoyanchev e81651b657 Ignore empty Accept-Language header value
Issue: SPR-15603
2017-05-31 21:10:08 -04:00
Sebastien Deleuze 1f28825f9d Add more @Nullable parameters based on null usage
Issue: SPR-15540
2017-05-31 21:42:23 +02:00
Sebastien Deleuze c3e6afb879 Improve null-safety to fix some Spring Boot warnings
Issue: SPR-15540
2017-05-31 17:14:49 +02:00
Sebastien Deleuze b47d713e14 Add missing @Nullable annotations on parameters
Issue: SPR-15540
2017-05-31 16:56:08 +02:00
Rossen Stoyanchev 5dcfd84d3b MockServerHttpRequest and Response set cookie headers
Issue: SPR-15522
2017-05-30 11:00:15 -04:00
Rossen Stoyanchev 67bcef22e4 Polish MockServerHttpRequest|Response 2017-05-30 11:00:15 -04:00
Arjen Poutsma 4b0dedc45e Add ExtractingResponseErrorHandler
This commit introduces ExtractingResponseErrorHandler: an alternative
ResponseErrorHandler that uses `HttpMessageConverter`s to convert HTTP
error responses to `RestClientException`.

Issue: SPR-15544
2017-05-30 13:17:25 +02:00
Rossen Stoyanchev 1383ad5f91 Reasonable defaults for MultipartHttpMessageWriter
MultipartHttpMessageWriter is now configured to handle JSON and XML
out of the box.
2017-05-27 20:41:07 -04:00
Rossen Stoyanchev 03b344b579 Refactor DefaultCodecs implementation
Simplify the internals of the DefaultCodecs implementation favoring
explicit fields per override vs a generic list of readers and writers
for overrides.
2017-05-27 20:41:07 -04:00
Rossen Stoyanchev 1328c8f46e Simplify CodecConfigurer related type names
Essentially drop "Configurer" suffix from nested interfaces.
2017-05-27 20:41:07 -04:00
Sebastien Deleuze 87598f48e4 Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi
annotations that leverage JSR 305 (dormant but available via
Findbugs jsr305 dependency and already used by libraries
like OkHttp) meta-annotations to specify explicitly
null-safety of Spring Framework parameters and return values.

In order to avoid adding too much annotations, the
default is set at package level with @NonNullApi and
@Nullable annotations are added when needed at parameter or
return value level. These annotations are intended to be used
on Spring Framework itself but also by other Spring projects.

@Nullable annotations have been introduced based on Javadoc
and search of patterns like "return null;". It is expected that
nullability of Spring Framework API will be polished with
complementary commits.

In practice, this will make the whole Spring Framework API
null-safe for Kotlin projects (when KT-10942 will be fixed)
since Kotlin will be able to leverage these annotations to
know if a parameter or a return value is nullable or not. But
this is also useful for Java developers as well since IntelliJ
IDEA, for example, also understands these annotations to
generate warnings when unsafe nullable usages are detected.

Issue: SPR-15540
2017-05-27 08:57:01 +02:00
Rossen Stoyanchev 2d37c966b2 Support for decoding @RequestPart content
Issue: SPR-15515
2017-05-26 18:03:01 -04:00
Rossen Stoyanchev be0b671191 Upgrade nio-multipart-parser to 1.1.0
Issue: SPR-15515
2017-05-26 09:19:10 -04:00
Juergen Hoeller e7b41bc30a Use Apache Johnzon 1.1 for JSON-B integration tests
Issue: SPR-15590
2017-05-25 23:37:14 +02:00
Rossen Stoyanchev 805fcc6a05 ResponseErrorHandler provides access to URI and method
Issue: SPR-15511
2017-05-24 15:34:40 -04:00
Arjen Poutsma 630fc194f0 Add HttpRequest.getMethodValue
This commit introduces a new method in HttpRequest:
`String getMethodValue`, which returns the HTTP method as a String.
Furthermore, HttpRequest.getMethod() has been given a default
implementation using this String value in combination with
`HttpMethod.resolve`.

Issue: SPR-15545
2017-05-24 16:36:58 +02:00
Juergen Hoeller 0183576215 Polishing 2017-05-23 22:05:22 +02:00
Juergen Hoeller db69a082d9 Avoid java.util.Optional signatures for simple field access
Issue: SPR-15576
2017-05-23 22:05:15 +02:00
Juergen Hoeller ce5e2b94c4 ProtobufJsonFormatHttpMessageConverter for configurable JSON processing
Issue: SPR-15550
2017-05-23 21:59:23 +02:00
Juergen Hoeller 113f0fb13f Javadoc suggests Jackson 2.9
Issue: SPR-14925
2017-05-23 21:59:16 +02:00
Andrey Kaipov 9c226aa742 Minor typo fix: form -> from
Closes gh-1411
2017-05-20 14:49:54 +02:00
Rossen Stoyanchev 11075f12bc Fix URI parsing in Reactor Netty request
Issue: SPR-15560
2017-05-19 21:47:27 -04:00
Juergen Hoeller 67881a5726 Polish PathPattern parser (including package change to web.util.pattern)
Issue: SPR-15531
2017-05-17 17:40:25 +02:00
Juergen Hoeller eaac348c05 Close InputStreams in writeResourceRegionCollection (analogous to writeResourceRegion)
Issue: SPR-15559
2017-05-17 14:34:50 +02:00
Rossen Stoyanchev 5ac7955de9 More qualified "request-id" header in WebTestClient
Issue: SPR-15501
2017-05-15 15:52:50 -04:00
Juergen Hoeller f985f71daf Polishing 2017-05-12 12:50:17 +02:00
Sebastien Deleuze 285fa1cc2c Fix typos in Kotlin extensions documentation 2017-05-10 17:22:27 +02:00
Arjen Poutsma b649041976 Add ServerHttpResponse.addCookie method
This commit adds a `addCookie(ResponseCookie)` method to the reactive
`ServerHttpResponse` interface.

Issue: SPR-15523
2017-05-09 10:18:39 +02:00
Rossen Stoyanchev add1305252 Re-add vararg options in WebHttpHandlerBuilder
WebHttpHandlerBuilder is low level not expected to appear frequently
but they might be repeated more in tests (e.g. of WebFilter's).

Issuse: SPR-15499
2017-05-08 15:50:27 -04:00
Rossen Stoyanchev 459457e1aa WebFilterChain delegation nested in Mono.defer()
Issue: SPR-15520
2017-05-08 15:36:31 -04:00
Rossen Stoyanchev 47d6e4a332 Immutable DefaultWebFilterChain
Issue: SPR-15517
2017-05-08 15:04:38 -04:00
Juergen Hoeller 5497416c2d Polishing 2017-05-08 09:10:36 +02:00
Juergen Hoeller f25c6ba9bc Polishing 2017-05-07 22:59:25 +02:00
Juergen Hoeller 25aef4d3cc ResponseStatusException reason is optional (with lazily constructed message)
Issue: SPR-15524
2017-05-06 12:53:03 +02:00
Juergen Hoeller 39f8bd663e Polishing 2017-05-05 23:19:08 +02:00
Juergen Hoeller 4fdd85324d Aligned exception handling in Jackson and JAXB codecs
Issue: SPR-15516
2017-05-05 23:19:01 +02:00
Rossen Stoyanchev 4d962a1793 Remove HttpStatus from HttpMessageConversionException
HttpMessageConverter's are client and server and arguably shouldn't
contain a server-side concept such a response status.

The status field is recent, it was added to differentiate 400 vs 500
errors with Jackson 2.9+ but there is no need for it since the same
distinction is reflected in raising an HttpMessageNotReadableException
vs a general HttpMessageConversionException.

Issue: SPR-15516
2017-05-05 14:44:08 -04:00
Rossen Stoyanchev 83e0e1604a Refine encoding/decoding exception handling
Starting with removing a package cycle on the use of
ResponseStatusException in the codec package, this commit generally
refines codec exception handling.

The new [Encoding|Decoding]Exception mirror the existing
HttpMessageNot[Readable|Writable]Exception and are used similarly
especially to differentiate betwen 400 and 500 errors when parsing
server request body content.

The commit also aligns some of the exception handling of JSON and XML
on the WebFlux side with that on the Spring MVC side.

Issue: SPR-15516
2017-05-05 14:29:43 -04:00
Rossen Stoyanchev d7e54cea84 Test commit 2017-05-05 09:41:54 -04:00
Rossen Stoyanchev 8231812a3c Jackson Encoder/Decoder accept custom MimeType's
Issue: SPR-15474
2017-05-04 18:05:55 -04:00
Rossen Stoyanchev afa1c93585 Fix error in mock server test code 2017-05-04 17:24:46 -04:00
Juergen Hoeller 652266bcc2 Polishing 2017-05-04 22:27:36 +02:00
Rossen Stoyanchev 75117f42b8 Use the configured charset for part headers
This comment extends the use of the charset property in
FormHttpMessageConverter to also include multipart headers with a
default of UTF-8.

We now also set the charset parameter of the "Content-Type" header to
indicate to the server side how to decode correctly.

Issue: SPR-15205
2017-05-04 15:59:54 -04:00
Rossen Stoyanchev bda2723933 Correct charset determination in Synchronoss reader 2017-05-04 13:30:56 -04:00
Rossen Stoyanchev bb744574e5 Remove optional javax.mail dependency from WebFlux
The MultipartHttpMessageWriter now directly encodes part header values
defaulting to UTF-8 and also specifies the charset in the
Content-Type header for the entire request.

This should work with something commonly used like Apache Commons
FileUpload which checks request.getCharacterEncoding() and uses it
for reading headers.
2017-05-04 13:12:44 -04:00
Rossen Stoyanchev a56f735edd Polish 2017-05-04 12:25:19 -04:00
Rossen Stoyanchev ac1db169a4 Drop "get" prefix from Part accessor methods 2017-05-04 10:13:16 -04:00
Rossen Stoyanchev 6f3051c677 Support for @RequestPart with reactive type wrapper
Issue: SPR-14546
2017-05-03 23:03:47 -04:00
Rossen Stoyanchev fc7bededd0 Support data binding for multipart requests in WebFlux
Issue: SPR-14546
2017-05-03 22:36:04 -04:00
Rossen Stoyanchev b5089ac092 Support @RequestBody Flux<Part> in WebFlux
This commit turns the Synchronoss NIO Multipart HttpMessageReader into
a reader of Flux<Part> and creates a separate reader that aggregates
the parts into a MultiValueMap<String, Part>.

Issue: SPR-14546
2017-05-03 18:46:41 -04:00
Arjen Poutsma cf7dfc7b17 Properly close channel in SynchronossPart
This commit properly closes the opened channels in the SynchronossPart,
and also makes sure that the entire contents is copied, not just the
first batch.
2017-05-03 14:51:22 +02:00
Juergen Hoeller 9d8e9cf243 Common root cause introspection algorithm in NestedExceptionUtils
Issue: SPR-15510
2017-05-03 11:31:28 +02:00
Rossen Stoyanchev 056284b407 Polish 2017-05-02 16:58:19 -04:00
Gregory Vandenbroucke ec55e429f0 Full "Forwarded" header support including port number
Issue: SPR-15504
2017-05-02 16:47:32 -04:00
Rossen Stoyanchev 2ccf78743a Move 500 error handling to HttpWebHandlerAdapter
Issue: SPR-15506
2017-05-02 16:44:37 -04:00
Rossen Stoyanchev 1881727b37 Remove ServerWebExchange#getRequestParams
Issue: SPR-15508
2017-05-02 16:09:55 -04:00
Juergen Hoeller 7f19e57d9d Polishing 2017-05-02 21:38:09 +02:00
Juergen Hoeller b709c77329 Multipart file tests reliably pass on Windows as well
Issue: SPR-14546
2017-05-02 21:26:31 +02:00
Stephane Nicoll 3b8b3502a8 Update copyright header 2017-05-02 16:39:28 +02:00
Phillip Webb 90477b40a4 Defer Charset.availableCharsets() call
Change the `StringHttpMessageConverter` to defer calling
Charset.availableCharsets() until absolutely necessary to help improve
startup times.

Issue: SPR-15502
2017-05-02 16:39:04 +02:00
Rossen Stoyanchev 2390748fd7 WebFlux multpart support polish + minor refactoring 2017-05-01 18:00:08 -04:00
Sebastien Deleuze 4bfd04b3c5 Add multipart support to ServerWebExchange
Issue: SPR-14546
2017-04-28 16:42:23 +02:00
Sebastien Deleuze 8e272bc5b0 Expose ServerCodecConfigurer as a bean
With this commit, ServerCodecConfigurer is now exposed as a bean in
order to be provided to DefaultServerWebExchange via
WebHttpHandlerBuilder and HttpWebHandlerAdapter. This allows
DefaultServerWebExchange to get configured codecs for reading form or
multipart requests.

Issue: SPR-14546
2017-04-28 16:42:23 +02:00
Sebastien Deleuze a712c19661 Add multipart support to WebFlux functional API
Issue: SPR-14546
2017-04-28 16:42:23 +02:00
Sebastien Deleuze 852dc84d38 Add MultipartHttpMessageWriter
This commit adds a reactive HttpMessageWriter that allows
to write multipart HTML forms with multipart/form-data
media type.

Issue: SPR-14546
2017-04-28 16:42:23 +02:00
Sebastien Deleuze 23e4dd6d3d Add reading reactive multipart request support
This commit introduces reactive multipart support by adding a new
MultipartHttpMessageReader interface (with default methods) and a
SynchronossMultipartHttpMessageReader implementation based on
the Synchronoss NIO Multipart implementation
(https://github.com/synchronoss/nio-multipart).

Issue: SPR-14546
2017-04-28 16:42:23 +02:00
Juergen Hoeller 1ea54eb2c6 GenericFilterBean lazily initializes its default environment
Alignment with HttpServletBean; consistent use of EnvironmentCapable.

Issue: SPR-15469
2017-04-27 21:38:30 +02:00
Juergen Hoeller c668d9a473 Polishing 2017-04-26 18:20:19 +02:00
Rossen Stoyanchev 4f3db9b822 Disable Servlet async request timeout in WebFlux
Issue: SPR-15463
2017-04-25 16:28:25 -04:00
Rossen Stoyanchev 6e71828a35 Add space before cookie attributes
According to RFC-6265 that there should be a space between the ; and
the attribute name, i.e. the header should be something like
name=value; Domain=localhost; HttpOnly rather than
name=value;Domain=localhost;HttpOnly

Issue: SPR-15225
2017-04-25 16:07:25 -04:00
Violeta Georgieva 4d058ceef4 Resume Undertow writes only when data is available 2017-04-24 11:17:37 +02:00
Rossen Stoyanchev cc102c2fcd Properly handle Flux<?> and Flux<Object> in WebFlux
Issue: SPR-15464
2017-04-20 09:19:38 -04:00
Arjen Poutsma 03861df0ba Polishing 2017-04-20 11:02:02 +02:00
Andy Clement cd86558811 Support optional trailing separator on path pattern matching
This commit adds the ability for path patterns to automatically
match a trailing separator (so there is no need to add two
variants of a pattern, one with and one without). This behaviour
is currently turned off but a simple tweak in PathPatternParser
can make it the default. If made default other parts of Spring
may need altering (simplifying hopefully) to cope with this.

Issue: SPR-15260
2017-04-19 11:59:21 -07:00
Andy Clement 316a680577 Modify getPathRemaining to return remaining path and bound variables
Without this change it was necessary to call getPathRemaining and
then chop up the path and make a call to matchAndExtract to get the
bound variables for the path part that matched. With this change
this is all done in the call to getPathRemaining which returns
an object holding the remaining path and the bound variables.

Issue: SPR-15419
2017-04-18 16:17:44 -07:00
Brian Clozel 88f8df4dce Update Mono.then(Supplier) deprecated calls
Reactor Core has now deprecated the `Mono.then(Supplier)`.
This is now replaced with `Mono.then(Mono.defer(Supplier))`.
2017-04-18 21:11:19 +02:00
Rossen Stoyanchev 3efb76c852 Jackson encoder skips String.class
Jackson2Encoder explicitly disables String from the supported types
consistent with the same change on the decoder side:

0662dbf044

Issue: SPR-15443
2017-04-14 17:21:26 -04:00
Brian Clozel a8d785b87f Move RxNetty support to test scope
The RxNetty runtime support is not meant to be officially supported and
should be restricted to testing purposes only.

Issue: SPR-15444
2017-04-14 19:18:42 +02:00
Sebastien Deleuze 005e85b0f5 Update to latest Reactor 3.1 API changes
Issue: SPR-15318
2017-04-14 13:18:20 +02:00
Juergen Hoeller 0b118322b0 Polishing 2017-04-13 16:17:05 +02:00
Sebastien Deleuze e3fae2716e Rename Mono#otherwise[Empty] to switch[onError/IfEmpty]
Issue: SPR-15318
2017-04-13 15:36:34 +02:00
Arjen Poutsma 908d16904f Refactor CodecConfigurer
This commit refactors the CodecConfigurer, with it's subtypes
ServerCodecConfigurer and ClientCodecConfigurerTests, into interfaces
instead of classes.
2017-04-13 11:02:17 +02:00
Rossen Stoyanchev fce8ed62ce Update @ControllerAdvice Javadoc
Issue: SPR-15432
2017-04-12 17:51:36 -04:00
Juergen Hoeller 9e55e8f8a6 Polishing 2017-04-12 18:07:14 +02:00
Sebastien Deleuze 4d9144132e Upgrade to Reactor Core 3.1
Issue: SPR-15318
2017-04-11 18:13:04 +02:00
Rossen Stoyanchev 043c7070e3 Polish default content type change
Issue: SPR-15367
2017-04-11 11:54:40 -04:00
Ryan O'Meara 4a890226ea Support for multiple default content types
Enhance FixedContentNegotiationStrategy and places where it is exposed
to also accept a list of media types.

Issue: SPR-15367
2017-04-11 11:54:40 -04:00
Juergen Hoeller 7f162a033b AbstractGenericHttpMessageConverter calls two-arg variants of canRead/canWrite again
Issue: SPR-15434
2017-04-11 15:37:56 +02:00
Sebastien Deleuze 9a501fac46 Fix failing tests
Issue: SPR-14925
2017-04-11 14:00:31 +02:00
Rossen Stoyanchev e33f603f68 Revert (recently added) cookie set header flags
Issue: SPR-15225
2017-04-11 07:19:07 -04:00
Rossen Stoyanchev 5d92a85fcb Mock Servlet request/response support Accept-Language
Issue: SPR-15209
2017-04-11 07:19:07 -04:00
Rossen Stoyanchev 3393c10d79 Refactor HttpHeaders "Accept-Language" with Locale 2017-04-11 07:19:07 -04:00
Sebastien Deleuze 23e35c0e1a Handle Jackson InvalidDefinitionException with 5xx status in WebFlux
Issue: SPR-14925
2017-04-11 12:39:09 +02:00
Arjen Poutsma 870e1897b6 Javadoc 2017-04-11 11:01:27 +02:00
Arjen Poutsma 82e864b217 Polishing
- Renamed `defaultCodec` to `defaultCodecs`, and `customCodec` to
`customCodecs`
- Added `@Override` annotations where necessary
- Fixed non-parameterized usage for parameterized types.
2017-04-11 11:01:27 +02:00
Rossen Stoyanchev e5fc40a9de MockHttpSevlet[Request|Response] set cookie headers
Issue: SPR-15225
2017-04-10 17:37:11 -04:00
Rob Winch e92e65f8c3 Fix ForwardedHeaderFilter preserves semicolon content
Previously a requestURI that contained ';' would have the value incorrectly stripped out when using
ForwardedHeaderFilter.

This commit ensures that the ';' is preserved when using ForwardedHeaderFilter.

Issue: SPR-15428
2017-04-10 09:50:44 -05:00
Rob Winch 96bfe7d197 Polish
Group all contextPath tests together
2017-04-10 09:50:44 -05:00
Rob Winch 1f289b7580 Add test to ensure ForwardedHeaderFilter contextPath preserves encoding
Add a test to verify that the ForwardedHeaderFilter contextPath override preserves URL encoding
as it should.

Issue SPR-15422
2017-04-10 09:50:43 -05:00
Rob Winch 84db06ec0b ForwardedHeaderFilter requestURI preserve encoding
Previously ForwardedHeaderFilter would override the requestURI with a URL decoded value. This would cause
problems when using a URL encoded requestURI since downstream Filters would not see the URL encoded
value as they should.

This commit resolves this issue by ensuring that the requestURI is properly encoded.

Issues SPR-15422
2017-04-10 09:50:43 -05:00
Sebastien Deleuze d098a4b96b Make CodecException handling consistent
This commit makes CodecException handling consistent between functional
and annotation-based APIs. It now returns by default 4xx status code
for decoding error and 5xx for encoding error + print the error reason
in logs without the full stack trace in both variants.

Issue: SPR-15355
2017-04-10 16:07:56 +02:00
Juergen Hoeller 15b5dd9f12 Polishing 2017-04-10 15:36:45 +02:00
Juergen Hoeller cf306037b5 Support for JSON Binding API (JSON-B)
Issue: SPR-14923
2017-04-10 15:36:38 +02:00
Juergen Hoeller e5fdd4cd1d Extracted AbstractJsonHttpMessageConverter from GsonHttpMessageConverter
Generic type resolution algorithm in GenericTypeResolver shared between Jackson and Gson.

Issue: SPR-15381
2017-04-10 15:36:29 +02:00
Juergen Hoeller 5986f881d0 HandlerMethod evaluates ResponseStatus annotation for early caching
Issue: SPR-15227
2017-04-08 15:56:05 +02:00
Violeta Georgieva ff03b4a4ad Init subscriber before switching the states
Issue: SPR-15418
2017-04-07 18:14:30 -04:00
Rossen Stoyanchev 3780d040ee Polish and minor fixes in ViewResolutionResultHandler 2017-04-07 17:15:07 -04:00
Rossen Stoyanchev e4c62cc029 Controller API for view rendering
Issue: SPR-15211
2017-04-07 17:15:07 -04:00
Bryan Kelly 9a9166622e Fix ForwardedHeaderFilter getRequestURL()
Previously ForwardedHeaderFilter would return the same StringBuffer for every invocation. This
meant that users that modified the StringBuffer changed the state of the HttpServletRequest.

This commit ensures that a new StringBuffer is always returned for ForwardedHeaderFilter.

Issue: SPR-15423
2017-04-07 15:51:11 -05:00
Andy Clement 584b290dff Introduce method to allow a pattern to partially consume a path
With this change there is a new getPathRemaining() method on
PathPattern objects. It is called with a path and returns
the path remaining once the path pattern in question has
matched as much as it can of that path. For example if the
pattern is /fo* and the path is /foo/bar then getPathRemaining
will return /bar. This allows for a set of pathpatterns
to work together in sequence to match a complete entire path.

Issue: SPR-15336
2017-04-06 12:21:32 -07:00
Juergen Hoeller 67ea4b3a05 package-info for repackaged libraries (and other polishing) 2017-04-06 14:10:46 +02:00
Arjen Poutsma aa3573b2bc Polishing 2017-04-06 11:37:21 +02:00
Rossen Stoyanchev e83fdaa2dd Revert recent change causing issue in Boot on WildFly 2017-04-05 12:41:41 -04:00
Sebastien Deleuze ed8565894a Return 5xx HTTP status for invalid target types with Jackson
InvalidDefinitionException has been introduced in Jackson 2.9 to be
able to differentiate invalid data sent from the client (should still
generate a 4xx HTTP status code) from server side errors like beans with
no default constructor (should generate a 5xx HTTP status code).

Issue: SPR-14925
2017-04-05 11:31:26 +02:00
Rossen Stoyanchev f293c4d84b Doc use of reactive types in Spring MVC controllers
Issue: SPR-15365
2017-04-04 17:32:24 -04:00
Rossen Stoyanchev f716c8e9bc Consistently check if AsyncContext already completed
Related to SPR-15412
2017-04-04 16:30:54 -04:00
Rossen Stoyanchev c0f2017262 Polish 2017-04-04 15:33:47 -04:00
Violeta Georgieva ece4815459 Ensure ISE will not be thrown when the client disconnects
- ServletServerHttpResponse.ResponseAsyncListener#onError/onTimeout
must complete the async operation
- ServletHttpHandlerAdapter.HandlerResultSubscriber#onComplete must
check that the async operation is not completed

Issue: SPR-15412
2017-04-04 14:45:00 -04:00
Juergen Hoeller e9627a10c7 Deprecate ObjectUtils.hashCode for primitives in favor of JDK 8's hashCode methods
Issue: SPR-15395
2017-04-04 17:16:50 +02:00
Rossen Stoyanchev ae1ed16cb8 Async return values refactoring in Spring MVC
Revise Javadoc on AsyncHandlerMethodReturnValueHandler to clarify its
main purpose is to prioritze custom async return value handlers ahead
of built-in ones. Also replace the interface from built-in handlers
which are prioritized already.

Remove DeferredResultAdapter and ResponseBodyEmitterAdapter --
introduced in 4.3 for custom async return value handling, since for
5.0 we will add built-in support for reactive types and the value of
these contracts becomes very marginal.

Issue: SPR-15365
2017-04-03 09:01:49 -04:00
Sebastien Deleuze dd5a73b2e1 Remove deprecated usage of Reactor Loopback interface 2017-03-30 14:36:23 +02:00
Sebastien Deleuze 9f321e8d56 Suppress warnings in tests 2017-03-30 14:28:10 +02:00
Sebastien Deleuze e2fd398bad Specify explicitly Kotlin extensions return type
The main purpose is to specify nullability.
2017-03-30 14:25:13 +02:00
Rossen Stoyanchev d1db249584 Fix regression in client codecs
Restore the correct client-side default for whether StringDecoder
should split on new lines. It is true forthe server and false for the
client by default.

The regression was introduced in the recent refactoring:
f8a21ab11b (diff-0175d58138b2e8b2bec087ffe0495340)
2017-03-29 16:10:53 -04:00
Sebastien Deleuze cbd98d5247 Switch back to Reactor BOM Aluminium-BUILD-SNAPSHOT 2017-03-29 16:41:54 +02:00
Arjen Poutsma 81430caa43 Deprecated AsyncRestTemplate and related types
This commit deprecates `AsyncRestTemplate` and related types
(`AsyncClientHttpRequestFactory` etc.) in favor of the Spring 5.0
`WebClient`.

Issue: SPR-15294
2017-03-29 15:54:06 +02:00
Violeta Georgieva 2556178422 Ensure NPE will not be thrown when cancelling a subscription
Issue: SPR-15393
2017-03-29 15:10:36 +02:00
Rossen Stoyanchev 525f30ad5e Remove dated references on URI template RFC 2017-03-27 15:49:20 -04:00
Rossen Stoyanchev 0479e3eefc Fix typo 2017-03-27 15:16:59 -04:00
Rossen Stoyanchev 9e96cfa7cd Polish 2017-03-27 15:15:45 -04:00
Rossen Stoyanchev f8a21ab11b Add ClientCodecConfigurer
Issue: SPR-15247
2017-03-27 14:57:55 -04:00
Rossen Stoyanchev dc3851df00 Extract AbstractCodecConfigurer base class
Issue: SPR-15247
2017-03-27 14:57:49 -04:00
Sebastien Deleuze 3598addc0e Use FormHttpMessageReader by default in ServerCodecConfigurer 2017-03-26 03:21:05 +02:00
Rossen Stoyanchev ec5b5c8578 Rename Http[Encoder|Decoder] to HttpMessage[Encoder|Decoder] 2017-03-24 17:48:40 -04:00
Rossen Stoyanchev 5414cd0cf8 Collape ServerHttpMessage[Reader|Writer]
This commit folds ServerHttpMessage[Reader|Writer] into its parent
HttpMessage[Reader|Writer] with the server methods pre-implemented
by default to be simple pass-through delegates.
2017-03-24 17:48:40 -04:00
Rossen Stoyanchev 4a7218f54f Introduce ServerCodecConfigurer
Issue: SPR-15247
2017-03-24 17:47:44 -04:00
Juergen Hoeller 65ba865d70 Support for populating model attributes through data class constructors
Includes a new overloaded ModelAndView constructor with an HttpStatus argument, as well as a HandlerMethodArgumentResolverSupport refactoring (revised checkParameterType signature, actually implementing the HandlerMethodArgumentResolver interface).

Issue: SPR-15199
2017-03-24 12:15:45 +01:00
Juergen Hoeller 2236262fc6 Up-to-date guidelines for serialization-based endpoints
Issue: SPR-15317
2017-03-24 11:09:57 +01:00
Juergen Hoeller 15bff8f911 HeaderValueHolder.toString() exposes underlying list of header values
Issue: SPR-15375
2017-03-24 11:07:01 +01:00
Juergen Hoeller 5ea4abdb85 Revised supportedMethods null handling in HttpRequestMethodNotSupportedException
Issue: SPR-15377
2017-03-24 11:06:47 +01:00
Juergen Hoeller b73153cd7c StandardMultipartFile.transferTo falls back to manual copy
Issue: SPR-15257
2017-03-24 11:06:39 +01:00
Rossen Stoyanchev 0662dbf044 String decoding for text only vs any MIME type
Follow-up to:
3d68c496f1

StringDecoder can be created in text-only vs "*/*" mode which in turn
allows a more intuitive order of client side decoders, e.g. SSE does
not have to be ahead of StringDecoder.

The commit also explicitly disables String from the supported types in
Jackson2Decoder leaving it to the StringDecoder in "*/*" mode which
comes after. This does not change the current arrangement since the
the StringDecoder ahead having "*/*" picks up JSON content just the
same.

From a broader perspective this change allows any decoder to deal with
String if it wants to after examining the content type be it the SSE
or another, custom decoder. For Jackson there is very little value in
decoding to String which works only if the output contains a single
JSON string but will fail to parse anything else (JSON object/array)
while StringDecoder in "*/*" mode will not fail.

Issue: SPR-15374
2017-03-23 16:53:06 -04:00
Arjen Poutsma a287e67992 Introduce 'useRegisteredExtensionsOnly' property in classes using MediaTypeFactory
This commit introduces a `useRegisteredExtensionsOnly` property that
indicates whether classes that use the `MediaTypeFactory` for supplying
default media types can do so.

 - In classes that were introduced in Spring 5.0, the
 `useRegisteredExtensionsOnly` property takes the place of the
 `useJaf` property that was removed in 0aaa652
 - In classes that existed before Spring 5.0, the
 `useRegisteredExtensionsOnly` property is added in addition to the
 deprecated `useJaf`, the latter delegating to the former, but with
 flipped behavior.

Issue: SPR-14908
2017-03-23 17:16:46 +01:00
Arjen Poutsma e2aa880301 Return null from MockServletContext.getMimeType for unknown type
ServletContext.getMimeType() returns `null` for unknown mime types; not
`application/octet-stream`.

Issue: SPR-14908
2017-03-23 12:45:48 +01:00
Arjen Poutsma fd1db57e05 Change MediaTypeFactory to return Optional
This commit changes the `MediaTypeFactory` to return
`Optional<MediaType>` (instead of a plain `MediaType`) for the
`getMediaType` methods.

Issue: SPR-14908
2017-03-23 10:14:43 +01:00
Rossen Stoyanchev 3d68c496f1 String encoding for any MIME type
CharSequenceEncoder now supports all MIME types, however since encoding
Flux<String> can overlap with other encoders (e.g. SSE) there are now
two ways to create a CharSequenceEncoder -- with support for text/plain
only or with support for any MIME type.

In WebFlux configuration we insert one CharSequenceEncoder for
text/plain (as we have so far) and a second instance with support for
any MIME type at the very end.

Issue: SPR-15374
2017-03-22 18:01:32 -04:00
Rossen Stoyanchev 2896c5d2ab Revise "streaming" MediaType support
Push the knowledge of what media types represent "streaming" down to
the Encoder level where knowledge is required (e.g. to encode a
JSON array vs a stream of JSON elements).
2017-03-22 18:01:32 -04:00
Arjen Poutsma 290e9bea14 Change MethodNotAllowedException to use HttpMethod
Changed the MethodNotAllowedException to use HttpMethod, instead of
Strings.
2017-03-22 16:38:41 +01:00
Sebastien Deleuze 4db2daae5c Add class level @JsonView tests
Issue: SPR-14925
2017-03-22 13:28:04 +01:00
Rossen Stoyanchev a999f40daa Polish + minor refactoring of SSE reader and writer
Instead of accepting List<Encoder|Decoder> and then look for the first
to support JSON, always expect a single JSON [Encoder|Decoder] and use
that unconditionally.

When writing use the nested ResolvableType instead of the Class of the
actual value which should better support generics.

Remove the SSE hint and pass "text/event-stream" as the media type
instead to serve as a hint. We are expecting a JSON encoder and using
it unconditionally in any case so this should be good enough.
2017-03-21 17:32:14 -04:00
Rossen Stoyanchev d0e0b6c8c9 Minor Jackson encoder/decoder refactoring
Consolidate JsonView hint extraction in shared base class.

Rename base class from AbstractJackson2Codec to Jackson2CodecSupport
since the class mainly provides support methods.
2017-03-21 14:51:46 -04:00
Rossen Stoyanchev 35805995c2 Polish EncoderHttpMessageWriter 2017-03-21 14:51:46 -04:00
Juergen Hoeller e892e02f41 Polishing 2017-03-21 17:44:47 +01:00
Rossen Stoyanchev 124cdb5c58 Polish Javadoc of [Server]HttpMessage[Reader|Writer] 2017-03-21 10:57:21 -04:00
Rossen Stoyanchev c8671041f1 EncoderHttpMessageWriter supports streaming MediaTypes
Support for flushing in EncoderHttpMessageWriter is now driven from a
configurable list of "streaming" media types with the list including
"application/stream+json" by default.

As a result Jackson2ServerHttpMessageWriter is no longer needed.
2017-03-21 10:15:56 -04:00
Rossen Stoyanchev f65544c192 Introduce ServerHttp[Encoder|Decoder]
ServerHttpEncoder and ServerHttpDecoder are HTTP-specific
specializations that can prepare encoding and decoding hints from
extra information available on the server side.

As a result Jackson2ServerHttpMessageReader is no longer needed.
2017-03-21 10:15:56 -04:00
Rossen Stoyanchev 5f8bc4552f [Encoder|Decoder]HttpMessageWriter server support
There is a natural way to implement ServerHttpMessage[Reader|Writer]
from [Encoder|Decoder]HttpMessageWriter by resolving hints first via
a protected method and then delegating to the regular read or write.

There is no downside either since it does not prevent
[Encoder|Decoder]HttpMessageWriter from being used for both client and
server scenarios while they're more useful.

As a positive side effect AbstractServerHttpMessage[Reader|Writer] can
be removed further simplfications can be made (in a future commit) to
accept ServerHttpMessageWriter for configuration purposes on the server
side and remove instanceof checks for ServerHttpMessageWriter.
2017-03-21 10:15:56 -04:00
Arjen Poutsma d414718467 Update MockServletContext to MediaTypeFactory
This commit changes the `MockServletContext.getMimeType` method to use
`MediaTypeFactory` instead of JAF. It also adds a `addMimeType(String,
MediaType)` method to customize the mime types returned from said
method.

Issue: SPR-14908
2017-03-21 09:39:22 -04:00
Rossen Stoyanchev 1329ccf1bc Update tests to new mime types
This commit updates the test code base to conform to changes in media
types returned by the MediaTypeFactory.

Issue: SPR-14908
2017-03-21 09:39:16 -04:00
Arjen Poutsma 0aaa6528dc Remove JAF references
This commit updates the main code base to conform to the dropped JAF
dependency in MediaTypeFactory. Specifically, it

 - Removes JAF detection (JAF_PRESENT constants)
 - Deprecated useJaf properties, with no direct replacement.
 - Updated docs to remove JAF references, in favor of MediaTypeFactory.

Issue: SPR-14908
2017-03-21 09:11:10 -04:00
Arjen Poutsma f0a43e5d5c Drop JAF dependency from MediaTypeFactory
This commit drops the Java Activation Framework dependency from the
MediaTypeFactory, in favor of parsing our own `mime.types` file, which
was obtained from Apache HTTPD.

Issue: SPR-14908
2017-03-21 09:06:27 -04:00
Rossen Stoyanchev 76fe5f6fce ResourceHttpMessageWriter refactoring
Fold ResourceRegionHttpMessageWriter into ResourceHttpMessageWriter.
The latter was a private helper (not meant to be exposed) and the two
have much in common now sharing a number of private helper methods.

The combined class does not extend AbstractServerHttpMessageConverter
from which it was not using anything.

Internally the combined class now delegates directly to ResourceEncoder
or ResourceRegionEncoder as needed. The former is no longer wrapped
with EncoderHttpMessageWriter which is not required since "resource"
MediaType determination is a bit different.

The consolidation makes it easy to see the entire algorithm in one
place especially for server side rendering (and HTTP ranges). It
also allows for consistent determination of the "resource" MediaType
via MediaTypeFactory for all use cases.
2017-03-20 09:21:35 -04:00
Rossen Stoyanchev c735ffb39b Fix content type issue in ResourceRegionHttpMessageWriter
ResourceRegionHttpMessageWriter no longer extends from
EncoderHttpMessageWriter freeing it to pass the correct content type
into the encoder.

Considering that the main benefit of EncoderHttpMessageWriter is to
deal with content type fallback cases, there is nothing to be missed.

Furthermore ResourceRegionHttpMessageWriter is a package private class
that is used internally within ResourceHttpMessageWriter and never
exposed externally as a an actual HttpMessageWriter.

Issue: SPR-15358
2017-03-17 17:29:05 -04:00
Rossen Stoyanchev 2979b37ae3 Consistent use of Mediatype in EncoderHttpMessageWriter
EncoderHttpMessageWriter now consistently uses the same MediaType to
set on the response and to pass to the encoder.

Issue: SPR-15357
2017-03-17 16:33:33 -04:00
Rossen Stoyanchev 91a75ed772 Polish EncoderHttpMessageWriter Content-Type handling 2017-03-17 12:46:29 -04:00
Rossen Stoyanchev ad91b94249 Require Encoder & Decoder in Reader & Writer wrappers
When CodecHttpMessageConverter was split into DecoderHttpMessageReader
and EncoderHttpMessageWriter the null checks were never removed.

This commit makes the Encoder and Decoder instances provided to their
respective wrappers required.
2017-03-17 12:46:22 -04:00
Rossen Stoyanchev a99fe3eda4 Polish HttpHiddenMethodFilter 2017-03-16 15:01:23 -04:00
Rossen Stoyanchev 37592ea07c DefaultWebFilterChain is a top-level, public class
Issue: SPR-15348
2017-03-16 15:01:23 -04:00
Juergen Hoeller ab7db413c6 DefaultResponseErrorHandler delegate methods declared as protected
Also revises copyToByteArray/String in FileCopyUtils/StreamUtils for lenient null handling.

Issue: SPR-15329
2017-03-16 18:57:13 +01:00
Rossen Stoyanchev f6e2c585c8 Refactor tests to use toExchange() shortcuts
Issue: SPR-15350
2017-03-16 11:55:09 -04:00
Rossen Stoyanchev 41c413a748 Add MockServerWebExchange and toExchange shortcuts
Issue: SPR-15350
2017-03-16 11:55:09 -04:00
Arjen Poutsma 45aa1edf87 Fix Undertow zero-copy-support
This commit fixed the exception that occurs when a larger file is
transfered using zero-copy on Undertow.

Issue: SPR-15343
2017-03-16 12:35:51 +01:00
Rossen Stoyanchev d39da1d06d Polish + minor HttpHandler refactoring
CompositeHttpHandler is public and called ContextPathCompositeHandler.

Also an overhaul of the Javadoc on HttpHandler, WebHttpHandlerAdapter,
and ContextPathCompositeHandler.
2017-03-15 17:05:20 -04:00
Phillip Webb 57d2fcef55 Extract CompositeHttpHandler functionality
Extract CompositeHttpHandler to a package private class and add direct
support via `HttpHandler.of(...)`. This removes the need for the
`HttpHandlerAdapterSupport` class.
2017-03-15 17:05:20 -04:00
Rossen Stoyanchev 1c9d4deba2 Add methods to prepend WebFilter + WebExceptionHandler 2017-03-10 17:04:11 -05:00
Rossen Stoyanchev 2cd6240dab Polish WebHttpHandlerBuilder 2017-03-10 17:04:11 -05:00
Brian Clozel b799013567 Update to Reactor Aluminium SNAPSHOT
Currently the BOM versions are:

* reactor-core 3.0.6.BUILD-SNAPSHOT
* reactor-netty 0.6.2.BUILD-SNAPSHOT

This commit fixes as well a few deprecations in reactor-core.
2017-03-10 15:20:40 +01:00
Rossen Stoyanchev a1c24d2122 SSE reader support to read full content as a String
The SSE reader is ordered ahead of StringDecoder because with
response.decodeToFlux(String.class) we actually want the SSE reader
to get involved first based on the content-type.

At the same time with response.decodeToMono(String.class) there is
nothing the SSE reader can do while the StringDecoder could read the
entore content as one String, as long as the server does terminate
the stream which can happen in a testing scenario.

This commit updates ServerSentEventHttpMessageReader#readMono in
to support String.class by delegating to StringDecoder. Since
reading to a Mono is an explicit choice there is not much possibility
for interfering with decoding to Flux.

Issue: SPR-15331
2017-03-08 17:13:40 -05:00
Rossen Stoyanchev 8c36d3c4d9 Refactor use of DataBufferFactory in SSE reader
This commit simplifies the use of DataBufferFactory in the SSE reader
which is used only to wrap a byte[] as a DataBuffer. There is no actual
benefit to use anything other than a DefaultDataBufferFactory.
2017-03-08 16:56:37 -05:00
Rossen Stoyanchev 9aa25c3982 Polish ServerSentEventHttpMessageReader 2017-03-08 16:38:58 -05:00
Juergen Hoeller 94a7624c1f Polishing 2017-03-07 15:42:04 +01:00
Juergen Hoeller f30c498162 Retrieve newly created attribute from underlying request (marking it for update)
Issue: SPR-15300
2017-03-07 15:41:23 +01:00
Juergen Hoeller 9aaed2bcef Polishing 2017-03-07 11:02:26 +01:00
Juergen Hoeller eeb01db888 Support for new ServletContext methods in Servlet 4.0 b03
Issue: SPR-12674
2017-03-06 21:42:41 +01:00
Juergen Hoeller 47c4cf7abf Drop support for Jetty 9.3 and OkHttp 2.x
Issue: SPR-15038
2017-03-06 17:54:02 +01:00
Rossen Stoyanchev 37726f4214 Improved annnotation support in ResolvableMethod 2017-03-06 09:19:57 -05:00
Rossen Stoyanchev 0296d003af Improved generics support in ResolvableMethod 2017-03-06 09:19:57 -05:00
Rossen Stoyanchev cdf19d1db1 @RequestParam tests use ResolvableMethod 2017-03-03 23:43:01 -05:00
Rossen Stoyanchev 6950cc0e64 Move ResolvableMethod
From spring-webflux to spring-web test sources since it is perfectly
usable for testing Spring MVC annotation method support.

Potentially to be promoted further up for use in any module that has
annotation method support. It has spring-core dependencies only
2017-03-03 22:12:33 -05:00
Rossen Stoyanchev ce69855274 Fix failing tests 2017-03-02 11:13:47 -05:00
Rossen Stoyanchev ccb2c6530e Support for @ControllerAdvice in WebFlux
Issue: SPR-15132
2017-03-02 03:30:34 -05:00
stonio 7d062df992 Use String#isEmpty()
Closes gh-1335
2017-02-22 11:55:17 +01:00
Juergen Hoeller d2cc97af47 Polishing 2017-02-21 22:41:40 +01:00
Brian Clozel babd5517aa Revert ParsingPathMatcher concurrency checks
`PathPatternParser` is now thread-safe and creates a new internal parser
for each `parse` call, since this operation is cheap.
This commit removes the `ThreadLocal` based instances of
`PathPatternParser` in `ParsingPathMatcher` which are not required
anymore.

Issue: SPR-15246
2017-02-21 11:44:59 +01:00
Andy Clement a0505bf1e7 Make PathPatternParser multi-threaded
With this change the original PathPatternParser is renamed
InternalPathPatternParser and a new PathPatternParser class is added.
This new PathPatternParser class is a very simple thread-safe wrapper for
the InternalPathPatternParser. It achieves this by creating a new
InternalPathPatternParser for each new parse request.  This follows the
model used for SpEL parsing.
2017-02-21 11:44:59 +01:00
Rossen Stoyanchev 71b021c7cc Add decorators for ClientHttpRequest & Response 2017-02-20 18:29:30 -05:00
Juergen Hoeller 1ddf8ec625 Polishing 2017-02-21 00:04:08 +01:00
Juergen Hoeller 73493bc490 Revised imports in tests (org.jetbrains.annotations.NotNull etc) 2017-02-20 23:00:22 +01:00
Juergen Hoeller 370e3d683a Polishing 2017-02-20 23:00:12 +01:00
Brian Clozel b732251b09 Ignore HEAD requests in ShallowEtagHeaderFilter
Prior to this commit, the `ShallowEtagHeaderFilter` could participate in
the response and set its ETag/Content-Length headers, even for HEAD
requests. Since the response body is empty, the filter implementation
would set a `"Content-Length: 0"`.

The RFC states that responses to HEAD requests should exhibit identical
response headers to GET (with the possible exception of payload related
headers such as Content-Length.

With this commit, `ShallowEtagHeaderFilter` now ignores HEAD requests
since the proper values may be set already for payload related headers
by the handler. The filter has no way to generate a proper ETag value
nor calculate the content length without the actual body.

Issue: SPR-15261
2017-02-20 11:58:22 +01:00
Andy Clement d924538211 Fix RegexPathElement when matching variables against a root path
The first fix for issue 15264 covered the case of using a single
variable (the case mentioned in the bug report). However, when
more than one variable is used a different PathElement is built.
This RegexPathElement needs a similar change that checks the
path includes data to bind.

Issue: SPR-15264
2017-02-19 17:11:31 -08:00
Andy Clement f1653cc21c Fix PathPattern incorrectly matching variable against root path
Issue: SPR-15264
2017-02-17 17:37:12 -08:00
Juergen Hoeller 45df1d9fea Javadoc fixes 2017-02-18 01:43:30 +01:00
Juergen Hoeller 214d0d76a5 Polishing 2017-02-18 01:01:35 +01:00
Juergen Hoeller 1ee0626c94 Polishing 2017-02-17 21:06:58 +01:00
Andy Clement f98ea11e5e Fix string handling to avoid exceptions when doing path extraction
Issue: SPR-15259
2017-02-15 16:37:43 -08:00
Juergen Hoeller 5f531a7a7d Comparators entry point with generically typed factory methods
Issue: SPR-14779
2017-02-15 18:05:32 +01:00
Brian Clozel 4ff17676d3 Avoid duplicate Content-Length headers in Netty client
This commit checks that a "Content-Length" request header isn't already
present before adding one in `Netty4ClientHttpRequestFactory`.
`HttpMessageConverter` implementations can write that request header so
the Netty request factory should only write that value when the header
is missing.

If that header is not written (and since we're not dealing with
the HTTP exchange in a chunked-based fashion), the HTTP client might not
send the request body at all.

Issue: SPR-15241
2017-02-13 21:07:35 +01:00
Juergen Hoeller 44ec6e0037 Polishing 2017-02-13 15:07:07 +01:00
Juergen Hoeller 199aa776c9 Support for Servlet 4.0 (PushBuilder argument, MockServletContext)
Issue: SPR-12674
2017-02-13 15:06:59 +01:00
Brian Clozel 2ac08afab5 Threadsafe use of pattern parser in ParsingPathMatcher
This commit ensures that the `PathPatternParser` and the associated
cache map are used in a threadsafe fashion, since the PathMatcher
instance can be used for concurrent requests.

Issue: SPR-15246
2017-02-13 14:34:49 +01:00
Sebastien Deleuze ef550c43d6 Flush JSON stream after each element
Issue: SPR-15104
2017-02-13 14:20:19 +01:00
Brian Clozel 1901cc65fd Use ParsingPathMatcher by default in WebFlux
Issue:
2017-02-10 18:30:28 +01:00
Brian Clozel fa4202f1bd Revert Path Pattern changes in WebFlux
Issue: SPR-14544
2017-02-10 18:30:01 +01:00
Juergen Hoeller ed85337901 MockHttpServletRequest exposes "HTTP/1.1" as default protocol
Issue: SPR-15232
2017-02-10 10:47:36 +01:00
Brian Clozel 5488906d0c Polish
Issue: SPR-15206
2017-02-09 22:36:28 +01:00
Greg Turnquist e4be7131ca Implement reactive HiddenHttpMethodFilter
Provides the ability to embed an HTTP verb inside a hidden form field
(like Thymeleaf's th:method operator).

Issue: SPR-15206
2017-02-09 22:35:57 +01:00
Brian Clozel 8d43f45515 Reduce API Surface in PathPatternRegistry
This commit reduces the exposition of `PathPattern` instances throughout
the `HandlerMapping` API and removes some methods from its public API.

Issue: SPR-14544
2017-02-09 22:09:46 +01:00
Brian Clozel 09d18f2ef5 Refactor HandlerMapping path match configuration
Since the introduction of `PathPatternRegistry`, the various path match
configuration flags are no longer needed in several places and that
configuration can live in the registry itself.

Issue: SPR-14544
2017-02-09 15:58:16 +01:00
Brian Clozel 47ac3379ea Do not use ParsingPathMatcher by default in Spring MVC 2017-02-09 11:21:33 +01:00
Brian Clozel 18c04815a7 Add PathPatternRegistry
This commit adds the new `PathPatternRegistry`, which  holds a
sorted set of `PathPattern`s and allows for searching/adding patterns

This registry is being used in `HandlerMapping` implementations and
separates path pattern parsing/matching logic from the rest. Directly
using `PathPattern` instances should improve the performance of those
`HandlerMapping` implementations, since the parsing and generation of
pattern variants (trailing slash, suffix patterns, etc) is done only
once.

Issue: SPR-14544
2017-02-09 11:21:33 +01:00
Brian Clozel a4da313a0a Polish
Issue: SPR-14544
2017-02-09 11:21:32 +01:00
Andy Clement f786feb5e1 Ensure correct recognition for start of match-the-rest path elements
Without this change the /{*foobar} and /** path elements were
not correctly enforcing that the first character they encounter
must be a separator. This problem was introduced when adjusting
the generated path element chains for these constructs. Originally
the generated chain included a SeparatorPathElement but in order for
these to match 'nothing' (i.e. /foo matches /foo/{*foobar}) the separator
path element was removed, so the separator enforcement needed moving
into the CaptureTheRestPathElement and WildcardTheRestPathElement.

Issue: SPR-14544
2017-02-09 11:09:38 +01:00
Andy Clement f58ffad939 Introduce PathPatternParser for optimized path matching
This commit introduces a PathPatternParser which parses request pattern
strings into PathPattern objects which can then be used to fast
match incoming string paths. The parser and matching supports the syntax
as described in SPR-14544. The code is optimized around the common usages
of request patterns and is designed to create very little transient
garbage when matching.

Issue: SPR-14544
2017-02-09 11:09:38 +01:00
Violeta Georgieva 706c72e1c7 Simplify the calculation of UndertowServerHttpRequest.uri 2017-02-08 16:55:58 -05:00
Rossen Stoyanchev f2967467e0 Improve writing in mock reactive request and response
Before this change the write Publisher was saved and Mono.empty()
returned from the write metohd which did not properly implement
the write contract since no writing ("consuming") was done.

This can be a problem in some cases. For example the request may appear
to succeed even if the publisher produces an error later when
subscribed to later after request handling completes.

This commit introduces a writeHandler function in the mock request and
response. By default it "writes" by consuming the content immediately,
which allows it to return a Mono<Void> that properly reflects when
writing is done, and it also caches the data so it may be replayed
later for test assertions.

For streaming scenario a custom writeHandler may be registered which
allows the custom handling to determine how long to stream before
cancelling so request handling may complete.

Issue: SPR-14590
2017-02-07 21:57:38 -05:00
Sebastien Deleuze 6b9b0230c4 Introduce JSON streaming support
This commit introduces JSON streaming support which
consists of serializing HTTP request with
application/stream+json media type as line delimited JSON.

It also optimize Flux serialization for application/json by
using flux.collectList() and a single Jackson invocation
instead of one call per element previous strategy.
This change result in a x4 throughput improvement
for collection with a lot of small elements.

Issues: SPR-15095, SPR-15104
2017-02-06 18:14:53 +01:00
Stephane Nicoll 48e834dfd1 Update copyright header 2017-02-03 07:34:39 +01:00
Eitan Adler 938c6a2acd Polish javadoc
Closes gh-1312
2017-02-03 07:29:50 +01:00
Ryan Pickett 654e14a86a Fix Javadoc in UriComponentsBuilder 2017-02-02 17:29:20 -05:00
Rossen Stoyanchev 1466c82f53 Better support for overriding base URI in WebClient
The base URI is ignored for requests that include a host.

WebClient exposes UriBuilder (rather than UriBuilderFactory) for
per-request URI building based on the base URI. That provides
full control to add or replace components of the base URI.
2017-02-02 17:24:18 -05:00
Juergen Hoeller acf511ac0e Polishing 2017-02-02 20:11:06 +01:00
Juergen Hoeller 9b3131ffba Skip default Content-Length if Transfer-Encoding header has been set
Issue: SPR-15212
2017-02-02 20:01:10 +01:00
Juergen Hoeller 0da964f0a7 MockHttpServletRequest returns empty BufferedReader in case of no content
Issue: SPR-15215
2017-02-02 19:55:42 +01:00
Rossen Stoyanchev c79092f0f9 Refactor random port in reactive module tests
This commit removes the use of SocketUtils#findAvailableTcpPort in
favor of letting servers pick a dynamic port by specifying port 0.

This should make integration tests more stable because the port is
chosen at the place where it needs to be used. It gives servers a
chance to try to open a socket on some port and start using the socket
if successful.
2017-01-31 16:19:19 -05:00
Rossen Stoyanchev 1fb0b0b786 Expose remoteAddress from ServerHttpRequest
Issue: SPR-15200
2017-01-31 15:04:24 -05:00
Rossen Stoyanchev 9142427c4d Add committed flag to ReactiveHttpOutputMessage
Issue: SPR-15135
2017-01-31 12:50:27 -05:00
Juergen Hoeller f84907a1fc Polishing 2017-01-31 12:00:13 +01:00
Juergen Hoeller 9243a14794 Test for correct handling of multiple header values
Issue: SPR-15166
2017-01-31 11:59:41 +01:00
Juergen Hoeller 1b2dc3638f Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
2017-01-30 22:15:55 +01:00
Juergen Hoeller 768802fa96 ResourceHttpMessageConverter reads Content-Disposition header to expose filename through Resource
Issue: SPR-15191
2017-01-30 22:15:30 +01:00
Rossen Stoyanchev cd476832cc Add check for Long.MAX_VALUE
Issue: SPR-15203
2017-01-30 10:03:20 -05:00
Rossen Stoyanchev 74a3013174 Replace use of deprecated Reactor Operators#getAndAdd 2017-01-30 09:14:05 -05:00
Arjen Poutsma 69c16f3821 Add headers in InterceptingClientHttpRequest
This commit *adds* the "intercepted" headers to the ClientHttpRequest,
as opposed to replacing them, which is what happened before this commit.

Issue: SPR-15166
2017-01-30 14:18:50 +01:00
Rossen Stoyanchev b487ed6748 Fix trailing slash issue
Issue: SPR-15201
2017-01-28 12:38:44 -05:00
Rossen Stoyanchev ee861e8001 Fix compiler deprecation-related errors 2017-01-27 17:26:14 -05:00
Rossen Stoyanchev d057c3d981 Deprecate DefaultUriTemplate handler
Following on the introduction of the UriBuilderFactory and its
DefaultUriBuilderFactory implementation, this commit deprecates
DefaultUriTemplate (and AbstractUriTemplateHandler).

The new DefaultUriBuilderFactory has comparable functionality and is
more flexible but cannot be merged  into the existing hierarchy and
be backwards compatible with regards to protected methods.

Issue: SPR-15124
2017-01-27 16:38:16 -05:00
Rossen Stoyanchev 7b67b5bc2a Introduce UriBuilderFactory and UriBuilder
Issue: SPR-15124
2017-01-27 14:07:55 -05:00
Rossen Stoyanchev cb0d992303 Refactor test HttpServer implementations
Due to the static nature of JUnit parameterized test inputs, an
HttpServer instance is re-used for all tests per test class.

This commit adds lifecycle handling to AbstractHttpServer with a
lifecycle monitor to ensure test server fields are properly
initialized and reset after each test .
2017-01-27 10:31:08 -05:00
Stephane Nicoll d550eb152c Polish contribution
Closes gh-1307
2017-01-27 14:17:13 +01:00