Commit Graph

3050 Commits

Author SHA1 Message Date
Rossen Stoyanchev 6df1a7874a MockHttpServletResponse uses correct language header
Issue: SPR-16311
2017-12-19 13:56:16 -05:00
Arjen Poutsma 8e253a316d Support top-level scalar values in Jackson2Tokenizer
Issue: SPR-16166
2017-12-14 16:44:40 +01:00
Juergen Hoeller 05988193b7 Upgrade to Jackson 2.9.3 and Netty 4.1.18 2017-12-13 17:55:50 +01:00
sdeleuze 6a7b197af7 Improve Jackson codecs documentation 2017-12-13 12:07:43 +01:00
sdeleuze 73a81f98d4 Allow interceptors to add existing header values
Additional commit to provide support of requests
that have a body.

Issue: SPR-15066
2017-12-13 10:08:24 +01:00
Rossen Stoyanchev f05175586e Refine behavior on error after response committed
If the response is set and we can't change the status through
ServerHttpResponse any more, allow the error signal to propagate and
let the individual server adapters handle it. Ultimately that should
result in closing the connection.

On Servlet containers, we check one last time if the response is
committed (we may not have filled the buffer). If not then save
the exception as a request attribute, dispatch, and re-throw it on the
container thread.

On Undertow access the connection and close it.

On Netty just let the error through to Reactor Netty.

Issue: SPR-16051
2017-12-12 14:51:24 -05:00
Christoph Dreis 260ebeca3a Improve performance of some string operations
Issue: SPR-16293
2017-12-12 17:14:24 +01:00
sdeleuze 554662ebab Allow interceptors to add existing header values
Provide a fully mutable HttpHeaders to ClientHttpRequestInterceptors
of a RestTemplate when headers are set using HttpEntity. This avoids
UnsupportedOperationException if both HttpEntity and
ClientHttpRequestInterceptor add values for the same HTTP header.

Issue: SPR-15066
2017-12-11 15:01:20 +01:00
Juergen Hoeller d198626618 Upgrade to Gradle 4.4 (and Apache HttpClient 4.5.4)
Issue: SPR-16237
2017-12-07 07:28:07 +01:00
Rossen Stoyanchev 203370a810 Handle absolute URI in Reactor request.uri()
The request URI returned from HttpServerRequest.uri() typically
contains contains an absolute path but could also contain an
absolute URI. This commit adds handling for the latter, effectively
taking only the absolute path portion.

Issue: SPR-16243
2017-12-01 23:34:35 -05:00
Rossen Stoyanchev b9a1168580 Consistently return null if certificates not available
Issue: SPR-16244
2017-12-01 21:38:40 -05:00
Rossen Stoyanchev e99b0038a0 Polish 2017-12-01 21:18:13 -05:00
Rossen Stoyanchev dd0d270ba2 Improve error handling when response is committed
ResponseStatusExceptionHandler lets the error through if it can't
change the status while HttpWebHandlerAdapter logs a more helpful
message (including status code) but without a full stack trace.

Issue: SPR-16231
2017-11-29 12:39:06 -05:00
Juergen Hoeller 873cb4e58b Remove unnecessary deprecation suppression 2017-11-29 15:44:08 +01:00
Sam Brannen 2b68212c20 Fix grammar 2017-11-29 14:44:21 +01:00
Rossen Stoyanchev 3650ecc3bb Polish 2017-11-28 22:16:07 -05:00
Rossen Stoyanchev dc3d834026 Refinements related to a committed response
1. setComplete checks the isCommitted flag to avoid an unnecessary
debug message. This method is meant to be safe to call many times.

2. setStatusCode lowers log message to TRACE, since the return value
communicates the outcome it's arguably much less critical.

3. Add comment and test case for ResponseStatusExceptionHandler.
A ResponseStatusException is clearly meant to be handled by this
handler so don't let it pass through even if the respones is
committed.

Issue: SPR-16231
2017-11-27 16:31:49 -05:00
Juergen Hoeller a8323f6a27 Latest dependency updates (OkHttp 3.9.1, JRuby 9.1.14, Rome 1.9) 2017-11-26 16:03:48 +01:00
sdeleuze 3b96690e69 Add missing RestOperations extensions
Issue: SPR-16229
2017-11-23 22:12:03 +01:00
Rossen Stoyanchev 01a82b5291 Improve semantics writing currentData
Before this commit, the return value from write was interpreted as the
data being fully written and ready to be released via releaseData().

This is not true for WebSocketSession implementations where a true
return value simply means the message was sent with the full payload
but releas is not appropriate until a send confirmation.

Technically not an issue since WebSocketSession's extending this do
not use pooled buffers. Nevertheless this commit refines the semantics
of write, removes the releaseData() method, and makes sub-classes
responsible for releasing the buffer when fully written (and they
know best when that is). As a bonus currentData is now private.

Issue: SPR-16207
2017-11-23 10:55:03 -05:00
Rossen Stoyanchev 102a0ad792 Polish 2017-11-23 10:22:35 -05:00
Rossen Stoyanchev c1b191edb0 Polish and improve logging 2017-11-22 23:25:36 -05:00
Rossen Stoyanchev afdca285e5 Avoid resume-suspend race condition
This commit turns suspendReading() into a readingPaused() notification
that is invoked after a succession of reads stops because there is no
more demand. Sub-classes can use this notification to suspend, if that
applies to them.

Most importantly the notification is guaranteed not to overlap with
checkOnDataAvailable() which means that suspend does not need to be
atomic and guarded against resume. The two can and do compete all the
time when reading ends with no demand, and a request for demand arrives
concurrently.

Issue: SPR-16207
2017-11-22 17:48:03 -05:00
sdeleuze 4a87d3da7b Set Vary: Origin on CORS unauthorized response
Issue: SPR-16224
2017-11-22 22:46:53 +01:00
sdeleuze 652e5c5584 Disable CORS credentials by default
Access-Control-Allow-Credentials CORS header, used to
allow cookies with CORS requests, is not set to true
anymore by default when enabling CORS with
@CrossOrigin or global CORS configuration in order to
provide a more secured default CORS configuration.

The related allowCredentials property now requires to
be set to true explicitly in order to support cookies
with CORS requests.

Issue: SPR-16130
2017-11-22 22:46:44 +01:00
Rossen Stoyanchev b7c924cac1 Polish 2017-11-21 23:20:13 -05:00
Rossen Stoyanchev 06b2ab3908 Use volatile for subscriber in base publishers
Issue: SPR-16207
2017-11-21 22:57:15 -05:00
Rossen Stoyanchev 3c2d1862f1 Light refactoring/polish in reactive read/write bridge
Issue: SPR-16207
2017-11-21 21:46:30 -05:00
Violeta Georgieva 2a481c5411 Fix race conditions in AbstractListenerReadPublisher
Transition from DEMAND->NO_DEMAND:
Two concurrent threads enter DEMAND.request and DEMAND.onDataAvailable.
And DEMAND.onDataAvailable finishes before DEMAND.request to be able to
update the demand field then a request for reading will be lost.

Transition from READING->NO_DEMAND:
readAndPublish() returns false because there is no demand but before
switching the states READING.request is invoked again a request for
reading will be lost.

Changing READING->DEMAND/NO_DEMAND is made conditional so that the
operations will be executed only if changing states succeeds.

When in READING state detect completion before each next item in order
to exit sooner, if completed.

Issue: SPR-16207
2017-11-21 14:44:46 -05:00
Violeta Georgieva b814875211 Fix race condition in transition from UNSUBSCRIBED->COMPLETED
- Ensure completion signal (normal/exception) will be delivered to
the subscriber when transition from UNSUBSCRIBED->COMPLETED

- According to the specification "Publisher.subscribe MUST call onSubscribe
on the provided Subscriber prior to any other signals to that Subscriber" so
ensure onComplete/onError signals will be called AFTER onSubscribe signal.

Issue: SPR-16207
2017-11-21 14:44:01 -05:00
Violeta Georgieva 41b13a4e8a Ensure onComplete/onError events will be delivered
Issue: SPR-16207
2017-11-21 14:42:05 -05:00
Juergen Hoeller 0cc644f61f Polishing 2017-11-21 16:34:08 +01:00
sdeleuze 9f1d8517ba Polish Kotlin source code style 2017-11-21 15:59:23 +01:00
Juergen Hoeller 40dacd3c1c Polishing 2017-11-20 22:27:07 +01:00
Juergen Hoeller 040aae5309 Upgrade to Protobuf 3.5 and Apache Johnzon 1.1.5 2017-11-20 12:49:25 +01:00
Andy Clement 508aea8a47 Rework implementation of PathPattern.extractPathWithinPattern
This commit changes the implementation of the PathPattern
extractPathWithinPattern method that used an old AntPathMatcher
derivative to a new version that integrates more closely with
PathContainer.

It also introduces consistency in a couple of areas. The javadoc
is updated to specify this but basically:
- the response from the extra method will have all leading
  and trailing separators removed.
- the response will have multiple adjacent separators within the
  reponse reduced to just one.  (For example response would be
  aaa/bb/cc and not aaa///bbb//cc)
If your response would start or finish with multiple separators, they
are all removed.

Issue: SPR-16120
2017-11-17 12:03:17 -08:00
Violeta Georgieva 0fbfa64385 UndertowServerHttpRequest: suspend reading when no demand
- When there is no demand for reading, the implementation
should suspend reading otherwise useless events will be
send by Undertow to the registered read listener.
- There is not need to wait for an event for reading/writing after calling
resumeReads/resumeWrites
2017-11-16 16:15:55 +01:00
Rossen Stoyanchev 19a9bc4747 Remove unnecessary assertion
Issue: SPR-16201
2017-11-15 16:04:32 -08:00
Rossen Stoyanchev e818b904ad Polish WebSocket-related 2017-11-13 23:20:01 -05:00
Juergen Hoeller 72f20e8d4f Polishing 2017-11-11 00:37:50 +01:00
Rossen Stoyanchev 87375fe6f8 ServerHttpRequest exposes SSL certificates
Issue: SPR-15964
2017-11-10 16:43:12 -05:00
Juergen Hoeller 780993ce75 Polishing 2017-11-10 20:21:26 +01:00
Juergen Hoeller de782026c4 Explicitly document UriTemplate as thread-safe
Issue: SPR-16173
2017-11-10 20:20:23 +01:00
Rossen Stoyanchev a5103307c6 Polish ErrorArgumentResolver 2017-11-10 10:15:46 -05:00
Rossen Stoyanchev 807297f173 Remove RxNetty (from test sources)
Practically no changes to RxNetty for a year and efforts underway to
rebuild 0.6.x based on a current Reactor Netty base.

Aside from the extra time to run integration tests having two
Netty-based servers can also cause false alarms such as ByteBuf leaks
related to RxNetty.
2017-11-09 15:56:56 -05:00
Rossen Stoyanchev 369d33c3d0 Support charset config by (static) resource location
This commit adds support for configuring static resource locations
with a charset to be applied to relative paths.
2017-11-09 13:15:06 -05:00
Rossen Stoyanchev 840ef46a9f Polish
Also remove ErrorDeferredResultProcessingInterceptor which was meant
to be package private to begin with as its peer
ErrorCallableProcessingInterceptor (also removed).
2017-11-08 23:15:31 -05:00
Rossen Stoyanchev 9786750b5a Improve @RequestAttribute WebFlux resolver
The resolver now takes into account the possibility the attribute
itself may be a reactive type.

Issue: SPR-16158
2017-11-06 21:44:45 -05:00
Rossen Stoyanchev 14f02d7192 Update reference with examples of multipart requests
Issue: SPR-16118
2017-11-06 16:33:58 -05:00
Arjen Poutsma af2e296ff3 Javadoc 2017-11-06 16:00:18 +01:00
Arjen Poutsma 2d1f87501c Add MultipartBodyBuilder
This commit introduces the MultipartBodyBuilder, a builder for multipart
form bodies.

Issue: SPR-16134
2017-11-06 10:42:11 +01:00
Juergen Hoeller e5c1deea63 Polishing 2017-11-05 16:23:30 +01:00
Juergen Hoeller 80a0cf71f4 MockHttpServletResponse.getDateHeader returns -1 for non-existent header
Includes consistent getDateHeader results in both MockHttpServletResponse variants (spring-test and spring-web)

Issue: SPR-16160
2017-11-05 16:12:21 +01:00
Juergen Hoeller 0edf4d6509 MockHttpServletRequest.getRequestURL aligns with getServerName/Port
Issue: SPR-16138
2017-11-05 16:11:21 +01:00
Juergen Hoeller 996d747aed Upgrade to Mockito 2.11
Includes fixes for invalid exception declarations in Mockito-based unit tests. Also includes FreeMarker 2.3.27, Commons Pool 2.4.3, JSON-P 1.1.2.

Issue: SPR-16157
2017-11-04 01:06:59 +01:00
Rossen Stoyanchev ef39092b3b UriUtils#encodUriVariables methods are now public 2017-11-03 08:21:55 -04:00
Rossen Stoyanchev 4534c5fbfc AbstractReactiveWebInitializer supports Servlet mapping
Issue: SPR-16155, SPR-16144
2017-11-02 21:03:09 -04:00
Rossen Stoyanchev 8c33ed02b3 ServletHttpHandlerAdapter supports Serlvet path mapping
Issue: SPR-16155
2017-11-02 20:53:26 -04:00
Rossen Stoyanchev aa653b23bc Add AbstractReactiveWebInitializer
This commit introduces a new AbstractReactiveWebInitializer in
spring-web that relies on WebHttpHandlerBuilder to detect request
processing infrastructure beans from an ApplicationContext.

This eliminates the need to create a DispatcherHandler, since it is
expected to be a Spring bean, and as a result the initializers in
spring-webflux have been deprecated.

Issue: SPR-16144
2017-11-02 14:57:06 -04:00
Norman Soetbeer 4dee333a75 Allow empty usernames for BasicAuth
The RFCs around basic authentication don't explicitly disallow empty
usernames. On the other hand usernames containing colons are, as colons
are used to separate the username from the password.
2017-11-02 09:59:14 -05:00
Rossen Stoyanchev 579328bd7a MockClientHttpRequest|Response support cookie headers
Issue: SPR-16124
2017-10-31 12:08:18 -04:00
Juergen Hoeller d06129debd InterceptingHttpAccessor uses internal ArrayList for sorting
Also caches InterceptingClientHttpRequestFactory (if applicable)

Issue: SPR-16137
2017-10-31 16:33:38 +01:00
Rossen Stoyanchev 8083eaae54 syncBody better differentiates plain vs multipart forms
FromHttpMessageWriter and MultipartHttpMessageWriter both support
MultiValueMap except the former supports String values only. This
presents an issue since either full generic type information must be
provided, which is cumbersome on the client side, or if left out there
is no good way to order the writers to make a proper decision.

This commit:

- refines the canWrite behavior of   to not a
accept MultiValueMap without proper generic information unless the
MediaType is explicitly set providing a strong hint.

- modifies MultipartHttpMessageWriter to be configured with a
FormHttpMessageWriter so it can write both plan and multipart data with
the ability to properly differentiate based on actual map values.

Issue: SPR-16131
2017-10-31 09:12:05 -04:00
Arjen Poutsma 49787493a6 Proper Undertow PooledByteBuffer release
This commit changes the way Undertow's PooledByteBuffers are dealt with.
Previously, these buffers where closed as soon as all data was read. As
of this commit, the UndertowServerHttpRequest returns PooledDataBuffers
from getBody(), so that the buffers are released when release() is
called.
2017-10-30 10:39:18 +01:00
Juergen Hoeller d963597ec0 Test with hasError for unknown status code
Issue: SPR-16108
2017-10-24 15:51:29 +02:00
Sebastien Deleuze 1c256a112b Parse correctly ContentDisposition header with semicolons
Issue: SPR-16091
2017-10-23 23:09:14 +02:00
Juergen Hoeller ecea82d3a5 Polishing 2017-10-23 17:14:09 +02:00
Rossen Stoyanchev 1cc5afe24b Fix lines over 120 characters
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style#line-wrapping
2017-10-20 16:42:26 -04:00
Andy Wilkinson 07eee05d1d Add missing "be" in Part's javadoc
Closes gh-1570
2017-10-20 16:43:48 +02:00
Rossen Stoyanchev ab92754a2e @MatrixVariable resolvers for WebFlux
The information was already parsed and available in a request attribute
but until now there were no argument resolvers to expose it.

Issue: SPR-16005
2017-10-19 21:01:38 -04:00
Arjen Poutsma c7a15260d6 Various DataBuffer improvements
This commit introduces various improvements in DataBuffer:

- DataBuffer now exposes its read and write position, as well as its
capacity and writable byte count.
- Added DataBuffer.asByteBuffer(int, int)
- DataBufferUtils.read now reads directly into a DataBuffer, rather than
copying a ByteBuffer into a DataBuffer
- TomcatHttpHandler now reads directly into a DataBuffer

Issues: SPR-16068 SPR-16070
2017-10-19 10:38:52 +02:00
Juergen Hoeller 9df6f3e6b8 Polishing 2017-10-18 20:21:49 +02:00
Juergen Hoeller bec1fc1852 ModelAttributeMethodProcessor detects re-enabled binding declaration
Issue: SPR-16083
2017-10-18 12:31:22 +02:00
Juergen Hoeller ea00c7c6c8 Explicit notes on ExceptionHandler root vs cause resolution
Issue: SPR-16074
2017-10-18 12:18:30 +02:00
Rossen Stoyanchev 94c4a7f941 Shortcut factory method in MockServerWebExchange
MockServerWebExchange now has a second factory method that accepts a
MockServerHttpRequest.BaseBuilder.

Issue: SPR-16079
2017-10-17 12:23:12 -04:00
Rossen Stoyanchev 2d05e538fb Set path in CookieWebSessionIdResolver
Issue: SPR-16030
2017-10-16 09:55:58 -04:00
Rossen Stoyanchev 4831d38db2 Lower log level for ResponseStatusException
Issue: SPR-16049
2017-10-16 09:55:58 -04:00
Juergen Hoeller 3890d4c9eb AbstractServerHttpResponse stores HTTP status code as integer value
Issue: SPR-16073
2017-10-16 15:34:09 +02:00
Juergen Hoeller 43b5e21947 Consistent alias declarations for value attribute on stereotypes
Issue: SPR-16066
2017-10-13 18:18:12 +02:00
Juergen Hoeller 682186a20d Refactored CodecConfigurer creation for clearer subpackage interdependencies
Includes redeclaration of CodecConfigurer.DefaultCodecs without concrete Jackson decoder/encoder references in order to avoid hard Jackson dependency.

Issue: SPR-16064
2017-10-13 14:23:22 +02:00
Sebastien Deleuze 2962f085e5 Relax type check in FormHttpMessage(Reader|Writer)
Issue: SPR-16055
2017-10-12 17:48:42 +02:00
Juergen Hoeller 0d3fa4eb70 Upgrade to Apache Johnzon 1.1.4 2017-10-10 20:35:47 +02:00
Juergen Hoeller cc6e6490d2 Polishing 2017-10-09 13:59:29 +02:00
Rossen Stoyanchev 48c41049b1 Correct package for MockServerWebExchange
Discovered late, but not too late. MockServerWebExchange is now in the
proper package matching to the location of ServerWebExchange.
2017-09-29 17:03:23 -04:00
Rossen Stoyanchev 223e27d53d Package private request and response implementations
Concrete server and client, reactive request and response
implementations should not have to be accessed outside their package.
They could be seen as private to their HttpHandler adapters and
ClientHttpConnector's respectively.

The one exception, WebSocket upgrades in spring-webflux, is an internal
framework use case, accommodated via downcast + accessors in the
abstract base classes.
2017-09-29 13:04:03 -04:00
Rossen Stoyanchev 13c959296a Polish 2017-09-27 22:04:07 -04:00
Brian Clozel 126ac849e5 Fix behavior of ClientResponse#bodyTo** with Void
Prior to this commit, asking for a `Void` type using any of the
`ClientResponse#bodyTo*` methods would immediately return an empty
`Publisher` without consuming the response body.

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

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

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

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

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

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

Issue: SPR-15877
Issue: SPR-16020
2017-09-28 00:31:12 +02:00
Rossen Stoyanchev 6ee1af27c6 WebFlux supports HTTP HEAD
Issue: SPR-15994
2017-09-27 15:25:29 -04:00
Juergen Hoeller a1a7c62127 Consistent configurer access in WebMvcConfigurationSupport
Issue: SPR-16017

(cherry picked from commit 40ba95f)
2017-09-27 19:52:48 +02:00
Brian Clozel 10139d42fc Revisit meaning of response.close() in HTTP client
Prior to this issue, SPR-15920 added this new `close()` method which was
supposed to be called to clean resources after response processing.

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

Issue: SPR-15993
2017-09-27 14:03:55 +02:00
Rossen Stoyanchev ec5969c578 InMemoryWebSession cleans up expired sessions
Issue: SPR-15963
2017-09-27 01:43:11 -04:00
Rossen Stoyanchev 15cc44e6e8 Add WebSession.invalidate()
Issue: SPR-15960
2017-09-27 00:10:38 -04:00
Rossen Stoyanchev 6da3518a66 WebSessionStore updates lastAccessTime on retrieve
Now that WebSessionStore is in charge of expiration checks on retrieve
it makes sense to also update the lastAccessTime on retrieve at the
same time, saving the need to call it after a retrieve.

Issue: SPR-15963
2017-09-26 23:12:58 -04:00
Rossen Stoyanchev cb2deccb2d WebSessionStore performs expiration check on retrieve
Issue: SPR-15963
2017-09-26 23:12:12 -04:00
Juergen Hoeller efce7902c4 Polishing 2017-09-27 01:34:11 +02:00
Rossen Stoyanchev eb6bd2d7b8 Remove args and return value lists from @RequestMapping
It is no longer adequate to list supported arguments and return values
-- between Web MVC and WebFlux, directly on the annotation.

Instead we have tables in the respective chapters in the reference with
cross references to each other.

Issue: SPR-15149
2017-09-26 15:29:58 -04:00
Eddú Meléndez 6f2d58fac6 Remove jackson-datatype-jdk7 auto registration
`jackson-datatype-jdk7` is not provided anymore. It's handlers are
incorporated in core databind.
2017-09-26 14:48:34 +02:00
Brian Clozel 95b83fe1ba Add zero copy support in reactor-based WebClient
This commit makes Reactor Netty `WebClient` instances
support zero-copy requests by implementing `ZeroCopyHttpOutputMessage`.

The implementation leverages the optimized `sendFile` mechanism if
available.
2017-09-26 11:05:48 +02:00
Andy Clement 07b961caa6 Empty path should match the "/" PathPattern
This commit makes both slash "/" and empty "" request paths match the
"/" `PathPattern`.

Issue: SPR-15653
2017-09-26 10:59:13 +02:00
Sebastien Deleuze 74120ef00f Add custom deserializers support to AbstractJackson2Decoder
Issue: SPR-15975
2017-09-25 23:21:50 +02:00
Juergen Hoeller e2882fe1db Build against EE 8 API level wherever possible
Upgrade to JAXB 2.3, JAX-WS 2.3, Annotations 1.3.1, Interceptor 1.2.1.
Also includes Log4J 2.9.1 and Asciidoctor 1.5.6.
2017-09-24 17:18:21 +02:00
Juergen Hoeller 9190b76ab9 Latest dependency updates (POI 3.17, Rome 1.8, EhCache 3.4, Caffeine 2.5.6, RxJava 2.1.4, Tomcat 8.5.21, JRuby 9.1.13, Rhino 1.7.7.2) 2017-09-23 11:28:19 +02:00
Stephane Maldini 21203921f0 sync with reactor-core snapshot 2017-09-22 13:56:39 -07:00
Juergen Hoeller 7ae59d0c2a Nullability refinements on private and static methods
Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
2017-09-22 18:22:14 +02:00
Brian Clozel 60f47f4489 Fix memory leak in reactive multipart parser 2017-09-22 17:03:38 +02:00
Andreas Ahlenstorf b30f6fd991 Ensure that JSON is written to response body
Issue: SPR-15988
2017-09-21 12:19:35 +02:00
Juergen Hoeller 15c82afc1c Consistent conversion of Optional array/list arrangements
Issue: SPR-15918
Issue: SPR-15919
Issue: SPR-15676
2017-09-20 18:28:49 +02:00
Juergen Hoeller ea01c4113a Revisit MockPart constructors
Issue: SPR-15854
2017-09-20 10:55:06 +02:00
Juergen Hoeller 4cbef27f90 Consistent tolerance of unknown HTTP status codes behind RestTemplate
Issue: SPR-15978
2017-09-20 10:54:58 +02:00
Juergen Hoeller 3bd2154046 Polishing 2017-09-19 00:02:40 +02:00
areshetnikov 0f0b8dc745 Fix class name in javadoc
Closes gh-1530
2017-09-18 14:28:37 +02:00
Sebastien Deleuze 1bc93e3d0f Revisit nullability annotations
This commit introduces the following changes.

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

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

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

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

5) Updated Javadoc and reference documentation.

Issue: SPR-15756
2017-09-15 13:26:41 +02:00
Violeta Georgieva ec2218c967 AbstractListenerWriteFlushProcessor: Ensure the last flush will be performed
When writing Publisher<Publisher<T>>, a flush operation is performed onComplete
for every Publisher. If the flush operation is not able to be performed immediately
it will be retried before starting to process data provided by the next Publisher.
For the last Publisher the implementation needs to ensure that the flush will
be performed only then whole operation will complete.

Issue: SPR-15949
2017-09-15 08:53:00 +02:00
Arjen Poutsma 2510db0683 Javadoc 2017-09-14 17:23:25 +02:00
Arjen Poutsma e70210a1da Introduce ForwardedHeaderFilter for WebFlux
This commit introduces a ForwardedHeaderFilter for WebFlux, similar to
the existing Servlet version. As part of this the
DefaultServerHttpRequestBuilder had to be changed to no longer use
delegation, but instead use a deep copy at the point of mutate().
Otherwise, headers could not be removed.

Issue: SPR-15954
2017-09-14 16:27:12 +02:00
Arjen Poutsma 4a0784bea8 Test HTTPS in ReactorServerHttpRequest URI
This commit adds a test for ReactorServerHttpRequest.getUri() to check
whether it returns a HTTPS scheme when configured with SSL.

Issue: SPR-15931
2017-09-12 15:14:54 +02:00
Juergen Hoeller 4371350b5d Polishing 2017-09-10 21:56:31 +02:00
Rossen Stoyanchev bc470fca30 Polish 2017-09-09 17:40:59 -04:00
Juergen Hoeller fd0132c7e6 Polishing 2017-09-08 16:56:22 +02:00
Yi EungJun cf106ec99e Fix typo 2017-09-08 10:48:27 +02:00
Brian Clozel 1a883b863d Remove temporary workaround for reactor-netty client
Now that https://github.com/reactor/reactor-netty/issues/138 is solved,
this commit removes the temporary workaround introduced in SPR-15784
but leaves the general mechanism for detecting empty responses.
2017-09-08 10:27:35 +02:00
Andy Clement 3956423afe Polish
The high level matchStarting API was removed a few commits ago.
This change tidies up by removing the supporting infrastructure
for that from the PathElements.
2017-09-07 14:03:46 -07:00
Arjen Poutsma ec6475a24c Expose scheme in ReactorServerHttpRequest URI
This commit determines fixes ReactorServerHttpRequest.getUri() so that
it includes a URL scheme.

Issue: SPR-15931
2017-09-07 12:29:28 +02:00
Rossen Stoyanchev 2fc2dab230 Fold DefaultWebSession within InMemoryWebSessionStore
InMemoryWebSessionStore is very closely associated to DefaultWebSession
passing it to it several fields and functions. Now that the store also
creates the session, it makes sense to bring the latter in as an inner,
nested class.

Issue: SPR-15875, 15876
2017-09-06 11:47:43 -04:00
Rossen Stoyanchev c7d54c8b52 Polish 2017-09-06 11:47:43 -04:00
Rob Winch 8ad14ae95c DefaultWebSessionManager decoupled from DefaultWebSession
DefaultWebSessionManager no longer requires the WebSessionStore
to use DefaultWebSession.

Removed explicit start() in save(). This seemed unnecessary since at
that point isStarted is guaranteed to return true. The status can
be updated through the copy constructor.

DefaultWebSessionTests added.

Issue: SPR-15875
2017-09-06 11:47:43 -04:00
Rob Winch 86912475af Refactor WebSessionStore
- Add WebSessionStore.createWebSession.

- Remove remove WebSessionStore.changeSessionId

- Add WebSessionStore updateLastAccessTime which allows updating the
WebSession lastAccessTime without exposing a method on WebSession in
an implementation independent way.

- Remove WebSessionStore.storeSession. This method is not necessary
since the WebSession that is returned allows saving the WebSession.
Additionally, it is error prone since the wrong type might be passed
into it.

Issue: SPR-15875, 15876
2017-09-06 11:47:43 -04:00
Rob Winch b7280472d6 Improve WebSession related tests
Add missing DefaultWebSessionManagerTests .block(). Previously
session.save() was invoked, but we did not ensure it was completed.
This commit makes it block on session.save()

Fix existingSessionIsExpired. This test is actually broken and is
testing a new session is created because the session id returned
by the idResolver does not match the existing WebSession.
This commit ensures that the id of the WebSession found by idResolver
matches the existing WebSession.

DefaultWebSessionManagerTests use Mockito. To ensure we test with
independence from InMemoryWebSessionStore we use Mockito for the
DefaultWebessionManager collaborators.

Add test for response.setComplete(). We want to ensure that when the
response is completed, it saves the WebSession and writes it to the
response using idResolver
2017-09-06 11:47:43 -04:00
Rob Winch 167ddc7cfc Polish HeaderWebSessionIdResolver
Use constant for default header name and make getHeaderName private.

Also switch HeaderWebSessionIdResolverTests to unit tests rather than
testing with DefaultWebSessionManager.

Issue: SPR-15917
2017-09-06 11:47:43 -04:00
Brian Clozel 16f3f8d28f Add close() method on HTTP client response
Before this commit, there was no way to signal the HTTP client that we
were done consuming the response. Without that, the underlying client
library cannot know when it is safe to release the associated resources
(e.g. the HTTP connection).

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

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

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

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

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

Issue: SPR-15924
2017-09-06 14:39:09 +02:00
Sebastien Deleuze 5d4ee09d53 Fix AbstractJackson2Encoder#canEncode
This commit ensures that the Jackson encoder is selected only
with supported mime types.

Issue: SPR-15910
2017-09-06 08:26:15 +02:00
Rossen Stoyanchev 320bfdf413 Polish 2017-09-05 17:47:02 -04:00
Greg Turnquist c98e01ad1f Create session-based WebSessionIdResolver
Introduces HeaderSessionIdResolver, which reads session ids from a session header and generates a session response header when new session are created.

Related issue: SPR-15917
2017-09-05 17:37:50 -04:00
Rossen Stoyanchev fc0841c60f Adapt to method name change in Mono 2017-09-05 13:57:20 -04:00
Juergen Hoeller f0198f3756 Upgrade to Apache Johnzon 1.1.3
Issue: SPR-15590
2017-09-02 00:28:41 +02:00
Brian Clozel bff54788e8 Enable HTTP compression Reactor ClientHttpConnector
`ReactorClientHttpConnector` provides an adapter layer to `WebClient`
for using Reactor-Netty's `HttpClient`.
This commit enables HTTP compression support by default for this client
Connector.

Another constructor is still available for providing a custom
`HttpOptions` configuration.

Issue: SPR-15908
2017-09-01 23:14:58 +02:00
Rossen Stoyanchev 3d61f7ba60 Polish 2017-09-01 16:57:35 -04:00
Brian Bohl 81dfadcb16 Fix StringIndexOutOfBoundsException in RestTemplate.doExecute IOException handler when query string is an empty string 2017-09-01 16:48:53 -04:00
Juergen Hoeller 2b44e6e21c Strong references to mapped exception handler methods
Issue: SPR-15907
2017-08-29 15:07:23 +02:00
Brian Clozel 397fd24849 Revert "Leverage Kotlin plugin dependency management"
This reverts commit 3e2f6c848a.
2017-08-22 21:29:39 +02:00
Sebastien Deleuze 3e2f6c848a Leverage Kotlin plugin dependency management 2017-08-22 17:35:57 +02:00
Sebastien Deleuze 9abe77670c Sync with reactor-core when() -> zip() change 2017-08-21 19:54:08 +02:00
Brian Clozel cc3d7d2d48 Apply dependency management to selected modules
This commit applies the Dependency Management Plugin to modules that
require it; right now Spring Framework is importing BOMs for Netty and
Reactor dependencies only.

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

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

Issue: SPR-15885
2017-08-21 14:41:55 +02:00
Juergen Hoeller b61c055e43 Polishing 2017-08-21 01:37:33 +02:00
Juergen Hoeller 3991ab4a23 Efficient Kotlin metadata detection
Issue: SPR-15673
2017-08-21 01:33:20 +02:00
Stephane Nicoll f6e7fef236 Polish 2017-08-19 10:50:41 +02:00
Juergen Hoeller 9aa369f402 Data class construction supports field default/marker parameters
Issue: SPR-15871
2017-08-18 17:59:06 +02:00
Juergen Hoeller 47a7475898 Resolve remaining nullability warnings
Issue: SPR-15869
2017-08-18 00:15:46 +02:00
Juergen Hoeller b94302b5bd Enforce non-null value from getBean and at injection points
Bean-derived null values may still get passed into bean properties and injection points but only if those are declared as non-required. Note that getBean will never return null; a manual bean.equals(null) / "null".equals(bean.toString()) check identifies expected null values now.  This will only ever happen with custom FactoryBeans or factory methods returning null - and since all common cases are handled by autowiring or bean property values in bean definitions, there should be no need to ever manually check for such a null value received from getBean.

Issue: SPR-15829
2017-08-18 00:11:35 +02:00
Sebastien Deleuze 73cf07e9a4 Fix overridden methods nullability
Issue: SPR-15869
2017-08-17 15:02:59 +02:00
Juergen Hoeller 61cdc842e0 BindingResult support for constructor argument mismatch on immutable data object
Issue: SPR-15542
2017-08-17 11:02:40 +02:00
Rossen Stoyanchev e433d8b66a Polish 2017-08-16 15:45:14 +02:00
rlindooren 5b29555d88 Jackson encoder and decoder should use provided mime types
Instead of always using the default JSON mime types
2017-08-16 15:25:18 +02:00
Rossen Stoyanchev 645e3492db Use URLDecoder for query params in WebFlux
Issue: SPR-15860
2017-08-16 13:34:31 +02:00
Rossen Stoyanchev 8b7a670821 Cancel WebAsyncManager thread on request timeout
Issue: SPR-15852
2017-08-16 09:26:21 +02:00
Rossen Stoyanchev 280c64ba35 Polish 2017-08-14 18:55:39 +03:00
Rossen Stoyanchev 8c4b1ab781 Functional PathPattern comparator 2017-08-14 16:33:39 +03:00
Rossen Stoyanchev 631b546d1c Proper null handling in PathPattern comparator 2017-08-14 11:45:27 +03:00
Juergen Hoeller adeb521ce4 Polishing 2017-08-08 17:27:28 +02:00
Stephane Maldini 2677bab560 Use Bismut-BUILD-SNAPSHOT
Sync 3.1.0.BUILD-SNAPSHOT changes to Operators.checkRequest (removed)
2017-08-03 14:30:08 -07:00
Rossen Stoyanchev 08dfce2cb5 Dedicated specificity comparator in PathPattern
The PathPattern compareTo method is now consistent with equals when
two patterns are of the same specificity but otherwise different.

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

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

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

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

Issue: SPR-15824
2017-08-02 10:20:58 +02:00
Rossen Stoyanchev b6d1fd9d22 Minor refactoring in PathPatternParser
Remove the separator constructor argument (but preserve internal
functionality) now that PathPatternParser is more explicitly purposed
for URL paths and in any case the use of an alternate separator would
also requires a similar input option on the PathContainer parsing side.
2017-08-01 22:52:18 +02:00
Rossen Stoyanchev 1794f1cea4 Polish path pattern parsing javadoc
Emphasize specific purpose for URL path matching.
2017-08-01 22:31:21 +02:00
Rossen Stoyanchev b1440b6816 Remove ParsingPathMatcher
Now that we also have RequestPath and PathContainer with the latter as
the required input, the ParsingPathMatcher adapter can be removed.
2017-08-01 13:35:21 +02:00
Juergen Hoeller ca0983cd85 Polishing 2017-08-01 12:08:57 +02:00
Rossen Stoyanchev f813a63fd8 PathContainer parses URL paths only
Collapse non-URL vs URL based path parsing into one essentially
supporting URL paths only.
2017-07-31 22:10:08 +02:00
Rossen Stoyanchev af83d2332a Fix regression in HttpPutFormContentFilter
Re-arrange the checks so that if there is no form parameter, then
immediately and unconditionally delegate to super.getParameterValues().
Or reversely if there is no super.getParameterValues() then return the
form parameter.

So the only remaining case is when combining values present in both.
In that case we'll take both only if a queryString exists.

One extra fix is to not even wrap the request if we did not parse any
form parameters at all which can happen with HttpHiddenMethodFilter.

Issue: SPR-15828, 15835
2017-07-31 17:30:22 +02:00
Stephane Nicoll 1a9cfefcbb Fix test failure
Issue: SPR-15548
Closes gh-1488
2017-07-31 10:45:18 +02:00
Rossen Stoyanchev dbe25cf717 Add RequestPath tests for modifying the contextPath 2017-07-28 12:26:34 +02:00
Rossen Stoyanchev 6855a85c41 Move RequestPath to parent server package 2017-07-28 12:26:34 +02:00
Sebastien Deleuze 6583f9f754 Use ParameterizedTypeReference instead of Class in Kotlin extensions
This commit also removes WebFlux non-extension functions in favor of
regular Kotlin extensions leveraging ParameterizedTypeReference parameter.

Issue: SPR-15818
2017-07-28 00:22:00 +02:00
Rossen Stoyanchev 7e232f989b Improve check for "Broken pipe" error message
Issue: SPR-15802
2017-07-25 10:30:11 +02:00
Sebastien Deleuze ed6fe2b723 Upgrade to Kotlin 1.1.4-eap-33
Issue: SPR-15814
2017-07-24 17:29:02 +02:00
Rossen Stoyanchev 14ccb38523 Handle nested w/o top-level array in Jackson2JsonTokenizer
Issue: SPR-15803
2017-07-21 13:43:38 +02:00
Rossen Stoyanchev bd0de7086e Jackson2JsonTokenizer unwraps top level array only
When the input stream is a JSON array the tokenizer skips over the
start and end array tokens in order to decode into an array of
top-level objects. However in this mode it also skips over nested
start and end array tokens which prevents proper parsing of JSR-310
dates (represented with an array syntax) as well as any fields that
are collections.

Issue: SPR-15803
2017-07-21 12:41:20 +02:00
Rossen Stoyanchev c3e3df57f8 Polish 2017-07-21 12:08:06 +02:00
Rossen Stoyanchev 3009e29489 Remove contentDispositionFormData with charset method
The method was orginally added under SPR-14547 but the example in it
was probably intended for use with Content-Disposition server response
header (file dowonload) and not for a Content-Disposition header
within the body of a multipart request.

In a Spring application a multipart request is typically serialized
by the FormHttpMessageConverter and hence the Content-Disposition is
not explicitly set by the application.

Issue: SPR-15205
2017-07-20 17:49:59 +02:00
Brian Clozel f1abcba4eb Support ipV6 Host addresses in HttpHeaders
This commit parses the "Host" HTTP request header as an
`InetSocketAddress`, while supporting IPv6 addresses like `[::1]`.

This host string contains `:` chars even though it has no port
information.

Issue: SPR-15799
2017-07-20 15:21:46 +02:00
Rossen Stoyanchev bb684ce60b Improve decoding support for multipart filename
StandardMultipartHttpServletRequest now properly decodes RFC-5987
encoded filenames (i.e. filename*) by delegating to ContentDisposition
and also support RFC-2047 syntax through javax.mail MimeUtility.

Issue: SPR-15205
2017-07-20 14:26:20 +02:00
Juergen Hoeller e4651d6b50 XmlEventDecoder uses common defensive XMLInputFactory (now in StaxUtils)
Issue: SPR-15797
2017-07-20 13:17:27 +02:00
Sebastien Deleuze fa4d139684 Support instantiating Kotlin classes with optional parameters
This commit updates BeanUtils class in order to add Kotlin optional
parameters with default values support to the immutable data classes
support introduced by SPR-15199.

Issue: SPR-15673
2017-07-20 10:44:06 +02:00
Brian Clozel 5cac619e23 Fix host+port resolution in ReactorServerHttpRequest
Prior to this commit, the host+port information of the incoming request
where taken from the remoteAddress, which is actually the socket address
of the HTTP client (i.e. not the server).

This commit resolves this information from the "Host" HTTP request
header, if available, or the actual local address of the channel if no
header is available.

Issue: SPR-15084
2017-07-20 01:45:13 +02:00
Juergen Hoeller 6d6d772f31 Polishing 2017-07-20 00:14:56 +02:00
Rossen Stoyanchev 378c72e9b6 Polish + minor refactoring of ResourceUrlProvider 2017-07-19 23:04:39 +02:00
Juergen Hoeller 13080f04f4 UriUtils.extractFileExtension properly handles all fragments
Issue: SPR-15786
2017-07-19 22:40:24 +02:00
Juergen Hoeller ac1d3b22c9 Polishing 2017-07-19 22:22:27 +02:00
Juergen Hoeller 46eba3dbfa Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 22:22:20 +02:00
Rossen Stoyanchev 68e6b148cb Refactor relative redirect filter support
Issue: SPR-15717
2017-07-19 18:46:16 +02:00
Rob Winch fadf04e4b4 Add RelativeRedirectFilter 2017-07-19 17:15:33 +02:00
Rob Winch 5f868b493a Add ForwardedHeaderFilter requestOnly
Add an option for ForwardedHeaderFilter to only process the
HttpServletRequest. This means that HttpServletResponse.sendRedirect will
only work when the application is conifgured to use relative redirects
using Servlet Container specific setup.

Issue: SPR-15717
2017-07-19 17:15:33 +02:00
Rossen Stoyanchev 147368eccc Proactively reject URLs without target address
Issue: SPR-15782
2017-07-19 12:37:32 +02:00
Rossen Stoyanchev cbe5a67687 Polish 2017-07-19 12:37:32 +02:00
Juergen Hoeller 9fc4fb10b0 Nullability fine-tuning around bean properties
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 11:43:58 +02:00
Sebastien Deleuze fb4ddb0746 Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between
getters and setters in order to be able to provide beans
with properties with a common type when type safety is
taken in account like with Kotlin.

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

Issue: SPR-15792
2017-07-19 09:07:56 +02:00
Juergen Hoeller c292a89b24 Http(Async)Client not actually nullable, plus MethodInterceptor nullability
Issue: SPR-15720
2017-07-19 00:15:37 +02:00
Rossen Stoyanchev 43f2de4671 Defensive checks in WebClient and Reactor connector
Since there is no reason for an exchange to ever complete without a
ClientResponse I've added a switchIfEmpty check at the WebClient level.

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

Issue: SPR-15784
2017-07-18 18:13:47 +02:00
Rossen Stoyanchev 7a0e5a378a Update for reactor-core change 2017-07-18 04:09:25 +02:00
Juergen Hoeller 12114a9d4c Consistent use of NIO.2 for file read/write interactions
Issue: SPR-15748
2017-07-18 00:54:41 +02:00
Rossen Stoyanchev ee91e52c3a Polish 2017-07-17 11:39:32 +02:00
Rossen Stoyanchev e2ee23bfc5 WebSession supports changeSessionId
Issue: SPR-15571
2017-07-17 11:09:38 +02:00
Rossen Stoyanchev 47b63150d1 Refactor DefaultWebSession
Use copy constructor to refresh a session with lastAccessTime and a
save function referencing the current exchange. As a result both fields
are now final and ConfigurableWebSession is no longer needed.
2017-07-14 22:55:56 +02:00
Rossen Stoyanchev bf712957f6 Polish WebSession support code 2017-07-14 22:55:56 +02:00
Rossen Stoyanchev e37af83459 Improve docs on on use of urlDecode=false
Issue: SPR-15643
2017-07-14 16:52:02 +02:00
Juergen Hoeller 301e2ea493 Nullability fine-tuning and related polishing
Issue: SPR-15720
2017-07-13 21:20:42 +02:00
Sebastien Deleuze f46520e6e8 Add Jackson Smile support to WebFlux
This binary format more efficient than JSON should be useful for server
to server communication, for example in micro-services use cases.

Issue: SPR-15424
2017-07-13 17:57:07 +02:00
Rossen Stoyanchev d9eafce266 Polish 2017-07-13 06:10:29 +02:00
Juergen Hoeller 5f767a86f5 Always invoke Jackson serialization with AtomicReference cause
Issue: SPR-15760
2017-07-12 19:13:03 +02:00
Rossen Stoyanchev 8359201a0d Improve write completion handling in ChannelSendOperator
Avoid re-using the WriteBarrier as the Subscription to both the
completionSubscriber and the writeSubscriber.

Instead DownstreamBridge is now called WriteCompletionBarrier and is
both a Subscriber and Subscription, i.e. handles all signals to and
from the completion Subscriber.

This frees the request method implementation in WriteBarrier to assume
it can only be called by the writeSubscriber and hence it's safe to
pass on request signals to the write source outside the synchronized
block.
2017-07-12 18:49:28 +02:00
Arjen Poutsma 6329ccb327 Read-Only HttpHeaders only created when necessary
This commit introduces a boolean `readOnly` flag in `HttpHeaders`,
which is used to check if creating a new `HttpHeaders` instance is
necessary in `readOnlyHttpHeaders`.
2017-07-12 18:13:24 +02:00
Arjen Poutsma f4180eb359 Removed faulty test 2017-07-12 15:02:50 +02:00
Rossen Stoyanchev 9ac71afbda Fix one failing test and @Ignore another
The failures look like older failures possibly exposed by recent
changes in Reactor.

The one in ViewResolutionResultHandler is very old test error.
The one in Jackson2JsonDecoderTests is more recent but went unreported.
2017-07-12 13:16:51 +02:00
Rossen Stoyanchev 89a5c857ac Fix recently intorduced bug in ChannelSendOperator
WriteBarrier acts as Subscription to both completionSubscriber and
writeSubscriber so the request method needs to be careful not to
pass on the request outside of readyToWrite or writeSubscriber checks.
2017-07-12 12:40:51 +02:00
Rossen Stoyanchev fbcd554f42 Fix method order in ChannelSendOperator
1. Group by contract
2. Follow lifecycle -- Subscriber 1st, Subscription 2nd, Publisher last
3. Order of declaration in implemented contracts
2017-07-12 12:29:38 +02:00
Rossen Stoyanchev 42188020b4 Polish ChannelSendOperator 2017-07-12 12:21:04 +02:00
Stephane Maldini b3a05ebac9 Inline super SubscriberAdapter with ChannelSendOperator
Add support for CoreSubscriber context passing
2017-07-11 13:12:07 -07:00
Rossen Stoyanchev 134ceac58e Set all strategies in CNM factory bean
ContentNegotiationManagerFactoryBean now provides an option to
explicitly set the strategies to use vs customizing a fixed
list of default strategies.

Issue: SPR-11114
2017-07-11 21:00:57 +02:00
Rossen Stoyanchev befacf4a35 ParameterContentNegotiationStrategy uses MediaTypeFactory
Issue: SPR-15649
2017-07-11 17:54:16 +02:00
Arjen Poutsma 2f9bd6e075 Add local error handling in WebClient.retrieve
This commit introduces a way to customize the WebClientExceptions, as
thrown by WebClient.ResponseSpec.bodyTo[Mono|Flux]. The first
customization will override the defaults, additional customizations are
simply tried in order.

Issue: SPR-15724
2017-07-11 16:36:40 +02:00
Rossen Stoyanchev eb84547894 Fix MockMvc + HttpPutFormContentFilter issue
Issue: SPR-15753
2017-07-11 11:43:48 +02:00
Rossen Stoyanchev c93792b8c9 Allow custom separator in PathContainer 2017-07-11 10:56:19 +02:00
Rossen Stoyanchev 0e370e0703 Separate out URL path parsing in PathContainer
PathContainer now has separate parsePath and parseUrlPath methods each
creating PathSegment and UrlPathSegment respectively.
2017-07-11 10:56:19 +02:00
Rossen Stoyanchev 1d201a55db Refine PathContainer.Segment value representation
Segment.value() now returns the actual original path segment value
including path parameters while semicolonContent() is removed.

valueDecoded() is renamed to valueToMatch() to reflect it is the value
for pattern matching which is not only decoded but also has path
parameters removed.
2017-07-11 10:54:42 +02:00
Rossen Stoyanchev 2f17c5f3b6 From static to instance-based PathContainer#subPath 2017-07-11 06:05:36 +02:00
Rossen Stoyanchev 9f7d57f933 Encapsulate choice of URI encoding within RequestPath
Currently the URI path is always treated as UTF-8 so we can eliminate
the encoding parameter from RequestPath#parse.
2017-07-11 06:05:36 +02:00
Rossen Stoyanchev 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
Ruben Dijkstra f1c7e0f5b2 Check for null on the argument instead of the message
See gh-1307
Issue: SPR-15196
2017-01-27 14:15:24 +01:00
Rossen Stoyanchev 4aac7c2ee2 Minor refactoring in Tomcat/Jetty adapters 2017-01-26 07:37:46 -05:00
Rossen Stoyanchev a2aaa05592 Polish 2017-01-26 07:25:22 -05:00
Violeta Georgieva 383375c35f Use separate reactive HttpHandler for Tomcat/Jetty
Introduce separate adapters TomcatHttpHandlerAdapter/JettyHttpHandlerAdapter
so that each adapter can use the Tomcat/Jetty APIs for reading/writing
with ByteBuffer.
2017-01-26 06:21:44 -05:00
Rossen Stoyanchev ae034e9afe Polish content disposition 2017-01-25 17:19:30 -05:00
Rossen Stoyanchev c8f98ecd8d Add MockPart to spring-test
Issue: SPR-14252
2017-01-25 17:05:25 -05:00
Juergen Hoeller 8038fb9c8b HandlerMethod pre-resolves parameter types at construction time
Issue: SPR-15186
2017-01-25 11:09:43 +01:00
Juergen Hoeller 5e946c2700 Consistent type variable resolution for arrays/collections (in particular at field level)
Dropping GenericCollectionTypeResolver in favor of direct ResolvableType usage.

Issue: SPR-15160
2017-01-24 18:00:17 +01:00
Juergen Hoeller a0df36ddda HiddenHttpMethodFilter defensively proceeds with original request in case of error dispatch
Issue: SPR-15179
2017-01-23 21:25:21 +01:00
Juergen Hoeller 54e2d63d6f Polishing 2017-01-19 21:21:01 +01:00
Kazuki Shimizu 053ac64101 Add "Problem Details for HTTP APIs" media types
See RFC 7807: Problem Details for HTTP APIs

* application/problem+json
* application/problem+xml

Issue: SPR-15110
2017-01-19 15:14:35 +01:00
Rossen Stoyanchev bb3b1f2fe2 Additional convenience methods in UriUtils
The generic encode method in UriUtils that encodes any character
outside the reserved character set for a URI is meant for "strict"
encoding of URI variable values. This commit adds a couple more
conveninence methods that accept a Map or array of URI variable
values to encode.

This facilitates the use case where the URI template is assumed to
be encoded while URI variables are encoded strictly to avoid any
possibility for unwanted reserved characters:

Map<String, ?> encodedUriVars = UriUtils.encodeUriVariables(uriVars);
uriComponentsBuilder.build(true).expand(encodedUriVars).toUri();

Issue: SPR-14970
2017-01-18 21:45:33 -05:00
Rossen Stoyanchev f2e293aadf UriComponents allows "+" in a query param
Issue: SPR-14828
2017-01-18 21:04:37 -05:00
Rossen Stoyanchev b609f3a546 WebHttpHandlerBuilder supports @Order on beans
Issue: SPR-15074
2017-01-18 20:55:29 -05:00
Rossen Stoyanchev 9faaa22fd4 Enable reactive web integration tests 2017-01-18 20:55:29 -05:00
Brian Clozel a0427209d8 Upgrade to Reactor Aluminium SNAPSHOT 2017-01-18 22:30:28 +01:00
Arjen Poutsma 7b341ae5e2 Moved UnsupportedMediaTypeException
Moved UnsupportedMediaTypeException next to Body[Inserters|Extractors],
as that is where they are used. This move should have been done as part
of the inserter and extractor move, but was forgotten.
2017-01-18 16:16:26 +01:00
Juergen Hoeller ee71e7bae1 Polishing 2017-01-18 01:00:02 +01:00
Juergen Hoeller bea934b5bd Polishing 2017-01-18 00:43:17 +01:00
Juergen Hoeller d21b6e596f Revised Charset handling and common StringUtils.uriDecode delegate
Issue: SPR-14492
2017-01-18 00:09:06 +01:00
Rossen Stoyanchev 8417831602 Add accessor methods to HttpPutFormContentFilter
Issue: SPR-14503
2017-01-17 17:19:04 -05:00
Juergen Hoeller 99dc96b1a4 Polishing 2017-01-17 20:42:40 +01:00
Juergen Hoeller ad5386773e ContentCachingRequestWrapper supports content cache limit
Issue: SPR-14829
2017-01-17 20:42:19 +01:00
Rossen Stoyanchev 9819558cba Support encoded query string in reactive requests
In addition to the updates from PR#1297 this commit adds an integration
test and fixes for the resulting failures with RxNetty, Reactor Netty,
and Undertow.

Also replaced use of URLDecoder which is not for decoding URIs with use
of UriUtils for decoding query parameters.

Issue: SPR-15140
2017-01-17 12:46:05 -05:00
Eiichi Sato 613e65f043 Fix URL decoding issue in reactive @RequestParam
%-encoded strings were injected undecoded into @RequestParam variables,
which does not coincide with spring-webmvc behaviour. This commit
fixes AbstractServerHttpRequest.getQueryParams() to correctly return
decoded name-value pairs.

Issue: SPR-15140
2017-01-17 12:46:05 -05:00
Violeta Georgieva 141e04aa0f Fix URI construction in UndertowServerHttpRequest
Ensure there is no "?" at the end of the generated URI when there is
no query available.
2017-01-17 10:19:01 -05:00
Juergen Hoeller 052014783a Remove outdated BeanFactoryLocator documentation references
Issue: SPR-15154
2017-01-17 16:03:17 +01:00
Juergen Hoeller 874b653314 Clarified cookieMaxAge default
Issue: SPR-15155
2017-01-17 15:33:30 +01:00
Juergen Hoeller ac6aa53031 Drop outdated BeanFactoryLocator / beanRefContext.xml mechanism
Issue: SPR-15154
2017-01-17 13:58:37 +01:00
Juergen Hoeller c42d44a42c Polishing and documentation fixes 2017-01-17 12:47:04 +01:00
Brian Clozel 0c99346829 Add SNI support in Netty4ClientHttpRequestFactory
This commit changes the `Bootstrap` to create a SSL Handler with
advisory peer information; this enables support for SNI.

Issue: SPR-15101
2017-01-17 11:15:06 +01:00
Juergen Hoeller 95330d0e44 Polishing 2017-01-16 21:49:21 +01:00
Juergen Hoeller 1922f03d24 StandardMultipartHttpServletRequest identifies MaxUploadSizeExceededException through keywords in message
Issue: SPR-9294
2017-01-16 21:45:22 +01:00
Juergen Hoeller 047786acef Revised InvocableHandlerMethod exception messages (controller vs endpoint vs handler)
Introduces dedicated MethodArgumentResolutionException for spring-messaging invocations.

Issue: SPR-15139
2017-01-16 21:14:46 +01:00
Vedran Pavić 83beb9d57d Set MockSessionCookieConfig#maxAge default to -1
Issue: SPR-15142
2017-01-16 03:17:54 +01:00
Rossen Stoyanchev ba3cc535f1 Refactor reactive mock request and response support
MockServerHttpRequest and MockServerHttpResponse now extend the same
abstract base classes that server-specific implementations do and
therefore approximate their behavior more closely.

As an immediate consequence MockServerHttpRequest is read-only after
it is created. Instead it now exposes static builder methods similar
to those found in RequestEntity. This enforces more strictness as well
as recycling of requests in tests and provides nicer builder methods.

To simplify tests DefaultServerWebExchange now offers a constructor
with just a request and response, and automatically creating a
DefaultWebSessionManager.

The spring-test module now also contains client-side reactive mock
request and response implementations. The mock client request extends
the same AbstractClientHttpRequest as client-specific implementations
do. There is no abstract base class for client responses.

Issue: SPR-14590
2017-01-13 15:23:06 -05:00
Juergen Hoeller 743ce2cda6 Polishing 2017-01-12 23:30:38 +01:00
Juergen Hoeller e19dff179e Polishing 2017-01-12 21:18:01 +01:00
Juergen Hoeller 02d727fd7c MockHttpServletRequestBuilder supports multiple locales
Includes revised content type handling.

Issue: SPR-15116
2017-01-12 21:17:54 +01:00
Juergen Hoeller 0403fe340d Merge pull request #1287 from markhobson/SPR-15109
Introduce mime/media types for application/rss+xml
2017-01-12 20:24:27 +01:00
Sebastien Deleuze 0a988fd2b1 Remove object wrappers in Kotlin extensions
This commit also improve significantly Kotlin extensions
documentation.

Issue: SPR-15127
2017-01-11 08:52:01 +01:00
Sebastien Deleuze aa43472f2e Fix error handling in Jackson2JsonDecoder
Issue: SPR-15112
2017-01-09 14:51:16 +01:00
Mark Hobson 2ce2f7d9a5 Introduce mime/media types for application/rss+xml
Issue: SPR-15109
2017-01-07 17:13:32 +00:00
Sam Brannen 9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Brian Clozel afd93a0b52 Disable streaming when reading to Resources in RestTemplate
Prior to this commit, the `ResourceHttpMessageConverter` would support
converting from an `HttpInputMessage` to a `InputStreamResource`. This
is valid when reading resources on the server side, but it's not
compatible with the way `RestTemplate` works.

The API exposed by `RestOperations` imply that the HTTP server response
should be fully consumed and properly closed by the time the `exchange`
method returns. In other words, this HTTP client does not support
streaming the HTTP response.

This commit allows the `ResourceHttpMessageConverter` to be configured
to disable read streaming when used in `RestTemplate`.

Issue: SPR-14882
2017-01-05 14:48:35 +01:00
Rob Winch df98d304fd Fix ForwardedHeaderFilter with non-empty contextPath
Issue: SPR-15088
2017-01-03 14:51:31 -06:00
Brian Clozel 1ab0916bed Fix default content-type for ResourceRegion HTTP responses
Prior to this commit, the `ResourceRegionHttpMessageConverter` would
rely on the default implementation of `getDefaultContentType` to guess
the default Content-Type of the resource region to be written to the
HTTP response. That implementation fetches the first media type
provided in the HTTP request "Accept" header.

This behavior is not correct when converting resources and this commits
aligns this converter with the `ResourceHttpMessageConverter` which uses
JAF to guess the correct Content-Type of the given resource, or just
returns "application/octet-stream" as a default value.

Issue: SPR-15041
2017-01-02 22:04:20 +01:00
Juergen Hoeller 311522bc86 Run reactive integration tests only as part of performance group 2016-12-29 22:41:23 +01:00
Juergen Hoeller 048098119e PATCH does not work with the standard JDK HTTP library
Issue: SPR-15052
2016-12-27 13:32:43 +01:00
Sebastien Deleuze 546687d5e4 Add Kotlin extension for RestTemplate
Issue: SPR-15056
2016-12-27 10:08:02 +01:00
Juergen Hoeller ef5c797569 Polishing 2016-12-23 21:23:30 +01:00
Sebastien Deleuze fbf88d19da Allow to specify hints with the functional web API
The most common use case is specifying JSON views.

ServerResponse.BodyBuilder#hint(String, Object) allows to
specify response body serialization hints.

ServerRequest#body(BodyExtractor, Map) allows to specify
request body extraction hints.

Issue: SPR-15030
2016-12-23 17:58:34 +01:00
Brian Clozel 54901ab865 Avoid explicit DecoratedObjectFactory setup in JettyRequestUpgradeStrategy
Align Jetty support on spring-websocket module.

Issue: SPR-14940
2016-12-21 17:27:27 +01:00
Sebastien Deleuze 69b69442bc Add ServerSentEventHttpMessageReader
This HTTP message reader parse incoming Server-Sent
Events and turn them into Flux<String>, Flux<Pojo>
or Flux<ServerSentEvent>.

Issue: SPR-14539
2016-12-21 17:07:41 +01:00
Sebastien Deleuze 183b326f6d Add ServerSentEvent#toString() 2016-12-21 16:46:43 +01:00
Sebastien Deleuze 419d2b4e0a Polish ServerSentEventHttpMessageWriterTests 2016-12-21 16:46:43 +01:00
Sebastien Deleuze a8d8273dc1 Fix a typo in ServerSentEventHttpMessageWriter Javadoc 2016-12-21 16:46:42 +01:00
Juergen Hoeller b54aee27be Polishing 2016-12-21 14:42:43 +01:00
Juergen Hoeller 598122fe8a Avoid package cycle between http.server and web.util 2016-12-21 14:42:32 +01:00
Sebastien Deleuze a1ae9ac1bd Add ServerHttpRequest.Builder#header(String, String)
This method allows to set or override easily a specific header value.
2016-12-20 23:54:22 +01:00
Sebastien Deleuze 712a63205c Add HttpHeaders#setAcceptLanguageAsLocale(Locale)
Issue: SPR-15024
2016-12-20 22:33:09 +01:00
Juergen Hoeller 82c1c859d9 Polishing
(cherry picked from commit 9cb4de8)
2016-12-20 21:17:48 +01:00
Stephane Maldini 241d5f7a3b Sync reactor-netty client response update and uncomment in tests 2016-12-20 14:37:32 +00:00
Sebastien Deleuze 7bde85ae55 Fix previous commit 2016-12-19 10:21:36 +01:00
Sebastien Deleuze 879b387954 Disable temporarily reactor-netty integration tests 2016-12-19 09:55:58 +01:00
Juergen Hoeller 9ba4b47bee Defensive processing of timeout callback and timeout result
Issue: SPR-14978
2016-12-17 12:57:18 +01:00
Rossen Stoyanchev bd8af55bc7 getAcceptLanguageAsLocale(s) returns most preferred Locale
An update on the last commit switching from:
List<Locale> getAcceptLanguageAsLocales() to
Locale getAcceptLanguageAsLocale()

This best supports the scenario for the most preferred Locale.
If there is a need to look at the prioritized list of languages it's
best to use Locale.filter with the LocaleRange's.

This is explained in the Javadoc for getAcceptLanguage().

Issue: SPR-15024
2016-12-16 17:15:43 -05:00
Rossen Stoyanchev fa56361ad2 Add getAcceptLanguageAsLocales
The use of Locale.LanguageRange for the Accept-Language header makes
sense as it gives the most flexibility for a client to set a weighted
list and for a server to do filtering via Locale#filter.

This commit adds an additional convenience method that turns
the LangugeRange list to a list of Locale's also filtering out a
wildcard (i.e. "*"). A List<Locale> is the most basic way to access
prefered languages and needed when filtering is not required.

Issue: SPR-15024
2016-12-16 16:20:06 -05:00
Rossen Stoyanchev c85d768b3c WebExchangeDataBinder uses the new "requestParams" 2016-12-16 16:20:06 -05:00
Stephane Maldini 7d9e8def44 uncomment reactor-netty in tests 2016-12-16 20:09:32 +00:00
Rossen Stoyanchev 95818609fc Minor refactoring
Consolidate into one method potentially re-using UriComponentsBuilder
for the location. Also use StringUtils#applyRelativePath.

Issue: SPR-15020
2016-12-15 19:34:33 -05:00
Rob Winch db2ebd30da Add Support for ForwardedHeaderFilter sendRedirect
Previously ForwrdedHeaderFilter did not ensure that
HttpServletResponse.sendRedirect worked properly based on
X-Forwarded-* headers.

This commit updates ForwardedHeaderFilter to overrided the
HttpServletResponse.sendRedirect method to ensure
X-Forwarded-* headers are honored.

Issue SPR-15020
2016-12-15 17:04:57 -05:00
Rossen Stoyanchev 96474405dc Refactor ServerWebExchange/ServerHttpRequest builders
ServerWebExchange.Builder has an additional Consumer-style shortcut
method that accepts a builder for modifying the request.

ServerWebExchange and ServerHttpRequest builders have fewer methods,
more use-case focused vs matching directly to properties.
2016-12-15 17:02:05 -05:00
Rossen Stoyanchev 6119415427 Support for "request parameters"
ServerWebExchange now provides access to "requestParams" as a
MulitValueMap with query parameters and form data combined.

The combined map is then used for the params condition of
@RequestMapping purposes () and also for @RequestParam arguments.

Issue: SPR-15000
2016-12-15 14:24:39 -05:00
Sebastien Deleuze 36da299f96 Add set/getContentLanguage() to HttpHeaders
Issue: SPR-14536
2016-12-15 17:30:53 +01:00
Sebastien Deleuze 9764d57433 Add set/getAcceptLanguage() to HttpHeaders
Issue: SPR-15024
2016-12-15 17:19:37 +01:00
Juergen Hoeller 37c734ec90 Consistent DeferredResultHandler invocation outside of result lock
Issue: SPR-14978
2016-12-15 15:43:47 +01:00
Arjen Poutsma 97558ab4de Move Body[Inserter|Extractor] to web.reactive.function 2016-12-15 13:22:11 +01:00
Arjen Poutsma aa8f531526 Move WebClient to web.reactive.function.client 2016-12-15 13:22:11 +01:00
Sebastien Deleuze dfcd5b9ed9 Add a test to validate Reactor Netty automatic flushing
Issue: SPR-14992
2016-12-15 13:08:36 +01:00
Stephane Maldini c201a14ea2 Temp disabling reactor-netty to unblock pipeline 2016-12-15 04:11:34 +00:00
Rossen Stoyanchev 257318eb87 Minor refactoring + polish in server reactive package
Renamed:
AbstractListenerFlushProcessor -> AbstractListenerWriteFlushProcessor
2016-12-14 17:43:07 -05:00
Rossen Stoyanchev 4738a61e98 Early registration of ReadListener
This is similar to the WriteListener changes on the ServerHttpResponse
where we are more naturally exposed to a delayed write. Nevertheless
we could also have a delayed read and should be consistent. The early
initialization of the RequestBodyPublisher also simplifies the
internal implementation a bit.
2016-12-14 16:17:46 -05:00
Juergen Hoeller 29543856ec OkHttpClientHttpRequestFactory allows POST request without body
Issue: SPR-15015
2016-12-14 22:05:34 +01:00
Rossen Stoyanchev 5a29069798 Refactor AsyncListener registration + polish
Instead of registering an AsyncListener in ServletHttpHandlerAdapter
we now register an AsyncListener in each of the request and response
where the events need to be handled anyway. This allows removing the
package private delegation methods in the request and response.
2016-12-14 15:34:58 -05:00
Rossen Stoyanchev 70f14c14c8 Polish Undertow reactive server support 2016-12-14 14:51:33 -05:00
Rossen Stoyanchev d3e05296e1 Replace close method with Undertow exchange listener
The Undertow HttpServerExchange has a complete listener which we can
use instead of the close() method UndertowServerHttpRequest.
2016-12-14 13:48:40 -05:00
Violeta Georgieva 8d786e8bba Refactor the usage of Undertow ByteBufferPool
- lazy allocate the PooledByteBuffer, only if there is a request body
  for reading
- close the PooledByteBuffer once the request finishes
2016-12-14 12:49:09 -05:00
Arjen Poutsma 582e625fcf Allow HandlerFunction to return Mono<ServerResponse>
This commit makes it possible for handler functions to return
asynchronous status codes and headers, by making HandlerFunction.handle
return a Mono<ServerResponse> instead of a ServerResponse. As a
consequence, all other types that deal with HandlerFunctions
(RouterFunction, HandlerFilterFunction, etc.) had to change as well.

However, when combining the above change with method references (a very
typical use case), resulting signatures would have been something like:

```
public Mono<ServerResponse<Mono<Person>>> getPerson(ServerRequest request)
```

which was too ugly to consider, especially the two uses of Mono. It was
considered to merge ServerResponse with the last Mono, essentialy making
ServerResponse always contain a Publisher, but this had unfortunate
consequences in view rendering.

It was therefore decided to drop the parameterization of ServerResponse,
as the only usage of the extra type information was to manipulate the
response objects in a filter. Even before the above change this was
suggested; it just made the change even more necessary.

As a consequence, `BodyInserter` could be turned into a real
`FunctionalInterface`, which resulted in changes in ClientRequest.

We did, however, make HandlerFunction.handle return a `Mono<? extends
ServerResponse>`, adding little complexity, but allowing for
future `ServerResponse` subtypes that do expose type information, if
it's needed. For instance, a RenderingResponse could expose the view
name and model.

Issue: SPR-14870
2016-12-14 16:52:36 +01:00
Sebastien Deleuze 4021d239ab Fix JsonObjectDecoder with '[' starting chunk
Issue: SPR-15013
2016-12-14 14:53:12 +01:00
Rossen Stoyanchev b70071fdda Remove temporary workaround in ReactorServertHttpResponse
We no longer should need the workaround for:
https://github.com/reactor/reactor-netty/issues/2

Issue: SPR-14643
2016-12-14 08:50:37 -05:00
Rossen Stoyanchev c66dd01724 Equal MockServerHttpResponse in spring-test and -web 2016-12-14 05:54:53 -05:00
Sebastien Deleuze 4519c236d6 Restore reactor-netty test in FlushingIntegrationTests 2016-12-14 11:05:18 +01:00
Sebastien Deleuze 1829adecb7 Disable temporarily reactor-netty in FlushingIntegrationTests 2016-12-14 09:34:19 +01:00
Rossen Stoyanchev 3df902c6cc Add ServerHttpRequest builder
Similar pattern as for ServerWebExchange with a default mutate method
on ServerHttpRequest returning a Builder and eventually creating an
immutable wrapper.

HttpHandlerAdapterSupport uses the builder to set the contextPath.
2016-12-13 17:59:51 -05:00
Rossen Stoyanchev f693e32973 Add ServerHttpResponseDecorator
For completeness and consistency with the existing
ServerHttpRequestDecorator and the ServerWebExchangeDecorator.
2016-12-13 17:59:51 -05:00
Rossen Stoyanchev d421112af3 Polish ServerWebExchange builder and ServerHttpResponse
Remove duplicated ServerHttpResponse#setComplete also declard in the
parent ReactiveHttpOutputMessage interface.

Also rename:
ServerWebExchange.MutativeBuilder --> ServerWebExchange.Builder
2016-12-13 17:59:51 -05:00
Rossen Stoyanchev 7193686bb0 Support encodeUrl mechanism via ServerHttpResponse
Issue: SPR-14529
2016-12-13 17:59:51 -05:00
Brian Clozel d4411f4cc6 Update AbstractClientHttpRequest with server changes
This commit updates `AbstractClientHttpRequest` to make it more similar
to its server counterpart.
2016-12-13 22:58:01 +01:00
Brian Clozel ba47d06cbb Update integration tests for reactor-netty
Now that reactor/reactor-netty#12 is fixed, we can restore the
previously ignored integration tests.
New tests are hanging, so this commit is converting the `StepVerifier`
`verify()` calls to using actual timeouts.

Issue: SPR-14975
2016-12-13 21:34:13 +01:00
Stephane Maldini 6922a1c534 Sync with latest reactor netty changes 2016-12-13 17:22:40 +00:00
Violeta Georgieva 9d03b77cdc Rename "ResponseBody" flush processor + use generics
Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Rossen Stoyanchev fe7ee5ff33 Rename "Request/ResponseBody" publisher/processor
AbstractRequestBodyPublisher and AbstractResponseBodyProcessor are now
used for WebSocket messages too and have been renamed more generally to
AbstractListenerReadPublisher and AbstractListenerWriteProcessor.

Issue: SPR-14527
2016-12-12 17:56:48 -05:00
Violeta Georgieva 46b39f4372 Initial reactive, WebSocket Tomcat support
Issue: SPR-14527
2016-12-12 17:56:47 -05:00
Violeta Georgieva 41ece612cf Generic AbstractRequest/ResponseBodyProcessor
In preparation for use with WebSockets.

Issue: SPR-14527
2016-12-12 17:56:47 -05:00
Juergen Hoeller e49813f2c4 Polishing 2016-12-12 22:49:40 +01:00
Juergen Hoeller aa29495d1d CommonsMultipartFile.getOriginalFilename() can be configured to preserve header-specified filename as-is
Issue: SPR-14613
2016-12-09 23:05:51 +01:00
Juergen Hoeller cf6a5835cc Polishing 2016-12-08 18:39:30 +01:00
Juergen Hoeller ee30ce95fe HttpInvokerClientInterceptor propagates client-side Error as-is
Issue: SPR-14985
2016-12-08 18:29:41 +01:00
Sebastien Deleuze 2735cba4b3 Append "data:" after line breaks for SSE JSON data fields
Issue: SPR-14899
2016-12-08 11:19:46 +01:00
bedrin 8315a4033f Add consumes attribute to @GetMapping
Issue: SPR-14988
2016-12-07 17:45:43 -05:00
Sebastien Deleuze 24b3614063 Add a 8 Kb flush threshold to RxNettyServerHttpResponse
Issue: SPR-14991
2016-12-07 11:13:45 +01:00
Brian Clozel ec8391a7fb Fix Netty4ClientHttpRequestFactory POST/PUT requests
This commit ensures that POST/PUT requests sent by the Netty client have
a Content-Length header set.

Integration tests have been refactored to use mockwebserver instead of
Jetty and have been parameterized to run on all available supported
clients.

Issue: SPR-14860
2016-12-07 09:23:53 +01:00
Arjen Poutsma 9e72033036 Add WebClient.filter method
This commit introduces a new method on WebClient: filter, which takes an
filter function, and returns a (filtered) WebClient.

Issue: SPR-14961
2016-12-06 13:03:58 +01:00
Arjen Poutsma 079eca9f63 Add status code check to bodyTo[Mono|Flux]
- Add 4xx/5xx status code check to ClientResponse.bodyToMono and bodyToFlux.
- Removed WebClient.retrieveMono and retrieveFlux.

Issue: SPR-14977
2016-12-06 09:29:21 +01:00
Rossen Stoyanchev 953f7d40cf Filter out hanging tests realted to Reactor Netty
Issue: SPR-14975
2016-12-05 16:03:12 -05:00
Arjen Poutsma 136b33bc4a Allow serving static files from RouterFunctions
This commit adds the ability to serve Resources (static files) through a
RouterFunction. Two methods have been added to RouterFunctions: one that
exposes a given directory given a path pattern, and a generic method
that requires a lookup function.

Issue: SPR-14913
2016-12-02 15:47:26 +01:00
Juergen Hoeller 1039fa1d34 Avoid defensive check for Servlet 3.1 Part interface
Issue: SPR-14467
2016-12-01 20:11:54 +01:00
Juergen Hoeller f6fc0a86b3 Polishing
(cherry picked from commit 0028b29)
2016-12-01 20:11:47 +01:00
Juergen Hoeller 7a8ec4f6eb Consistent use of "URI variables" terminology
Issue: SPR-14969
2016-12-01 12:30:10 +01:00
Juergen Hoeller 8cb7e026e2 HttpRequestPathHelper in new web.server.support package
In general, web.util is supposed to remain lowest-level, not depending on any other web.* package. Since web.client also has a support package, a corresponding web.server.support package seemed appropriate for a helper class depending on ServerWebExchange in web.server itself.
2016-11-30 11:12:06 +01:00
Brian Clozel 3bd17175ed Update with new HttpServerResponse.sendFile signature
Reactor Netty's `HttpServerResponse` has a new `sendFile` signature that
takes a `Path` instead of a `File`.
2016-11-29 14:29:39 +01:00
Rossen Stoyanchev cb50f6bc8c ResponseEntity headers builder casts body to any type
Issue: SPR-14939
2016-11-28 17:22:24 -05:00
Sebastien Deleuze 0fcae5d2c5 Polishing
Issue: SPR-14952
2016-11-25 12:54:48 +01:00
Sebastien Deleuze 8d26c738a0 Polishing
This commit polishes previous one by also accepting
generic types explicitly declared with a class that
extends DataBuffer allowing to write Flux<DefaultDataBuffer>
for example.

Issue: SPR-14952
2016-11-25 10:33:13 +01:00
Daniel Fernández a98be035a3 Make the signature of RHOM#writeAndFlush() more flexible
This modifies the signature of
ReactiveHttpOutputMessage#writeAndFlush(...) in order to
be able to use Flux<Flux<DataBuffer>> objects as arguments of
this method.

Issue: SPR-14952
2016-11-25 09:59:33 +01:00
Sebastien Deleuze a143b57d4b Polish Kotlin nullable support
This commit polishes Kotlin nullable support by reusing
MethodParameter#isOptional() instead of adding a new
MethodParameter#isNullable() method, adds
Kotlin tests and introduces Spring Web Reactive
support.

Issue: SPR-14165
2016-11-24 18:28:50 +01:00
Raman Gupta fada91e538 Treat Kotlin nullable as non-required
Where `isOptional` is used, also check for `isNullable` i.e.
values are not considered required if they are Kotlin nullables:
- spring-messaging: named value method arguments
- spring-web: named value method arguments
- spring-webmvc: request parts

This means that Kotlin client code no longer has to explicity specify
"required=false" for Kotlin nullables -- this information is inferred
automatically by the framework.

Issue: SPR-14165
2016-11-24 17:18:55 +01:00
Arjen Poutsma 735e288d46 Add DataBuffer BodyInserter/BodyExtractor
Added a BodyExtractor for Flux<DataBuffer>, and a BodyInserter for
Publisher<DataBuffer>

Issue: SPR-14918
2016-11-24 17:04:50 +01:00
Violeta Georgieva 6f222609c2 Fix NPE in ServletServerHttpResponse.ResponseBodyProcessor.write
Issue: SPR-14941
2016-11-24 11:53:28 +01:00
Rossen Stoyanchev 3eb2432ced Fix TODO in ReactorHttpServer 2016-11-23 15:47:19 -05:00
Juergen Hoeller 1f4c6de287 Polishing 2016-11-23 21:10:01 +01:00
Rossen Stoyanchev 6b9b47ee13 Polish 2016-11-23 13:20:38 -05:00
Stephane Maldini 099f5a254e Upgrade to reactor-netty/-ipc to 0.6 snapshots 2016-11-23 12:50:01 -05:00
Juergen Hoeller 9bf4d7cf4e Polishing 2016-11-22 14:57:00 +01:00
Juergen Hoeller 85b0ce1ef7 Avoid defensive checks against java.time API
Issue: SPR-13188
2016-11-22 14:55:03 +01:00
Juergen Hoeller da63898d5f Polishing 2016-11-21 17:36:04 +01:00
Arjen Poutsma dbe81bef52 Add PATCH method operation to RestTemplate
This commit adds a HTTP PATCH operation to the RestTemplate:
patchForObject. As with most operations, there are three variants:
varargs, Map, and URI based.

Issue: SPR-14857
2016-11-17 10:19:09 +01:00
Mark Paluch 6261106a93 Fix TLS detection in URLs for Netty Client RequestFactory
Do not check on non-specified port when scheme is https.
Enables SSL for https URIs with a specified port.

Issue: SPR-14889
2016-11-11 16:39:18 +01:00
Juergen Hoeller dda9762072 Moved WebExchangeDataBinder to web.bind.support (alongside WebRequestDataBinder)
Issue: SPR-14542
2016-11-08 11:01:58 +01:00
Sebastien Deleuze 99a8510ace Introduce HttpHeaders get/setContentDisposition()
This commit introduces a new ContentDisposition class designed
to parse and generate Content-Disposition header value as defined
in RFC 2183. It supports the disposition type and the name,
filename (or filename* when encoded according to RFC 5987) and
size parameters.

This new class is usually used thanks to
HttpHeaders#getContentDisposition() and
HttpHeaders#setContentDisposition(ContentDisposition).

Issue: SPR-14408
2016-11-08 01:12:23 +01:00
Rossen Stoyanchev 816e32872a Reactive support for @ModelAttribute argument
Issue: SPR-14542
2016-11-07 15:02:13 +02:00
Juergen Hoeller 9b57437b7a Polishing 2016-11-07 12:55:35 +01:00
Juergen Hoeller 365ecd4cca Polishing 2016-11-04 14:14:31 +01:00
Juergen Hoeller 17f5f86a54 Polishing 2016-11-04 12:25:38 +01:00
Juergen Hoeller ac774cdcef Avoid deprecated Mockito methods
Issue: SPR-14880
2016-11-04 12:24:46 +01:00
Juergen Hoeller 84d3808b3b Upgrade to Mockito 2.2
Issue: SPR-14880
2016-11-03 22:53:35 +01:00
Sebastien Deleuze 8705df502d Rename Verifier to StepVerifier
Issue: SPR-14800
2016-11-02 19:01:40 +01:00
Sebastien Deleuze b4b7c278df Update tests according to latest reactor-test changes
- ScriptedSubscriber has been renamed to Verifier
 - The Publisher is passed to create() instead of verify()
 - No more need to specify the generic type explicitly
 - Version is now sync with reactor-core

Issue: SPR-14800
2016-11-01 22:28:50 +01:00
Rossen Stoyanchev 99cacaa72d Improve reactive support for access to Principal
The method to access the Principal from the ServerWebExchange is now
a Mono<Principal> (rather than Optional<Principal>).

There is also support for Principal as a controller method argument.

Issue: SPR-14680, SPR-14865
2016-11-01 18:44:14 +02:00
Rossen Stoyanchev 33dbbce182 ApplicationContext-based HttpHandler setup
This commit adds support for detecting the target WebHandler along with
WebFilters, WebExceptionHandlers, and other spring-web reactive
strategies in an ApplicationContext.

WebReactiveConfigurationSupport has @Bean factory methods for
DispatcherHandler and ResponseStatusExceptionHandler.

WebHttpHandlerBuilder has a static factory method that initializes the
builder from an ApplicationContext. This method is also used in the
DispatcherHandler#toHttpHandler(ApplicationContext) shortcut method.

Issue: SPR-14837
2016-10-31 20:45:26 +02:00
Rossen Stoyanchev 3da0295c12 Support for reactive controller @InitBinder methods
Issue: SPR-14543
2016-10-31 16:11:44 +02:00
Juergen Hoeller c4ee876416 Polishing 2016-10-31 12:45:41 +01:00
Juergen Hoeller 7f280a3b17 Polishing 2016-10-31 12:28:44 +01:00
Rossen Stoyanchev 00a35897fe ServerWebExchange provides access to form data
The ServerWebExchange now has a getFormData() method that delegates to
FormHttpMessageReader for the parsing and then caches the result so
it may be used multiples times during request processing.

Issue: SPR-14541
2016-10-28 22:58:31 +03:00
Rossen Stoyanchev 81b4dedd08 Polish form reader/writer 2016-10-28 21:29:02 +03:00
Sebastien Deleuze 46599e7d03 Add FormHttpMessageReader/Writer
Issue: SPR-14540
2016-10-28 19:08:01 +03:00
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
Juergen Hoeller 5f4e838f41 Jackson-based message converters do not log warning for serializer not found
Issue: SPR-14163
2016-04-14 14:13:13 +02:00
Juergen Hoeller 3222664024 Avoid unnecessary GenericHttpMessageConverter re-declaration 2016-04-13 19:03:59 +02:00
Juergen Hoeller 96875fe015 Avoid unnecessary GenericHttpMessageConverter re-declaration 2016-04-13 18:52:52 +02:00
Juergen Hoeller 570851e8e4 Consistent headers.getContentLength() checks
(cherry picked from commit 7f438dc)
2016-04-13 18:50:15 +02:00
Juergen Hoeller e3667467f6 AbstractJackson2HttpMessageConverter's canRead/canWrite checks media type first before delegating to Jackson
Issue: SPR-14163
2016-04-13 18:34:22 +02:00
Tokuhiro Matsuno 741fbcd6fe Fix typo
Closes gh-1013
2016-04-12 08:17:24 +02:00
Johnny Lim f4b7da9a3e Fix typo
Closes gh-1030
2016-04-12 08:14:53 +02:00
Juergen Hoeller 448621ac58 HttpHeaders consistently ignores invalid date header values
Issue: SPR-14144
2016-04-11 17:45:49 +02:00
Juergen Hoeller 21e4ac1aa2 Upgrade to Netty 4.1
Issue: SPR-14143
2016-04-11 12:20:13 +02:00
Juergen Hoeller cb9549655c AbstractApplicationContext registers default embedded value resolver
Issue: SPR-14140
2016-04-09 20:49:22 +02:00
Juergen Hoeller 4ae065996b Polishing
(cherry picked from commit aa5c12c)
2016-04-08 23:06:25 +02:00
Juergen Hoeller 37bd51cf6d Handle Resources beyond int length through Servlet 3.1's setContentLengthLong
Issue: SPR-14135
2016-04-08 15:54:24 +02:00
Juergen Hoeller 042d8d0b4c FacesRequestAttributes falls back to ExternalContext as session mutex
Issue: SPR-12402
2016-04-07 11:41:32 +02:00
Juergen Hoeller ed14ae60e5 Consistent deprecation of outdated MVC infrastructure classes
Issue: SPR-14128
2016-04-07 11:37:34 +02:00
Sam Brannen 8213df817e Clean up warnings in spring-web 2016-04-06 15:21:07 +02:00
Sebastien Deleuze 1f9a9cf404 Auto-detect Kotlin Jackson module
Issue: SPR-14108
2016-04-04 16:49:40 +02:00
Juergen Hoeller f6cb30b165 @ExceptionHandler is able to process Error thrown from handler method
Issue: SPR-11106
2016-03-31 11:52:36 +02:00
Roy Clarkson f35ec5353a Add support for OkHttp3
OkHttp3 introduces a new package and API that is incompatible with
previous versions. This commit adds a new
OkHttp3ClientHttpRequestFactory and supporting classes.
2016-03-29 18:15:04 +02:00
Brian Clozel eec22f5072 Avoid duplicate flush when closing outputstream
Prior to this commit, the `HttpInvokerServiceExporter` would close
its `ObjectOutputStream`, which itself issues duplicate flushes on the
underlying `OutputStream`. Duplicate flushes can lead to multiple,
separate TCP packets where those should be gathered writes.

This commit wraps the underying stream with a decorator that guards
against flush calls that are duplicated with the one done in `close`.

Issue: SPR-14040
2016-03-29 17:31:42 +02:00
Brian Clozel b947bfe8e9 Support of HTTP persistent connections for JDK client
Prior to this commit, HTTP clients relying on the JDK HTTP client would
not properly reuse existing TCP connections (i.e. HTTP 1.1 persisten
connection). The SimpleClientHttpResponse would close the actual connection once the
response is handled.

As explained in the JDK documentation
(http://docs.oracle.com/javase/8/docs/technotes/guides/net/http-keepalive.html)
HTTP clients should do the following to allow resource reuse:

* consume the whole HTTP response content
* close the response inputstream once done

This commit makes sure that the response content is
totally drained and then the stream closed (and not the connection).

Issue: SPR-14040
2016-03-29 17:31:42 +02:00
Juergen Hoeller 6298292523 AsyncRestTemplate triggers no-output HTTP requests immediately as well
Issue: SPR-14093
2016-03-29 15:22:32 +02:00
Juergen Hoeller b2a17ba537 RequestHeaderMapMethodArgumentResolver defensively checks for non-existing header values
Issue: SPR-14091
2016-03-27 14:07:25 +02:00
Brian Clozel 862d10c128 Support new default values in WebDataBinder
Prior to this commit, binding a `@ModelAttribute` object as a Controller
handler paramater would instantiate the object and set all its
properties, fetching data from the request. When no data is available,
the WebDataBinder tries to bind default "empty" values:
* Boolean.FALSE for boolean types
* empty arrays for array types
* null by default

This commit adds the new default empty values:
* empty Collections for Collection types
* empty Maps for Map types

Rather than using empty implementations provided by `Collections.empty`
(which are not mutable), we're using the closest possible target type
and real implementations, provided by the `CollectionFactory`.

Issue: SPR-13502
2016-03-25 21:37:08 +01:00
Juergen Hoeller 852212d0c5 Polishing 2016-03-24 19:57:54 +01:00
Juergen Hoeller 517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller 06db5aa43f Polishing 2016-03-24 15:34:17 +01:00
Juergen Hoeller 9a52c81443 UriComponentsBuilder allows more efficient (and less restrictive) CORS origin comparison
Also introduces a specifically narrowed cloneBuilder() method for UriComponentsBuilders.

Issue: SPR-14080
2016-03-24 15:33:44 +01:00
Juergen Hoeller abe7345008 DefaultCorsProcessor checks for existing CORS response before attempting to compare origin
Issue: SPR-14080
2016-03-24 15:08:19 +01:00
Juergen Hoeller 9af12d290e Polishing 2016-03-23 18:39:29 +01:00
Juergen Hoeller 5025c615b1 Consistent use of AnnotatedElementUtils.findMergedAnnotation/hasAnnotation
Issue: SPR-13440
2016-03-23 18:39:20 +01:00
Brian Clozel c7bd3b8440 Support HTTP range requests in Controllers
Prior to this commit, HTTP Range requests were only supported by the
ResourceHttpRequestHandler when serving static resources.

This commit improves the ResourceHttpMessageConverter that
now supports partial writes of Resources.
For this, the `HttpEntityMethodProcessor` and
`RequestResponseBodyMethodProcessor` now wrap resources with HTTP
range information in a `HttpRangeResource`, if necessary. The
message converter handle those types and knows how to handle partial
writes.

Controller methods can now handle Range requests for
return types that extend Resource or HttpEntity:

    @RequestMapping("/example/video.mp4")
    public Resource handler() { }

    @RequestMapping("/example/video.mp4")
    public HttpEntity<Resource> handler() { }

Issue: SPR-13834
2016-03-23 16:40:12 +01:00
Rossen Stoyanchev 7a5e93ff16 Add support for setting the "Vary" response header
Issue: SPR-14070
2016-03-22 21:47:55 -04:00
Markus Malkusch 160410c148 Be explicit about the time unit in WebRequest
This commit adds the timeunit to the interface documentation
of WebRequest.checkNotModified().
2016-03-18 18:23:15 +01:00
Rossen Stoyanchev 582864802e Ensure RedirectModel is initialized
This commit fixes an old bug in ModelAndViewContainer where getModel
returns a new ModelMap instance that isn't saved and re-used.

Issue: SPR-14045
2016-03-14 23:00:19 -04:00
Juergen Hoeller d124a13eb4 Consistent use of empty enumerations 2016-03-11 15:07:59 +01:00
Sam Brannen 4bead6e542 Polish Javadoc for @GetMapping
Issue: SPR-13992
2016-03-07 18:18:46 +01:00
Sam Brannen cbcc9998f1 Support 'produces' and 'consumes' attributes in @DeleteMapping
Issue: SPR-13992
2016-03-07 18:13:40 +01:00
Sam Brannen bea26413b4 Support 'produces' attribute in @[Post|Put|Patch]Mapping
Issue: SPR-13992
2016-03-07 18:13:40 +01:00
Sam Brannen 78690a24fb Add headers & name attributes to composed @RequestMapping annotations
Issue: SPR-13992
2016-03-07 18:13:40 +01:00
Sam Brannen ca8acc8758 Suppress warnings Gradle build 2016-03-07 15:36:46 +01:00
Rossen Stoyanchev f162256906 Use ContentNegotiationManager for static resources
The ResourceHttpRequestHandler now relies on the conifgured
ContentNegotiationManager to determine the content type for resource
requests rather than implementing that internally.

First we check against the matched resource based on the resource file
extension. Then we expand the check against the request with any
configured content negotiation strategy.

Issue: SPR-13658
2016-03-04 16:06:01 -05:00
Rossen Stoyanchev 6f2c968925 Support strict URI variable encoding
The DefaulUriTemplateHandler now provides a strictEncoding property
which if turned on encodes everything outside the reserved char set.

This is in contrast to the default policy of encoding only illegal
charaters depending on the URI component type.

Issue: SPR-11652
2016-03-03 14:37:48 -05:00
Rossen Stoyanchev e98738d8ba Polish UriTemplateHandler related classes 2016-03-03 13:33:45 -05:00
Rossen Stoyanchev 36e2dd90a7 Support contextPath override in ForwardedHeaderFilter
Issue: SPR-13614
2016-03-02 18:38:25 -05:00
Rossen Stoyanchev 6fcc869338 Polish ForwardedHeaderFilter
Issue: SPR-13614
2016-03-02 18:38:25 -05:00
Rossen Stoyanchev 4cf0b59e00 Add ForwardedHeaderFilter
The new Filter is simply a new way of packaging the ability to extract
X-Forwarded-* headers already available via UriComponentsBuilder.

The Filter wraps the request and the effect is that anything using the
request will see the original schem, host, and port.

Issue: SPR-13614
2016-03-01 23:33:36 -05:00
Sebastien Deleuze 7b861c9a8a Add defaultUseWrapper support to Jackson builder
Issue: SPR-13975
2016-03-02 00:03:25 +01:00
Stephane Nicoll b3b3fc5a7e Polish 2016-03-01 19:10:39 +01:00
Brian Clozel 0d6f80052d Support conditional updates in ServletWebRequest
Prior to this commit, `ServletWebRequest.checkNotModified` would only
support conditional GET/HEAD requests with "If-Modified-Since" and/or
"If-None-Match" request headers. In those cases, the server would return
"HTTP 304 Not Modified" responses if the resource didn't change.

This commit adds support for conditional update requests, such as
POST/PUT/DELETE requests with "If-Unmodified-Since" request headers.
If the underlying resource has been modified since the specified date,
the server will return a "409 Precondition failed" response status
to prevent concurrent updates.

Even if the modification status of the resource is reversed here
(modified vs. not modified), we're keeping here the same intent for the
return value, which signals if the response requires more processing or
if the handler method can return immediately:

```
if (request.checkNotModified(lastModified)) {
  // shortcut exit - no further processing necessary
  return null;
}
```

Issue: SPR-13863
2016-03-01 14:37:29 +01:00
Sebastien Deleuze c385427397 Allow to specify AbstractHttpMessageConverter default charset
Before this commit, specifying the charset to use with produces or
consumes @RequestMapping attributes resulted in default charset
loss. That was really annoying for JSON for example, where using
UTF-8 charset is mandatory in a lot of use cases.

This commit adds a defaultCharset property to
AbstractHttpMessageConverter in order to avoid losing the
default charset when specifying the charset with these
@RequestMapping attributes.

It changes slightly the default behavior (that's why we have waited
4.3), but it is much more error prone, and will match with most
user's expectations since the charset loss was accidental in most
use cases (users usually just want to limit the media type supported
by a specific handler method).

Issue: SPR-13631
2016-02-29 23:34:32 +01:00
Sam Brannen 61824b1ade Remove trailing whitespace from source code 2016-02-29 18:52:57 +01:00
Sam Brannen 467b5f3f28 Introduce composed annotations for @RequestMapping
This commit introduces the following common composed annotations for
@RequestMapping in Spring MVC and Spring MVC REST.

- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping

Issue: SPR-13992
2016-02-29 18:22:30 +01:00
Sam Brannen b423596b2e Introduce composed annotations for web scopes
This commit introduces the following common composed annotations for
web scopes.

- @RequestScope
- @SessionScope
- @ApplicationScope

Issue: SPR-13993
2016-02-29 17:38:46 +01:00
Sam Brannen 0c66838268 Polish Javadoc for @RequestMapping 2016-02-26 22:35:51 +01:00
Juergen Hoeller ca19920d74 Refined ApplicationContextInitializer assignability exception 2016-02-24 17:50:14 +01:00
Sebastien Deleuze 3329abffc8 Allow to specify request body type in RestTemplate
This commit allows to specify the request body type in order to
serialize generic types with a GenericHttpMessageConverter if
needed.

Issue: SPR-13154
2016-02-23 16:15:38 +01:00
Brian Clozel 1c2ac49f2a Add weak ETag support in ShallowEtagHeaderFilter
This commit adds weak ETag support in ShallowEtagHeaderFilter.
This improves the behavior of the filter in tow ways:

* weak ETags in request headers such as `W/"0badc0ffee"` will be
compared with a "weak comparison" (matching both weak and strong ETags
of the same value)
* when enabled with the "writeWeakETag" init param, the filter will
write weak Etags in its HTTP responses

Issue: SPR-13778
2016-02-18 18:05:48 +01:00
Juergen Hoeller 8495fcf109 Avoid accessing the session if no session attributes need to be updated
Issue: SPR-13950
2016-02-18 17:33:39 +01:00
Juergen Hoeller e0d7c6be00 Name attributes in method argument annotations allow for placeholders and expressions
Issue: SPR-13952
2016-02-17 22:59:12 +01:00
Brian Clozel ac3847bf4a Clarify Javadoc for CacheControl.noCache,noStore
This change makes clear that this is the intent of the CacheControl API
not to provide a way to configure both "no-cache" and "no-store"
directives for the "Cache-Control" header.

Issue: SPR-13780
2016-02-17 16:48:28 +01:00
Juergen Hoeller 5c87afc51d Polishing 2016-02-16 22:28:46 +01:00
Juergen Hoeller 5e5bf7f518 Polishing 2016-02-16 13:57:08 +01:00
Arjen Poutsma 37b32d38bc Use synchonous API for synchonous OkHttp requests
This commit changes the OkHttpClientHttpRequestFactory to use the
synchronous OkHttp API for non-async requests, as opposed to
synchronizing the async API (which it used to do).

Issue: SPR-13942
2016-02-16 12:16:10 +01:00
Juergen Hoeller 27c1280949 Consider negative contentLength() result as not resolvable
Issue: SPR-13571
2016-02-11 22:24:13 +01:00
Juergen Hoeller 8558cbc9bf Polishing 2016-02-10 19:40:47 +01:00
Rossen Stoyanchev b11d345c0d Common base class for [Unknown]HttpStatusCodeException
Issue: SPR-13928
2016-02-10 11:21:59 -05:00
Juergen Hoeller 901c2d5f74 Consistent API between spring-web and spring-messaging HandlerMethod infrastructure
Issue: SPR-13929
2016-02-10 16:23:11 +01:00
Rossen Stoyanchev 902a7287f7 Fix NPE in InvocableHandlerMethod
Issue: SPR-13917
2016-02-04 23:32:22 -05:00
Rossen Stoyanchev b49235ac59 BufferedImage converter writes Content-Type again
Issue: SPR-13906
2016-02-04 14:59:13 -05:00
Juergen Hoeller e90310612f Polishing 2016-02-04 20:00:00 +01:00
Rossen Stoyanchev bedf1a9bd0 Polish UriTemplateTests 2016-01-29 15:39:02 -05:00
Rossen Stoyanchev f5aa011722 UriComponents support for array query params
Issue: SPR-9712
2016-01-29 15:32:42 -05:00
Rossen Stoyanchev 2e7470b27f Allow binding=false on @ModelAttribute
Issue: SPR-13402
2016-01-26 23:51:18 -05:00
Rossen Stoyanchev 806e79b14b Polish 2016-01-26 23:20:58 -05:00
Rossen Stoyanchev e62ada898b Add @RequestAttribute with servlet-based support
Issue: SPR-13894
2016-01-26 16:37:50 -05:00
Rossen Stoyanchev 698f923fc3 Add @SessionAttribute with Servlet-based support
Issue: SPR-13894
2016-01-26 16:37:44 -05:00
Juergen Hoeller b4f33adf48 Consistent java.util.Optional resolution, lenient handling of optional multipart files, correct Servlet 3.0 Part list/array selection
Issue: SPR-13418
Issue: SPR-13849
Issue: SPR-13850
Issue: SPR-13893
2016-01-26 18:06:15 +01:00
Sebastien Deleuze a730e55d92 Add support for Jackson 2.7
AbstractJackson2HttpMessageConverter now implements its own
TypeVariable resolution algorithm since in Jackson 2.7 it is now
deprecated and has not the same behavior .
See https://github.com/FasterXML/jackson-databind/issues/1087
for more details.

The dependency on jackson-datatype-jdk7 has been removed since
it is now provided by default in the jackson-databind module.

Issues: SPR-13483, SPR-13728
2016-01-25 09:38:16 +01:00
Rossen Stoyanchev d70ad765bf Support HTTP HEAD
Issue: SPR-13130
2016-01-24 20:18:41 -05:00
Rossen Stoyanchev 9cc518d167 Polish StringHttpMessageConverterTests 2016-01-22 09:40:33 -05:00
Rossen Stoyanchev 9e16cbda4c Polish ServletServerHttpRequest change 2016-01-20 17:50:36 -05:00
Sammy Chu 5185953f29 Avoid double encoding URI in ServletServerHttpRequest
Issue: SPR-13876
2016-01-20 17:42:40 -05:00
Rossen Stoyanchev a5f4aa6824 Add HttpStatus to ModelAndView
Issue: SPR-13560
2016-01-20 16:54:05 -05:00
Rossen Stoyanchev 73a794336c Support @ResponseStatus on controller type level
Issue: SPR-13547
2016-01-15 17:15:34 -05:00
Stephane Nicoll 2fc2c29e9a Update copyright header 2016-01-15 10:51:11 +01:00
Rossen Stoyanchev 037f351efd Replace anonymous impls with ListenableFutureAdapater
Before this change AsyncRestTemplate had two anonymous implementations
of ListenableFuture that were adapting the result. Those have been
replaces with ListenableFutureAdapter.

This commit is preparation for SPR-13785.
2016-01-14 16:47:55 -05:00
Ian Chan 93298fc9fa Catch RejectedExecutionException in WebAsyncManager
Issue: SPR-13836
2016-01-14 15:47:00 -05:00
Rossen Stoyanchev 7690f27c5e Add MediaType constants for application/pdf
Issue: SPR-13831
2016-01-14 14:57:09 -05:00
Rossen Stoyanchev f3c2bb6557 Fix error message in RestTemplate
Issue: SPR-13860
2016-01-14 14:52:10 -05:00
Rossen Stoyanchev e56587dcc3 Add note to @CrossOrigin javadoc
Issue: SPR-13857
2016-01-14 14:13:53 -05:00
Juergen Hoeller 773d175681 Polishing 2016-01-13 12:52:05 +01:00
Dennis Kieselhorst 554bf4958d Improve Content-Length exception message
In case ShallowEtagHeaderFilter is not used, the message was confusing
2016-01-08 09:30:31 +01:00
Brian Clozel cdda839426 XML configuration support for RFC 5861
This commit adds the XML+XSD configuration part of the RFC 5861
Cache-Control directives added in Spring's `CacheControl`.

Issue: SPR-13841
2016-01-07 18:13:34 +01:00
madorb 6c282096c6 Add RFC-5681 support to CacheControl
This commit adds the "stale-while-revalidate" and "stale-if-error"
Cache-Control directives in the `CacheControl` support class.

Issue: SPR-13841
2016-01-07 18:13:26 +01:00
Brian Clozel 9e4cf85af7 Add HTTP Status 451 UNavailable for legal reasons
Issue: SPR-13632
2015-12-29 20:51:42 +01:00
Rossen Stoyanchev 63958ac0ff Fix concurrent test failure
Since ListenableFuture callbacks are invoked after the future is set,
we cannot rely on callbacks having taken place right after a call
to future.get(). This change adds a CountdownLatch to detect when
the callbacks were invoked.

Issue: SPR-12538
2015-12-22 22:07:55 -05:00
Rossen Stoyanchev bc671f05d6 Fix test warnings 2015-12-22 17:52:56 -05:00
Rossen Stoyanchev 258cc7b27f Update AsyncRestTemplate interception
AsyncRequestExecution now properly supports decoration of the
request (URI, HTTP method, and headers).

Removed a no-op IdentityListenableFutureAdapter.

Use Spring Framework coding style.

Issue: SPR-12538
2015-12-22 17:36:24 -05:00
Jakub Narloch 12969f6268 SPR-12538 AsyncRestTemplate interceptors 2015-12-22 16:21:47 -05:00
Rossen Stoyanchev 12b73caa84 Add @RestControllerAdvice
Issue: SPR-13673
2015-12-22 16:11:34 -05:00
Juergen Hoeller 2e6eb614b5 Avoid scoped destruction callbacks in case of no post-processor actually applying
Issue: SPR-13744
2015-12-18 17:14:57 +01:00
Juergen Hoeller 3d87718fc6 DispatcherServlet and ServletWrapping/ForwardingController accept any HTTP method by default
Issue: SPR-4799
2015-12-18 12:57:18 +01:00
Juergen Hoeller 760668c034 Polishing 2015-12-18 00:09:39 +01:00
Sam Brannen 5b3edcd9f9 Spring Cleaning in December
- Delete unused imports
- Delete unused code
- Clean up warnings
2015-12-17 20:27:33 +01:00
Juergen Hoeller 8ce5e88c66 Require Jackson 2.6+, FreeMarker 2.3.21+, XStream 1.4.5+
Issue: SPR-13062
2015-12-17 17:14:50 +01:00
Juergen Hoeller 7f7f24949b Polishing 2015-12-09 15:13:41 +01:00
Juergen Hoeller 11806b9215 Class identity comparisons wherever possible (and further polishing)
Issue: SPR-12926
2015-12-09 12:28:09 +01:00
Juergen Hoeller 4261f34b63 Consistent and lenient HttpMethod resolution across all web modules
Issue: SPR-13776
2015-12-09 12:26:44 +01:00
Juergen Hoeller 1585a822d6 Javadoc fixes
Issue: SPR-13765
2015-12-07 12:50:23 +01:00
Juergen Hoeller b1ef6ece9f AbstractRequestLoggingFilter unwraps request to find ContentCachingRequestWrapper
Issue: SPR-13764
2015-12-07 12:47:38 +01:00
Juergen Hoeller 20beace1bf AnnotationConfigWebApplicationContext allows for custom AnnotatedBeanDefinitionReader/ClassPathBeanDefinitionScanner
Issue: SPR-9324
2015-12-07 12:46:32 +01:00
Juergen Hoeller d64ac32e3d ControllerAdviceBean accepts bean types without @ControllerAdvice annotation (as in 3.2)
Issue: SPR-13759
2015-12-04 13:03:00 +01:00