Commit Graph

1461 Commits

Author SHA1 Message Date
Rossen Stoyanchev c3f22b7364 Add "mutate" builder to ServerWebExchange
This commit adds a default mutate method to ServerWebExchange which
prepares an immutable wrapper and returns the provided mutated
properties.
2016-10-28 19:05:05 +03:00
Sebastien Deleuze b1030eba3f Fix JsonObjectDecoder chunks handling
Issue: SPR-14859
2016-10-28 16:44:53 +02:00
Arjen Poutsma 8f844461a0 Make HttpComponentsAsyncClientHttpRequest abortable
This commit aborts the HttpComponentsAsyncClientHttpRequest whenever the
returned Future is canceled.

Issue: SPR-14845
2016-10-28 14:19:15 +02:00
Arjen Poutsma 7b469f9c62 Improve WebClient error handling
This commit introduces two new `WebClient` methods: `retrieveMono` and
`retrieveFlux`, both of which offer direct access to the response body.
More importantly, these methods publish a WebClientException if the
response status code is in the 4xx or 5xx series.

Issue: SPR-14852
2016-10-28 13:15:29 +02:00
Arjen Poutsma c96badc794 Add ExchangeFilterFunction.ofRequestProcessor and ofResponseProcessor 2016-10-28 09:05:07 +02:00
Arjen Poutsma 20dec61d04 Refactored BodyInserters
This commit introduces a couple of changes to BodyInserters:

- Refactored writeWithMessageWriters into BiFunction
- BodyInserters.fromResource now uses ResourceMessagewriter from context
- BodyInserters.fromServerSentEvents now uses SseHttpMessageWriter from context
2016-10-25 11:11:58 +02:00
Arjen Poutsma 94930043fd Added MediaType.TEXT_EVENT_STREAM 2016-10-25 11:11:58 +02:00
Brian Clozel 99a3210859 Refactor tests with ScriptedSubscriber
Reactor recently added the `ScriptedSubscriber` in its new
`reactor-addons` module. This `Subscriber` revissits the previous
`TestSubscriber` with many improvements, including:

* scripting each expectation
* builder API that guides you until the final verification step
* virtual time support

This commit refactor all existing tests to use this new
infrastructure and removed the `TestSubscriber` implementation.

Issue: SPR-14800
2016-10-25 10:44:44 +02:00
Rossen Stoyanchev aea3a75018 Fix failing tests
Issue: SPR-14772, SPR-14803
2016-10-21 16:19:57 -04:00
Rossen Stoyanchev 5c9c5e0b45 Early registration of WriteListener
At present Tomcat expects a WriteListener to be registered immediately
on the initial thread so for the time being this commit ensures the
WriteListener is registered unconditionally for every request.

Issue: SPR-14772, SPR-14803
2016-10-21 15:29:57 -04:00
Rossen Stoyanchev e3673d43b9 Thread-safe reactive ServerHttpRequest
This commit replaces the lazy URI and headers initialization in the
reactive ServerHttpRequest in favor of eager initialization at
construction time. Both the URI and headers are nearly guaranteed to
be accessed for every request (URI for application path, headers for
"Origin" header).

Query params are still lazily parsed but parsing is idemptotent and
in the unlikely case of concurrent access (it's the framework that
typically accesses query params) it maybe parsed twice but should
be side effect free still.

Cookies are also parsed lazily and since we delegate to the "native"
request, it depends on the underlying runtime whether synchronization
is needed. This commit adds synchronization for the HttpServletRequest.
At present RxNetty, Reactor, and Undertow implementations provide
thread-safe access to cookies.
2016-10-21 15:17:28 -04:00
Arjen Poutsma 08931950f4 Add byte[] encoder and decoder
This commit adds a ByteArrayDecoder and ByteArrayEncoder.
2016-10-21 12:34:06 +02:00
Juergen Hoeller 3726c6f18d Polishing 2016-10-21 12:26:27 +02:00
Rossen Stoyanchev b92d541ba0 Add contextPath support for reactive web applications
This commit introduces support for running multiple HttpHandler's under
distinct context paths which effectively allows running multiple
applications on the same server. ContextPathIntegrationTests contains
an example of two applications with different context paths.

In order to support this the HttpHandler adapters for all supported
runtimes now have a common base class HttpHandlerAdapterSupport
which has two constructor choices -- one with a single HttpHandler and
another with a Map<String, HttpHandler>.

Note that in addition to the contextPath under which an HttpHandler is
configured there may also be a "native" contextPath under which the
native runtime adapter is configured (e.g. Servlet containers). In such
cases the contextPath is a combination of the native contextPath and
the contextPath assigned to the HttpHandler. See for example
HttpHandlerAdapterSupportTests.

Issue: SPR-14726
2016-10-20 17:42:38 -04:00
soldierkam 8143e5fe20 HttpClient instance should be shared for each call 2016-10-20 17:06:46 +02:00
Arjen Poutsma fa9cc1eb1a Add bodyToMono/bodyToFlux convenience methods
This commit adds a bodyToMono and bodyToFlux convenience method to
ClientResponse/ServerRequest, similar to the body(Publisher) method that
is on ClientRequest/ServerResponse.
2016-10-20 16:58:30 +02:00
Sebastien Deleuze 921bf5fb70 Use the official RxJava to Reactive Streams adapter
This commit removes the usage of Reactor adapters (about to
be moved from Reactor Core to a new Reactor Adapter module).
Instead, RxReactiveStreams is now used for adapting RxJava
1 and Flowable methods are used for RxJava 2.

Issue: SPR-14824
2016-10-20 15:08:05 +02:00
Arjen Poutsma 0cfb6b37f2 Align Reactive WebClient with web.reactive.function
This commit refactors the web client to be more similar to
web.reactive.function. Changes include:

- Refactor ClientWebRequest to immutable ClientRequest with builder and
   support for BodyInserters.
- Introduce ClientResponse which exposes headers, status, and support
   for reading from the body with BodyExtractors.
- Removed ResponseErrorHandler, in favor of having a ClientResponse
   with "error" status code (i.e. 4xx or 5xx). Also removed
   WebClientException and subclasses.
- Refactored WebClientConfig to WebClientStrategies.
- Refactored ClientHttpRequestInterceptor to ExchangeFilterFunction.
- Removed ClientWebRequestPostProcessor in favor of
   ExchangeFilterFunction, which allows for asynchronous execution.

Issue: SPR-14827
2016-10-20 12:35:23 +02:00
Arjen Poutsma dc1926a861 Moved BodyExtractor and BodyInserter to http.codec
This commit moves the web.reactive.function.[BodyInserter|BodyExtractor]
to http.codec, so that they can be used from the client as well.

Furthermore, it parameterized both inserter and extractor over
ReactiveHttpOutputMessage and ReactiveHttpInputMessage respectively, so
that they can be limited to only be used on the client or server.
2016-10-20 11:44:01 +02:00
Rossen Stoyanchev 72397e3505 Polish
Issue: SPR-14798
2016-10-19 16:30:52 -04:00
Sebastien Deleuze 50f2cda009 Better encapsulation for CORS default permit configuration
This commit also improves CorsRegistration Javadoc.

Issue: SPR-14798
2016-10-19 15:31:22 -04:00
Violeta Georgieva 25e7cd577d Handle AsyncListener.onComplete in Servlet adapter
Typically the Mono<Void> from the HttpHandler also reflects the
completion of the request and response body processors and at that
point invoking AsyncContext#complete() from HandlerResultSubscriber
should be sufficient.

This commit explicitly propagates the AsyncListener.onComplete event
to the request and response body processors for added safety.
Technically as mentioned those processors should have completed but
depending on how the controller is written there is a possibility
the body processors may not have completed.

Issue: SPR-14772
2016-10-19 14:28:24 -04:00
Rossen Stoyanchev ec1eb14280 Add getPrincipal to ServerWebExchange
ServerWebExchange now has a getPrincipal method and along with that a
ServerWebExchangeDecorator that can be used to wrap the exchange in
order to return the authenticated user.

Issue: SPR-14680
2016-10-17 17:48:22 -04:00
Philippe Marschall ae5b0c6fb5 Replace J2EE with Java EE
String with version 5 the name of Java Platform, Enterprise Edition
changed from J2EE to Java EE. However a lot of the documentation still
uses the term J2EE.

This commit includes the following changes:

 * replace J2EE with Java EE where appropriate

This is not a blind search and replace. The following occurrences
remain unchanged:

 * references to old J2EE releases, most notably 1.3 and 1.4.
 * references to "Expert One-On-One J2EE Design and Development"
 * references to "Core J2EE patterns"
 * XML namespaces
 * package names

Issue: SPR-14811
See gh-1206
2016-10-15 11:49:00 +03:00
Rossen Stoyanchev 6cb7d51ee5 Polish 2016-10-14 17:16:23 -04:00
soldierkam e5158d47e0 EncoderHttpMessageWriter tries to send wildcard type in response header 2016-10-14 16:58:31 -04:00
Violeta Georgieva ced6559941 Improve AbstractResponseBodyProcessor.onNext(..)
If the provided DataBuffer is empty then request the next DataBuffer.
2016-10-14 16:41:14 -04:00
Rossen Stoyanchev fada5aed6e Check status in AbstractServerHttpResponse setComplete 2016-10-14 15:32:34 -04:00
Rossen Stoyanchev 960cc42060 Fix test failure in WebSessionIntegrationTests 2016-10-13 18:02:41 -04:00
Rossen Stoyanchev d4446c79b6 Restore state field in AbstractServerHttpResponse
This commit fixes test failures introduced earlier in commit 9f8e84.
2016-10-13 17:10:51 -04:00
Rossen Stoyanchev c1e5e3a87e Polish AsyncListener in ServletHttpHandlerAdapter 2016-10-13 16:31:53 -04:00
Violeta Georgieva 7e94377382 Handle async operation events
Problem:
The following exception is observed on an async timeout:
"java.lang.IllegalStateException: It is invalid to call
isReady() when the response has not been put into non-blocking mode"

Current Implementation:
The async operation events sent by the web container are not propagated
to the internal implementation. When timeout/error happens and if the
application does not complete the async operation, the web container
will complete it. At that point if the application tries to read/write,
the operation will fail with an exception (above) that there is not
async operation started.

Proposed Solution:
On async timeout or error, make calls to:
- AbstractRequestBodyPublisher.onError,
- AbstractResponseBodyProcessor.onError,
- AbstractResponseBodyFlushProcessor.onError
As a result of these calls the async operation will be completed and no
more invocations of read/write will be made.
2016-10-13 16:14:33 -04:00
Rossen Stoyanchev 9f8e8458c1 Polish AbstractServerHttpResponse
This commit simplifies the logic for applying beforeCommit actions
replacing the use of chained Mono.then calls with a single
Flux.concat.

Also renamed writeStatusCode, writeHeaders, and writeCookies to
applyStatusCode, applyHeaders, and applyCookies respectively to
better reflect we're simply setting them on the underlying response
(not necessarily written yet).
2016-10-13 16:04:30 -04:00
Sam Brannen 8cf1933148 Only print request/response body if char enc is present in MVC Test
Commit e65a1a4372 introduced support in PrintingResultHandler for only
printing the request or response body in the Spring MVC Test framework
if the content type is known to be text-based (e.g., plain text, HTML,
XHTML, XML, JSON, etc.). For unknown content types the body is assumed
to be text-based and is therefore always printed. The latter behavior,
however, is undesirable since the content may in fact not be text-based.

This commit addresses this issue by making the printing of the request
or response body an opt-in feature. Specifically, if a character
encoding has been set, the request or response body will be printed by
the PrintingResultHandler. Note, however, that the character encoding
is set to ISO-8859-1 in MockHttpServletResponse by default.

In addition, MockHttpServletRequest's getContentAsString() method now
throws an IllegalStateException if the character encoding has not been
set.

Issue: SPR-14776
2016-10-13 16:55:14 +02:00
Rossen Stoyanchev 1de73b9b4f Polish 2016-10-11 20:20:40 -04:00
Rossen Stoyanchev b28b3e8877 Add WebExchangeDataBinder
Issue: SPR-14541
2016-10-11 20:20:40 -04:00
Sebastien Deleuze 9bf8489afd Remove duplicated elements in CorsConfiguration#combine()
Issue: SPR-14792
2016-10-11 10:38:34 +02:00
Sebastien Deleuze 196c73fa50 Polish CorsConfigurationTests 2016-10-11 10:03:12 +02:00
Rossen Stoyanchev 33c48e7a17 Polish reactive CORS support 2016-10-10 18:00:11 -04:00
Sebastien Deleuze e31a2f778b Add Reactive CORS support
This is a port of Spring MVC CORS support for Spring Web Reactive:
 - CORS classes keep the same name but are in the
   web.cors.reactive package
 - CorsConfiguration is reused because not tied to Servlet API
 - CORS HandlerMapping integration is done at
   AbstractHandlerMapping level
 - AbstractUrlHandlerMapping and AbstractHandlerMethodMapping
   have been slightly modified to call
   AbstractHandlerMapping#processCorsRequest()
 - Both global CORS configuration + @CrossOrigin support have
   been implemented

Issue: SPR-14545
2016-10-10 18:00:05 -04:00
Sebastien Deleuze 0cc330e8fc Fix HttpRequest#getURI() with Netty based engines
Host and port are now properly retrieved from Reactor
Netty and RxNetty (the scheme is not available).

Issue: SPR-14794
2016-10-10 23:35:23 +02:00
Brian Clozel ea5ff87f8e Fix NumberFormatException with X-Forwarded-Host
This commit fixes `NumberFormatException`s that were thrown when parsing
IPv6 host values in `X-Forwarded-Host` request headers.

Issue: SPR-14761
2016-10-07 23:11:34 +02:00
Brian Clozel 53441f8962 Configure default SSL context in Netty RequestFactory
This commit configures a default SslContext if none has been provided.
This also enforces separate Netty bootstrap instances for cleartext and
TLS exchanges.

Issue: SPR-14744
2016-10-06 15:57:26 +02:00
Juergen Hoeller cfa0f6c84b Consistent final logger fields 2016-10-04 23:00:36 +02:00
Sebastien Deleuze 324c310cbd Log unresolved exceptions at error level 2016-10-04 16:08:59 +02:00
Brian Clozel 11aa920785 Remove RxJava 1.x variants of WebClient adapters
Issue: SPR-14743
2016-10-04 14:47:55 +02:00
Sam Brannen 04b8ae921e Introduce getContentAsByteArray()/getContentAsString() in MockHtttpSvltReq
In order to improve debugging and logging within test suites, this
commit introduces getContentAsByteArray() and getContentAsString()
methods in MockHttpServletRequest, analogous to the existing methods in
MockHttpServletResponse.

Issue: SPR-14717
2016-10-03 18:05:58 +02:00
Sebastien Deleuze dbc86ec043 Refine Jackson canEncode() / canDecode() implementation
This commit refine Jackson canEncode() / canDecode()
implementation by using ObjectMapper canSerialize() /
canDeserialize() methods.

Issue: SPR-14748
2016-09-27 23:59:44 +02:00
Sebastien Deleuze 44ceecc8b3 Imply text/event-stream when serializing ServerSentEvent
Issue: SPR-14748
2016-09-27 09:27:33 +02:00
Juergen Hoeller fb7ae010c8 Avoid unnecessary generics on emptyMap/Set/List 2016-09-26 18:04:49 +02:00
Josh Long 9b87ea017b fix spelling of word 'recommendation'
this PR fixes the spelling error for the word 'recommendation'
2016-09-21 15:03:04 -04:00
Juergen Hoeller 89717e1783 Reactive setup refinements 2016-09-21 11:24:20 +02:00
Brian Clozel 578af59f0c Polish byte-range resource handling 2016-09-20 23:46:21 +02:00
Juergen Hoeller 129d7bef6e Polishing 2016-09-20 22:41:20 +02:00
Juergen Hoeller d94ce0a1b2 Avoid package dependency cycles 2016-09-20 22:41:11 +02:00
Brian Clozel 5b33e02fb4 Add ClientHttpRequestInterceptor in WebClient
This commit adds a new chain-based, interception contract to be used
with `WebClient`. This is the HTTP client equivalent of the `WebFilter`
contract already implemented in web reactive server.

A `ClientHttpRequestInterceptor` implementation can transform the
outgoing HTTP request (method, URI or headers) before delegating it to
the next interceptor in the chain, or bypass the request processing
altogether and return a (cached) HTTP response.

Issue: SPR-14502
2016-09-20 18:15:07 +02:00
Brian Clozel c608103140 Add client HTTP request and response Mocks 2016-09-20 18:15:07 +02:00
Sebastien Deleuze f918a2b192 Rename beforeRead/Write() to resolveRead/WriteHints()
This commit also removes the ServerHttpResponse parameter, not
needed here since it is possible to override the write() method.

Issue: SPR-14557
2016-09-20 17:52:31 +02:00
Brian Clozel a7a9e36ca0 Add ResourceRegionHttpMessageWriter
This new `HttpMessageWriter` leverages the `ResourceRegionEncoder` to
write `ResourceRegion` to HTTP responses, thus supporting HTTP Range
requests.

Whenever possible, this message writer uses the zero copy support for
single range requests.

This `HttpMessageWriter` is never used directly, but is used as a
delegate by the `ResourceHttpMessageWriter`. When provided with the
`BOUNDARY_STRING_HINT`, the `ResourceRegionHttpMessageWriter`
adapts its behavior in order to write a single/multiple byte ranges.

Issue: SPR-14664
2016-09-20 16:18:45 +02:00
Brian Clozel 55d6f88dcd Add ResourceRegionEncoder
This commit adds the necessary infrastructure for the support of HTTP
Range requests. The new `ResourceRegionEncoder` can write
`ResourceRegion` objects as streams of bytes.

The `ResourceRegionEncoder` relies on an encoding hint
`BOUNDARY_STRING_HINT`. If present, the encoder infers that multiple
`ResourceRegion`s should be encoded and that the provided boundary
String should be used to separate ranges by mime boundaries.
If that hint is absent, only a single resource region is encoded.

Issue: SPR-14664
2016-09-20 16:14:22 +02:00
Sebastien Deleuze 1d46b8d7e1 Polish 2016-09-20 14:28:12 +02:00
Sebastien Deleuze 857e77eec2 Make ServerHttpMessageReader/Writer more powerful and flexible
This commit makes it possible, in addition to provide hints, to
perform additional operations with the request and the response
at ServerHttpMessageReader/Writer level.

AbstractServerHttpMessageReader/Writer now provide
convenient beforeRead/beforeWrite abstract methods for such need.

Issue: SPR-14557
2016-09-20 11:55:51 +02:00
Sebastien Deleuze 38f3d12e45 Do not provide hints for can*() methods anymore
Issue: SPR-14557
2016-09-20 11:55:51 +02:00
Sebastien Deleuze 1bf828a149 Polish 2016-09-19 16:32:50 +02:00
Sam Brannen b521aa879f Clean up warnings related to forthcoming removals in Tomcat 9 2016-09-17 16:16:06 +02:00
Rossen Stoyanchev b2ccdfbc9e Polish error logging for HTTP reactive server classes 2016-09-16 16:09:44 -04:00
Violeta Georgieva 80ff5ae9c5 Improve exception handling when clients disconnect.
Issue: SPR-14538
2016-09-16 16:09:43 -04:00
Brian Clozel c4b9b92247 Polish ResponseExtractors 2016-09-16 21:39:38 +02:00
Rob Winch b58a06208f Add HttpBasic ClientWebRequestPostProcessor
Issue: SPR-14682
2016-09-16 21:29:59 +02:00
Rossen Stoyanchev 0bace1b0ae Add getContextPath to ServerHttpRequest
Issue: SPR-14726
2016-09-16 15:21:48 -04:00
Rossen Stoyanchev cf2112f539 Update intializer for the reactive servlet adapter
Move the AbstractServletHttpHandlerAdapterInitializer together with
the other two base classes in spring-web-reactive. Since the
interface is in the web package, this avoids a package cycle.
Also add a mention in the reference.

Issue: SPR-14713
2016-09-16 12:57:16 -04:00
Arjen Poutsma 2b57a4d618 Add WebApplicationInitializers for Web Reactive
This commit introduces three new WebApplicationInitializers for use with
Spring Web Reactive:

 - The AbstractServletHttpHandlerAdapterInitializer registers a
 ServletHttpHandlerAdapter that wraps a user-provided HttpHandler.

 - The AbstractDispatcherHandlerInitializer registers a
 ServletHttpHandlerAdapter that wraps a DispatcherHandler (or any
 WebHandler). The handler is provided with an application context.

 - The AbstractAnnotationConfigDispatcherHandlerInitializer is a
 subclass of the above, creating an
 AnnotationConfigApplicationContext based no provided @Configuration
 classes.

Issue: SPR-14713
2016-09-16 12:57:16 -04:00
Sebastien Deleuze 9d8c089a21 Polish 2016-09-16 16:17:37 +02:00
Sebastien Deleuze 6cda08e94b Add Jackson @JsonView support
Issue: SPR-14693
2016-09-16 12:51:27 +02:00
Sebastien Deleuze e74c59bf30 Introduce ServerHttpMessageWriter/Reader to resolve hints
Issue: SPR-14693
2016-09-16 12:51:27 +02:00
Juergen Hoeller 6dc1898dbb Timeout exceptions as RuntimeExceptions
Issue: SPR-14669
2016-09-15 08:54:17 +02:00
Rossen Stoyanchev 765b47246a Improve async request timeout handling
Rather than setting the status to 503 directly from the timeout
interceptor which no longer seems to work reliably with Servlet
containers like Jetty even performing an additional ERROR dispatch back
to the original URL, we know rather set the DeferredResult to an
AsyncTimeoutException, which results in a dispatch and standard
handling within Spring MVC. This should be a more reliable way of
dealing with timeouts.

Issue: SPR-14669
2016-09-14 21:34:30 -04:00
Rossen Stoyanchev 8ccfecc406 Workaround for Content-Length issue in Reactor Netty
Issue: SPR-14643
2016-09-14 17:45:27 -04:00
Sebastien Deleuze fc52ddcd97 Polish 2016-09-13 15:03:13 +02:00
Sebastien Deleuze 4991b97887 Polish 2016-09-12 14:47:48 +02:00
Sebastien Deleuze aaba53f76a Allow to pass hints parameter in HttpMessageReader/Writer
Issue: SPR-14557
2016-09-12 11:13:27 +02:00
Sebastien Deleuze b91867cf45 Update Codec API to use Map<String, Object> for hints
Issue: SPR-14557
2016-09-12 11:08:01 +02:00
Brian Clozel cc5300c4d5 Align MVC checkNotModified with reactive support
Since SPR-14522, the web reactive framework supports checkNotModified
features. This commit aligns the existing MVC infrastructure with
web reactive's behavior.

Because of the new Servlet 3.0 baseline, some constraints
aren't relevant anymore and duplicate code has been removed in
`HttpEntityMethodProcessor`.

Issue: SPR-14659
2016-09-06 18:02:48 +02:00
Violeta Georgieva 00617d74de Fix AbstractRequestBodyPublisher to comply with the spec
As per specification "The Subscription MUST allow the Subscriber to
call Subscription.request synchronously from within onNext or
onSubscribe". With the current implementation if Subscription.request
is called more than once when Subscriber.onSubscribe ISE will be
thrown - java.lang.IllegalStateException: DEMAND.
With this fix the implementation will not throw ISE and will allow
many invocations of Subscription.request when
Subscriber.onSubscribe.
2016-09-02 23:37:20 +02:00
Rossen Stoyanchev a1ac51256a Add MockServerHttpRequest/Response to spring-test
Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Rossen Stoyanchev 73752c295d Refactor location of MockServerHttpRequest/Response
This change puts the MockHttpServerRequest/Response under
org.springframework.mock.http.server.reactive.test which
mirrors the arrangement we have with the Servlet mock equivalents
and sets up the addition of MockHttpServerRequest/Response in
spring-test.

Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Rossen Stoyanchev e17132c217 Polish MockServerHttpRequest
Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Rossen Stoyanchev 0681519255 Add checkNotModified support for view resolution
Issue: SPR-14522
2016-09-01 18:07:23 -04:00
Rossen Stoyanchev 6071e01168 Add checkNotModified support in ServerWebExchange
Issue: SPR-14522
2016-09-01 17:44:51 -04:00
Sebastien Deleuze 02bed0a34b Polishing 2016-09-01 17:15:50 +02:00
Sebastien Deleuze 06d4bb6a1a Let users control SSE stream completion
This commit avoid merging automatically the SSE stream with
Flux.never(). Since browsers automatically reconnect when
the HTTP connection is closed, it is now the user responsability
to optionally perform a concatWith(Flux.never()) on streams that
complete in order to avoid receiving the data multiple times on
client side.

The behavior with hot streams that never complete does not change.

Issue: SPR-14578
2016-09-01 17:14:24 +02:00
Arjen Poutsma 16b525f698 Refactored SseEvent to ServerSentEvent
- Renamed SseEvent to ServerSentEvent to make the name less redundant.
 - ServerSentEvent is now immutable, having a builder to create new instances.
 - Realigned the class properties to more closely match the events
   described in the spec, so that `reconnectTime` becomes `retry`, and
   `name` becomes `event`.
2016-09-01 13:47:50 +02:00
Arjen Poutsma 35cf4f173b Copied getAndSub() over from Reactor
Operators.getAndSub was removed in Reactor 3.0.1, this commit copies the
implementation over to AbstractRequestBodyPublisher, which used it.
2016-09-01 11:16:01 +02:00
Juergen Hoeller e08b1b75b6 @PathVariable supports 'required' attribute (for model attribute methods)
Issue: SPR-14646
2016-08-31 14:43:39 +02:00
Juergen Hoeller ab9fea6b8d Polishing
(cherry picked from commit 3767092)
2016-08-31 02:08:31 +02:00
Juergen Hoeller 31c5644691 ResponseStatusExceptionHandler in web.server.handler (plus related polishing) 2016-08-30 23:58:14 +02:00
Juergen Hoeller 03609c1518 Consistent comma splitting without regex overhead
Issue: SPR-14635
2016-08-30 23:56:58 +02:00
Rossen Stoyanchev 391752abc2 Polish and update reactive getting started reference
This commit updates the instructions on getting started with
Spring Web Reactive and also updates constructors and setters to
streamline the getting started procedure.

Issue: SPR-14640
2016-08-30 14:36:19 -04:00
Juergen Hoeller 2aab08f093 Polishing 2016-08-30 12:59:40 +02:00
Juergen Hoeller 58ffca76c3 CommonsMultipartResolver explicitly converts FileSizeLimitExceededException
Issue: SPR-14638
2016-08-30 12:57:46 +02:00
Sebastien Deleuze e8530c917e Add Smile and CBOR Jackson data formats support
This commit adds Smile and CBOR Jackson HttpMessageConverters
and make it possible to create Smile and CBOR ObjectMapper via
Jackson2ObjectMapperBuilder, which now allows to specify any
custom JsonFactory.

Like with JSON and XML Jackson support, the relevant
HttpMessageConverters are automaticially configurered by
Spring MVC WebMvcConfigurationSupport if jackson-dataformat-smile
or jackson-dataformat-cbor dependencies are found in the classpath.

Issue: SPR-14435
2016-08-30 11:06:40 +02:00
Rossen Stoyanchev 3b95e0b6e0 Fix media type regression in resource handling
Issue: SPR-14577
2016-08-29 16:27:24 -04:00
Sebastien Deleuze 417a9d4559 Ensure correct array elements order in Jackson2JsonEncoder
Issue: SPR-14586
2016-08-29 16:22:25 +02:00
Sam Brannen d6d05e8ca0 Remove trailing whitespace in Java source code 2016-08-29 15:25:10 +02:00
Juergen Hoeller dfdfd72a3e Polishing
(cherry picked from commit 430180a)
2016-08-26 18:59:40 +02:00
Brian Clozel b84fefc430 Wrap RestTemplate extractor exceptions in RestClientExceptions
When using a `RestTemplate` instance within a Spring MVC application,
client exceptions may propagate in the MVC stack and can be wrongly
mapped by server `ExceptionHandlers`, leading to a wrong HTTP response
sent to the MVC client.

The `RestTemplate` instance uses `HttpMessageConverter` to decode
the remote service responses; and when those fail decoding an HTTP
response, they can throw an `HttpMessageNotReadableException`. That
exception then bubbles up through the `HttpMessageConverterExtractor`,
`RestTemplate` and the whole MVC stack, later mapped to HTTP 400
responses, since those exceptions can also be throws by the server stack
when the incoming requests can't be deserialized.

This commit wraps all `IOException` and `HttpMessageNotReadableException`
instances thrown by the extractor into `RestClientException`` instances.
It's now easier to consistently handle client exceptions and avoid such
edge cases.

Issue: SPR-13592
2016-08-26 17:56:00 +02:00
Brian Clozel d8fc13f6fc Fix server errors for invalid If-None-Match request headers
HttpEntityMethodProcessor should not throw IllegalArgumentExceptions for
invalid If-None-Match headers.

For those cases, this commit makes sure that both
`HttpEntityMethodProcessor` and `ServletWebRequest` have a consistent
behavior and stop processing the request as conditional and leave the
handler handle it.

Issue: SPR-14559
2016-08-26 15:48:47 +02:00
Juergen Hoeller 2e4a7480fc Consistent use of JDK 7 StandardCharsets over Charset.forName
Issue: SPR-14492
2016-08-26 14:16:19 +02:00
Juergen Hoeller a8f7f75f64 Moved encodeHttpHeaderFieldParam method to HttpHeaders itself (including tests)
This commit also sets the test source encoding to UTF-8.

Issue: SPR-14547
2016-08-26 11:14:02 +02:00
Brian Clozel f93cb2f539 Support ordered interceptors in RestTemplate
This commit sorts `ClientHttpRequestInterceptor`s when those are set in
`InterceptingHttpAccessor` (which `RestTemplate` extends from).

Interceptors can now be annotated with `@Order` or implements `Ordered`
to reflect their order of execution for each request.

Issue: SPR-13971
2016-08-25 17:14:09 +02:00
Arjen Poutsma ab7107c4c5 Added Host property to HttpHeaders
Added getHost/setHost to HttpHeaders, returning/taking a
InetSocketAddress.
2016-08-25 15:49:07 +02:00
Brian Clozel f2faf84f31 Add RFC5987 support for HTTP header field params
This commit adds support for HTTP header field parameters encoding, as
described in RFC5987.
Note that the default implementation still relies on US-ASCII encoding,
as the latest rfc7230 Section 3.2.4 says that:

> Newly defined header fields SHOULD limit their field values to
  US-ASCII octets

Issue: SPR-14547
2016-08-25 14:26:58 +02:00
Juergen Hoeller d9d84ff388 Polishing 2016-08-24 11:40:24 +02:00
Juergen Hoeller d047174c6b Unit test for empty Access-Control-Request-Headers (Chrome 52)
Includes optimized method/header resolution in CorsConfiguration.

Issue: SPR-14617
2016-08-24 11:40:18 +02:00
Brian Clozel e4575330c3 Support empty body in Jackson2JsonDecoder.decodeToMono
Prior to this commit, extracting an HTTP response with an empty body
and no Content-Type header using the WebClient would:

* trigger the use of the Jackson2JsonDecoder
* throw a NoSuchElementException because of the use of `Flux.single()`

This commit changes this behavior to `Flux.singleOrEmpty()` to avoid
throwing exceptions for empty Flux instances.

Issue: SPR-14582
2016-08-23 16:10:41 +02:00
Erik Olsson 64bc0ca744 Add ClientOptions support in ReactorClientHttpConnector
Default ClientOptions enable SSL support.

Issue: SPR-14593
2016-08-23 11:17:12 +02:00
Rob Winch d48c32e7f6 Fix reactor-core 3.0.0.RELEASE
Fix the build to work with reactor-core-3.0.0.RELEASE
2016-08-19 12:56:36 -05:00
Juergen Hoeller 7bb4ab6842 Various @since tags (and varargs on setInterceptors)
(cherry picked from commit 5222489)
2016-08-18 12:58:02 +02:00
Juergen Hoeller ab0d523cc0 Polishing
(cherry picked from commit 1932a9d)
2016-08-17 21:54:40 +02:00
Stephane Nicoll 2a4ee07cb3 Fix typo 2016-08-10 14:23:37 +02:00
Juergen Hoeller 59a24b406a Polishing 2016-08-10 14:20:42 +02:00
Rossen Stoyanchev cc288a0c4a Switch back to Reactor 3.0 snapshots 2016-08-08 16:42:30 -04:00
Juergen Hoeller aeec1245eb ClientWebRequestBuilders documentation fix
Issue: SPR-14561
2016-08-08 13:20:27 +02:00
Sebastien Deleuze 5531e80724 Anticipate reactor.test.TestSubscriber removal
reactor.test.TestSubscriber will not be part of Reactor Core
3.0.0 since it needs to be refactored to fit all the needs
expressed by the users. It is likely to be back later in one
of the Reactor Core 3.0.x releases.

This commit anticipate this removal by temporarily copying
TestSubscriber in spring-core test classes. As soon as
the new TestSubscriber will be available in Reactor Core,
Spring Framework reactive tests will use it again.
2016-08-08 11:24:21 +02:00
Sebastien Deleuze e86529ec90 Prevent StackOverflowError in AbstractJackson2HttpMessageConverter
Issue: SPR-14520
2016-08-04 11:20:38 -07:00
Juergen Hoeller 8109a8c288 Updated ServletHttpHandlerAdapter usage 2016-08-04 03:04:33 +02:00
Arjen Poutsma dfef4e09da Added HttpHandler contructor argument 2016-08-03 15:39:44 -07:00
Kamil Szymanski 4aea551e8e Use abbreviated expression lambda instead of statement lambda
Closes gh-1126
2016-07-30 12:54:59 +02:00
Rossen Stoyanchev d219054b0d Polish 2016-07-27 12:34:31 -04:00
Violeta Georgieva 301528665d Refactor AbstractResponseBodyFlushProcessor states
With the current state machine
- the implementation can hang after the last element when executing
on Jetty.
- in some cases there will be no flush after the last
Publisher<DataBuffer>.
2016-07-27 11:12:00 -04:00
Violeta Georgieva 4798a1eb02 Cancel Subscription when onError is invoked internally
AbstractResponseBodyProcessor.onError and
AbstractResponseBodyFlushProcessor.onError will be invoked when:
- The Publisher wants to signal with onError that there are failures.
Once onError is invoked the Subscription should be considered canceled.
- The internal implementation wants to signal with onError that there
are failures. In this use case the implementation should invoke
Subscription.cancel()
2016-07-27 11:12:00 -04:00
Violeta Georgieva 16939b7bc7 AbstractListenerServerHttpResponse improvements
This commit changes writeWithInternal(Publisher<DataBuffer> body).
It is implemented as writeAndFlushWith(Mono.just(body)).
2016-07-27 11:12:00 -04:00
Juergen Hoeller b9ab895743 Inferred generics for newSetFromMap arrangements
Issue: SPR-13188
2016-07-26 21:26:31 +02:00
Juergen Hoeller e03dea1d64 Polishing 2016-07-26 17:15:19 +02:00
Juergen Hoeller c13f8419f9 Minor revision of reactive support layout (ahead of 5.0 M1)
DataSourceUtils moved to main core.io.buffer package.
Consistently named Jackson2JsonDecoder/Encoder and Jaxb2XmlDecoder/Encoder.
Plenty of related polishing.
2016-07-26 15:39:32 +02:00
Juergen Hoeller c97bfd73ad Reintroduced XMLReaderFactory deprecation markers on JDK 9
Issue: SPR-14486
2016-07-25 14:12:29 +02:00
Sam Brannen 2b6971a20e Clean up deprecation warnings in spring-web 2016-07-23 17:17:50 +02:00
Sam Brannen 76aa7b1cd9 Delete unused imports in spring-web 2016-07-23 17:17:29 +02:00
Sam Brannen cb1b178405 Ensure Reactor & RxJava response extractors compile with Eclipse JDT 2016-07-23 17:15:18 +02:00
Brian Clozel b2e848737c Rename reactor.io.netty -> reactor.ipc.netty 2016-07-23 14:34:12 +02:00
Juergen Hoeller 382a931e7d Polishing 2016-07-22 22:28:20 +02:00
Juergen Hoeller e59a5993f3 Consistent support for multiple Accept headers
Issue: SPR-14506
2016-07-22 22:27:58 +02:00
Brian Clozel 6e54ed0df1 Add missing timeout in web-reactive IntegrationTests 2016-07-22 21:37:51 +02:00
Rossen Stoyanchev 10c90a677c Move http.converter.reactive to http.codec 2016-07-22 14:14:46 -04:00
Arjen Poutsma b0d7625e3e Reactor StringEncoder into CharSequenceEncoder
This commit refactors the StringEncoder to a CharSequenceEncoder, in
order to support StringBuilders, Groovy GStrings, etc.

Issue: https://github.com/spring-projects/spring-reactive/issues/120
2016-07-22 12:47:46 -04:00
Arjen Poutsma 436a98ec68 Polishing 2016-07-22 15:32:56 +02:00
Marius Grama 3635c9dbfe Update xmlunit library to version 2.1.0
xmlunit 2.1.0 is the latest release for xmlunit.
Most of the xmlunit functionality used within spring-framework
was done through the xmlunit 1.x helper class
`org.custommonkey.xmlunit.XMLAssert`.

As of xmlunit 2.0.0 most of the XML comparison methods are done
through hamcrest matchers exposed by the xmlunit-matchers
library. In some cases during the migration, the matchers
had to be customized with custom `NodeMatcher` or
`DifferenceEvaluator` instances in order to keep the assertions
correct (they were performed with xmlunit 1.x previously).

Issue: SPR-14043
2016-07-21 15:04:21 +02:00
Sebastien Deleuze 9fb8a2eb2e Add contextClass resolution to JacksonJsonDecoder
Issue: SPR-14158
2016-07-21 14:57:50 +02:00
Sebastien Deleuze 74158af1b9 Add JsonView and type resolution support to JacksonJsonDecoder
There is no contextClass support yet, we need to find a way to pass
this information to the codecs.

Issue: SPR-14158
2016-07-21 13:55:59 +02:00
Sebastien Deleuze 903770f008 Add JsonView and type resolution support to JacksonJsonEncoder
Issue: SPR-14158
2016-07-21 13:19:52 +02:00
Brian Clozel 4d035e3ab1 Update Google Protobuf support to 3.0.0
This commit adds support for Google Protobuf 3.0.0 and make some changes
in the additional formats support:
* "com.googlecode.protobuf-java-format:protobuf-java-format" is no
longer required and its required version has been raised to 1.3+
(this lib adds support for JSON, XML, HTML formats)
* "com.google.protobuf:protobuf-java-util" is also now supported for
JSON format

Issue: SPR-13589
2016-07-21 11:38:56 +02:00
Arjen Poutsma 7b2196b408 Add writeAndFlushWith to ReactiveHttpOutputMessage
This commit changes the reactive flushing mechanism to use a newly
introduced writeAndFlushWith(Publisher<Publisher<DataBuffer>>) on
ReactiveHttpOutputMessage instead of using the FlushingDataBuffer.

Issue: https://github.com/spring-projects/spring-reactive/issues/125
2016-07-21 11:08:54 +02:00
Juergen Hoeller 28e7c11234 Polishing 2016-07-20 22:41:56 +02:00
Sebastien Deleuze 3a4e5d5da8 Fix ParameterizedType + contextClass support in Jackson converter
Issue: SPR-14470
2016-07-20 09:29:23 +02:00
Rossen Stoyanchev b52b56c94e Update to the latest Reactory Netty snapshot 2016-07-19 21:11:07 -04:00
Juergen Hoeller 99be15f58b Revise encoding steps towards use of JDK Charset and StandardCharsets
Issue: SPR-14492
2016-07-19 23:43:06 +02:00
Juergen Hoeller 79d30d8c8a Polishing 2016-07-19 23:42:32 +02:00
Juergen Hoeller adc595b5f1 Avoid dependency on WebUtils for extracting file extension
Issue: SPR-14479
2016-07-19 23:30:33 +02:00
Rossen Stoyanchev 86c659f5c0 Remove isAsyncStarted assertion
Issue: SPR-14444
2016-07-19 16:43:03 -04:00
Juergen Hoeller a4743c07d4 Polishing 2016-07-19 20:09:00 +02:00
Juergen Hoeller 88fcd0a2ed Framework build compatible with JDK 9 (tests running against java.base module)
Issue: SPR-13344
2016-07-19 19:37:34 +02:00
Juergen Hoeller aaac199e8b Consistently use constructor-based instantiation instead of Class.newInstance / BeanUtils.instantiate
Issue: SPR-14486
2016-07-19 19:21:06 +02:00
Juergen Hoeller 8bb34bc962 Resource.isFile() and JAF MediaTypeFactory
Issue: SPR-14484
2016-07-19 18:53:31 +02:00
Rossen Stoyanchev 4b92bf2af1 Split HttpMessageConverter into ~Reader and ~Writer 2016-07-18 22:16:35 -04:00
Brian Clozel dca80788d4 Fix default origin port in ReactorClientHttpConnector
This commit ensures that a valid port is given to the underlying Netty
client when no port is defined in the URL itself.

By default, port 80 is used by the Reactor Netty client.

Issue: SPR-14477
2016-07-18 21:53:15 +02:00
Rossen Stoyanchev 3e096ce810 Improve javadoc on reactive classes
Ensure type-level Javadoc in every class, comply with guidelines for
80 char on Javadoc, and minor polish.
2016-07-18 14:59:15 -04:00
Brian Clozel 7a0c2422c6 Add client-side exception hierarchy
The `WebClient` has a new exception hierarchy:

* `WebClientException` is the root of all exceptions thrown by the
`WebClient`
* `WebClientResponseException` are all exceptions associated with
specific HTTP response status codes
* `WebClientErrorException` and `WebServerErrorException` are
respectively for 4xx and 5xx HTTP status codes

`ResponseExtractor` implementations are adapted to optionally throw
exceptions if it's impossible to extract the relevant parts of the
response (e.g. extracting the response body if the response is a 404).

This commit also introduces `ResponseErrorHandler`s that take care of
the whole exception mapping infrastructure. Since
`WebClientResponseException`s provide the status, headers and response
body, we also need a dedicated mechanism to extract information from the
response body at that level.

The `BodyExtractors` are responsible for extracting that information
from the exception, given they are provided with all the information
they need; in that case, message decoders are required.

To convey all this new information downstream, the `WebClient` now wraps
the message converters and response error handler instances into a
dedicated `WebClientConfig` object.
2016-07-18 17:33:15 +02:00
Rossen Stoyanchev 028be2a298 Switch to Reactor 3 snapshots and Netty 4.1.3 2016-07-15 17:16:26 -04:00
Juergen Hoeller dc1664939c Javadoc fixes and pruning of outdated references 2016-07-15 22:12:11 +02:00
Juergen Hoeller f0c397e4e2 Comprehensive Servlet 3.1 support in spring-web and spring-test
Issue: SPR-14467
2016-07-15 22:11:14 +02:00
Sam Brannen 3f317b7d3f Clean up warnings in spring-web 2016-07-15 18:38:27 +02:00
Sam Brannen 58804da369 Polish Reactor & RxJava response extractors 2016-07-15 17:54:24 +02:00
Sam Brannen 1731460eac Ensure Reactor & RxJava response extractors compile with Eclipse JDT 2016-07-15 17:53:15 +02:00
Rossen Stoyanchev d2e105f28d Add @Since 5.0 and package-info for reactive classes 2016-07-14 17:40:17 -04:00
fisache 9aa35a8b5f Polish doc
Closes gh-1108
2016-07-14 19:15:38 +02:00
Arjen Poutsma 3e47fccf2b Propagate IOExceptions in Servlet bridge 2016-07-14 12:30:35 -04:00
Arjen Poutsma 4390cd0c2b Fixed Jaxb2CollectionHttpMessageConverterTests
- Added Woodstox before Aalto in the spring-web build, so that Woodstox
   is used as StAX implementation, and not the less featured Aalto.
 - Hardcoded Aalto dependency in XmlEventDecoder, instead of relying on
   the StAX XMLInputFactory.
2016-07-14 12:30:35 -04:00
Rossen Stoyanchev 5d1b542698 Move spring-web-reactive classes to spring-web 2016-07-14 12:30:35 -04:00
Juergen Hoeller 84afc601b8 Configurable UrlPathHelper in PathExtensionContentNegotiationStrategy
This commit also aligns ResourceUrlProvider's and RequestMappingInfo's UrlPathHelper setter/getter signatures.

Issue: SPR-14454
2016-07-13 15:14:42 +02:00
Juergen Hoeller a1f5fb53db Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
2016-07-07 01:04:24 +02:00
Juergen Hoeller da9c24c41e Polishing 2016-07-06 18:11:33 +02:00
Juergen Hoeller 102dc8a4dd Polishing 2016-07-06 15:29:15 +02:00
Stephane Nicoll e4b0486c5a Add @FunctionalInterface on candidate interfaces
Issue: SPR-14432
2016-07-06 14:32:13 +02:00
Sam Brannen 1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Stephane Nicoll 00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Juergen Hoeller b5db5d3aac Broadly remove deprecated core classes and methods
Issue: SPR-14430
2016-07-05 15:52:49 +02:00
Juergen Hoeller 0fc0ce78ae Drop deprecated dependencies on Log4j, JRuby, JExcel, Burlap, Commons Pool/DBCP
This commit also removes outdated support classes for Oracle, GlassFish, JBoss.

Issue: SPR-14429
2016-07-05 15:46:53 +02:00
Juergen Hoeller 51252ebbca Avoid defensive checks against Java 8 API (java.util.Optional etc)
This commit also fixes broken javadoc links and code references.

Issue: SPR-13188
2016-07-05 02:09:00 +02:00
Juergen Hoeller 2b3445df81 Drop Portlet MVC support
This commit also removes the corresponding deprecated Servlet MVC variant and updates DispatcherServlet.properties to point to RequestMappingHandlerMapping/Adapter by default.

Issue: SPR-14129
2016-07-04 23:33:47 +02:00
Juergen Hoeller ae0b7c26c5 Drop Servlet 2.5 runtime compatibility
Issue: SPR-13189
2016-07-04 23:31:21 +02:00
Juergen Hoeller ccf791b63f Deprecate OkHttp 2.x support
Issue: SPR-14344
2016-07-04 23:23:28 +02:00
Juergen Hoeller 447835465f Remove support for deprecated AbstractHttpClient class
Issue: SPR-14422
2016-07-04 23:21:42 +02:00
Stephane Nicoll 037746da44 Polish
Closes gh-1097
2016-07-01 14:26:48 +02:00
Juergen Hoeller 1c73664c40 Defensively access deprecated AbstractHttpClient class from Apache HttpComponents
Issue: SPR-14422
2016-07-01 14:11:26 +02:00
Juergen Hoeller 66ec1c1618 Add missing package-info files for common packages
Issue: SPR-14420
2016-06-30 21:39:06 +02:00
Juergen Hoeller 772bc030ee BasicAuthorizationInterceptor belongs to http.client.support
Issue: SPR-14412
2016-06-29 10:41:18 +02:00
Stephane Nicoll db963bc556 Add BasicAuthorizationInterceptor
This commit adds a `ClientHttpRequestInterceptor` that applies a BASIC
authorization header for each request.

It can be used as follows:

```
BasicAuthorizationInterceptor basicAuthorization =
    new BasicAuthorizationInterceptor("user", "secret");
restTemplate.getInterceptors().add(basicAuthorization);
```

Issue: SPR-14412
2016-06-28 17:29:04 +02:00
Rossen Stoyanchev 2cdcf752ba MvcUriComponentsBuilder respects optional params
Issue: SPR-14405
2016-06-27 16:02:54 -04:00
Rossen Stoyanchev e38623df87 Fix MediaType lookup for ResourceHttpRequestHandler
As of 4.3 ResourceHttpRequestHandler delegates to the configured
ContentNegotiationManager, or one created internally, to look up
the media type for are resource.

This commit ensures the internally created ContentNegotiationManager is
correctly injected with the ServletContext through which it can perform
lookups as before.

Also the ServletPathContentNegotiationStrategy now checks the
ServletContext first and then delegates to its parent the
PathContentNegotiationStrategy and not vice versa. This is
consistent with how handleNoMatch (also in the same class) works
and also matches how ResourceHttpRequestHandler worked before 4.3.

Issue: SPR-14368
2016-06-27 14:56:55 -04:00
Juergen Hoeller 15c96b8efd ServletResponseHttpHeaders consistently overrides HttpHeaders again
Issue: SPR-14406
2016-06-27 15:33:53 +02:00
Rossen Stoyanchev 919f6c96f9 ForwardedHeaderFilter is case-insensitive
Issue: SPR-14372
2016-06-17 14:20:42 -04:00
Juergen Hoeller dcb2c73102 MultipartResolutionDelegate skips Part parameter checks on Servlet 2.5
Issue: SPR-14358
2016-06-14 22:48:51 +02:00
Juergen Hoeller 1dfc0ffd43 SpringHandlerInstantiator supports all HandlerInstantiator-provided factory methods
Issue: SPR-14347
2016-06-09 17:02:39 +02:00
Juergen Hoeller a211d1472e Polishing 2016-06-08 15:22:01 +02:00
Juergen Hoeller cc7781ecf3 FormHttpMessageConverter's charset (and its UTF-8 default) applies to part converters as well
Issue: SPR-14338
2016-06-08 13:58:44 +02:00
Juergen Hoeller 8fc84e2d6f Upgrade to Jackson 2.8 RC1, Undertow 1.4 CR1, Netty 4.1.1
Issue: SPR-14340
Issue: SPR-14328
Issue: SPR-14143
2016-06-08 09:47:51 +02:00
Juergen Hoeller 981c894acf @ExceptionHandler matches against cause type as well
Issue: SPR-14291
2016-06-07 21:22:01 +02:00
Juergen Hoeller 31aed61d15 CorsFilter asserts presence of CorsConfigurationSource 2016-06-07 16:49:23 +02:00
Juergen Hoeller 8c4bc3656b Polishing 2016-06-07 15:42:16 +02:00
Juergen Hoeller 6807bcb863 Fixed @since references after SPR-14080 backport
Issue: SPR-14305
(cherry picked from commit 9a41774)
2016-06-07 13:38:17 +02:00
Juergen Hoeller c412eabb00 Jackson2ObjectMapperBuilder/FactoryBean accepts deserializers by handled type
Issue: SPR-14337
2016-06-07 12:50:00 +02:00
Juergen Hoeller abcfffdde9 Allow JAXB to be registered next to plain Jackson
Issue: SPR-14336
2016-06-07 12:36:17 +02:00
Rossen Stoyanchev c2a50ad1bf Fine-tune X-Forwarded header in ForwardedHeaderFilter
The contextPathOverride property is now gone.
X-Forwarded-Header (if present) is used instead of the contextPath.

Issue: SPR-14270
2016-06-06 12:37:22 -04:00
Juergen Hoeller 521c41d75e Polishing 2016-06-02 17:02:44 +02:00
Juergen Hoeller 7de61f80a7 AbstractRequestLoggingFilter supports logging of request headers
Issue: SPR-14245
2016-06-02 11:41:24 +02:00
Juergen Hoeller ea728b15c8 Polishing 2016-06-01 22:01:32 +02:00
Rossen Stoyanchev c74d979735 Rename contextPath method in ForwardedHeaderFilter 2016-06-01 15:45:44 -04:00
Rossen Stoyanchev 1f3ac340fa Polish X-Forwarded-Prefix handling
Issue: SPR-14270
2016-06-01 15:33:19 -04:00
Eddú Meléndez 7ee687c798 Support X-Forwarded-Prefix in ForwardedHeaderFilter
See SPR-14270
2016-06-01 14:28:19 -04:00
Rossen Stoyanchev 92f1b69e8c Update MultipartFilter documentations
Issue: SPR-11373
2016-05-31 12:42:32 -04:00
Juergen Hoeller f7f2327f60 ServletServerHttpRequest.getHeaders() ignores invalid content type
Issue: SPR-14309
2016-05-29 13:22:00 +02:00
Johnny Lim ace624a01a Polish Javadoc in MediaType
Closes gh-1064
2016-05-25 09:23:27 +02:00
Rossen Stoyanchev 400206a2fe Update @RestController javadoc
Issue: SPR-13945
2016-05-22 09:06:23 -04:00
Juergen Hoeller 5682950289 Polishing 2016-05-06 12:03:10 +02:00
Juergen Hoeller 42d32ba396 ResourceRegion fits better in core.io.support (next to EncodedResource)
Issue: SPR-14221
2016-05-06 12:02:51 +02:00
Juergen Hoeller 08ddd1b3bc AbstractRequestLoggingFilter ignores non-available query string
Issue: SPR-14244
2016-05-04 18:17:06 +02:00
Sam Brannen 7b13311f03 Delete unused imports 2016-05-03 20:12:37 +02:00
Sam Brannen 6b3eba0500 Suppress warnings in Gradle build 2016-05-03 19:56:33 +02:00
Juergen Hoeller 52e5b4a6ff Polishing 2016-05-03 18:55:39 +02:00
Juergen Hoeller 76964e16ef Explicit note on Java deserialization 2016-05-03 18:44:37 +02:00
Brian Clozel 05b29a4a17 Add convenient getters for force*Encoding attributes
Issue: SPR-14240
2016-05-03 16:14:09 +02:00
Brian Clozel 76ee46847a Selectively force encoding in CharacterEncodingFilter
Prior to this commit, setting the `forceEncoding` option would force
encoding on both requests and responses.

This commit adds two new setters and a new constructor to differentiate
both options: forcing the encoding on the request and/or on the
response.

You can now define this filter programmatically using those options or
update your servlet XML configuration like:

```
<filter>
  <filter-name>characterEncodingFilter</filter-name>
  <filter-class>o.sf.web.filter.CharacterEncodingFilter</filter-class>
  <init-param>
     <param-name>encoding</param-name>
     <param-value>UTF-8</param-value>
  </init-param>
  <init-param>
    <param-name>forceRequestEncoding</param-name>
    <param-value>true</param-value>
  </init-param>
  <init-param>
    <param-name>forceResponseEncoding</param-name>
    <param-value>false</param-value>
  </init-param>
</filter>

```

Issue: SPR-14240
2016-05-03 14:47:22 +02:00
Brian Clozel 5ac31fb39d Refactor HTTP Range support with ResourceRegion
Prior to this commit, the `ResourceHttpMessageConverter` would support
all HTTP Range requests and `MethodProcessors` would "wrap" controller
handler return values with a `HttpRangeResource` to support that use
case in Controllers.

This commit refactors that support in several ways:
* a new ResourceRegion class has been introduced
* a new, separate, ResourceRegionHttpMessageConverter handles the HTTP
range use cases when serving static resources with the
ResourceHttpRequestHandler
* the support of HTTP range requests on Controller handlers has been
removed until a better solution is found

Issue: SPR-14221, SPR-13834
2016-05-02 19:00:52 +02:00
Brian Clozel 29da44c8dc Support ETags with special chars in ServletWebRequest
This commit makes sure that HTTP request headers containing ETag values
are properly parsed and not simply tokenized using a "," separator.
Indeed, ETags can legally contain separator characters such as " " and
",".

Issue: SPR-14216
2016-04-29 11:20:29 +02:00
Brian Clozel 55dae618a6 Improve multi-valued HTTP headers support
Prior to this change, getting header values with `HttpHeaders` when
headers are multi-valued would cause issues.
For example, for a given HTTP message with headers:
    Cache-Control: public, s-maxage=50
    Cache-Control: max-age=42

Getting a `List` of all values would return <"public", "s-maxage=50">
and getting the header value would return "public, s-maxage=50".

This commit takes now into account multi-valued HTTP headers and adds
new getters/setters for "If-Match" and "If-Unmodified-Since" headers.

Note that for ETag-related headers such as "If-Match" and
"If-None-Match", a special parser has been implemented since ETag values
can contain separator characters.

Issue: SPR-14223, SPR-14228
2016-04-28 18:48:47 +02:00
Juergen Hoeller 9412f7a094 InstantFormatter accepts RFC-1123 values as well
Issue: SPR-14201
2016-04-28 14:35:33 +02:00
Rossen Stoyanchev 335d968f85 Polish DefaultUrlTemplateHandler 2016-04-27 08:55:52 -04:00
Brian Clozel a50ea80e4e Handle multiple conditional request headers
Prior to this change, setting both "If-None-Match" and
"If-Unmodified-Since" conditional request headers would check for both
conditions to be met.

This commit fixes this behavior to follow the RFC7232 Section 6:
> entity tags are presumed to be more accurate than date validators

So in case both conditions are present, the "If-None-Match" condition
takes precedence.

Issue: SPR-14224
2016-04-27 12:02:33 +02:00
Juergen Hoeller d06188ed4d ResponseEntity allows for setting non-standard status code
Issue: SPR-14205
2016-04-26 23:06:10 +02:00
Juergen Hoeller e5d52a96a7 HttpSessionRequiredException programmatically exposes name of expected attribute
Issue: SPR-14206
2016-04-26 23:06:10 +02:00
Rossen Stoyanchev 538c582342 Extract AbstractUriTemplateHandler base class
Issue: SPR-14147
2016-04-26 13:32:35 -04:00
Juergen Hoeller f73df2e138 SpringServletContainerInitializer does not log WebApplicationInitializer class names
Issue: SPR-14213
2016-04-26 17:09:57 +02:00
Venil Noronha b2c9c8abcf Add text/markdown MediaType constant
Issue: SPR-14192
2016-04-25 09:57:30 -04:00
Sam Brannen 920eba79f8 Polish Javadoc for DefaultUriTemplateHandler 2016-04-23 16:49:04 +02:00
Rossen Stoyanchev 065b7968a3 Add defaultUriVariables property to RestTemplate
Issue: SPR-14147
2016-04-22 16:21:23 -04:00
Rossen Stoyanchev 0d007a328b Polish DefaultUriTemplateHandler 2016-04-22 16:21:18 -04:00
Johnny Lim 44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Juergen Hoeller f1cb793ccb Rename MimeType's getCharSet() to getCharset()
Issue: SPR-14172
2016-04-14 16:38:59 +02:00
Juergen Hoeller 977734cc59 Upgrade to Protobuf Java Format 1.4
Issue: SPR-14171
2016-04-14 15:44:53 +02:00
Juergen Hoeller 62ce9afe3a Jackson-based message converters consistently check media type first
Issue: SPR-14163
2016-04-14 14:26:05 +02:00