Commit Graph

3083 Commits

Author SHA1 Message Date
Rossen Stoyanchev c69703ffdb Deprecate path extension strategies
This commit deprecates PathExtensionContentNegotiationStrategy and
ServletPathExtensionContentNegotiationStrategy and also updates code
that depends on them internally to remove that dependence.

See gh-24179
2020-01-22 13:35:09 +00:00
Rossen Stoyanchev 542e187831 Expose media type mappings in ContentNegotiationManager
ContentNegotiationManagerFactoryBean now ensures that
ContentNegotiationManager contains the MediaType mappings even if the
path extension and the parameter strategies are off.

There are also minor fixes to ensure the media type mappings in
ContentNegotiationManagerFactoryBean aren't polluted when mapping keys
are not lowercase, and likewise MappingMediaTypeFileExtensionResolver
filters out duplicates in the list of all file extensions.

See gh-24179
2020-01-22 13:35:09 +00:00
Rossen Stoyanchev 214ba63127 Deprecate config options for content negotiation by path extension
See gh-24179
2020-01-22 13:35:09 +00:00
Arjen Poutsma 54669c51c9 Use Jackson SequenceWriter for streaming
Before this commit, the AbstractJackson2Encoder instantiated a
ObjectWriter per value. This is not an issue for single values or
non-streaming scenarios (which effectively are the same, because in the
latter values are collected into a list until offered to Jackson).
However, this does create a problem for SMILE, because it allows for
shared references that do not match up when writing each value with a
new ObjectWriter, resulting in errors parsing the result.

This commit uses Jackson's SequenceWriter for streaming scenarios,
allowing Jackson to reuse the same context for writing multiple values,
fixing the issue described above.

Closes gh-24198
2020-01-21 14:22:00 +01:00
Rossen Stoyanchev 5e9d29d813 Ability to customize default Smile codecs
Closes gh-24382
2020-01-20 17:29:59 +00:00
Rossen Stoyanchev 5d8c5b0d9b Avoid NPE on comment SSE event
Closes gh-24389
2020-01-20 11:26:58 +00:00
Brian Clozel 59bef22235 Avoid setting special Content-* response headers for Tomcat
As of gh-21783, Spring WebFlux uses a `TomcatHeadersAdapter`
implementation to directly address the native headers used by the
server.

In the case of Tomcat, "Content-Length" and "Content-Type" headers are
processed separately and should not be added to the native headers map.

This commit improves the `HandlerAdapter` implementation for Tomcat and
removes those headers, if previously set in the map. The adapter
already has a section that handles the Tomcat-specific calls for such
headers.

Fixes gh-24361
2020-01-17 15:01:58 +01:00
Rossen Stoyanchev ac8eaca475 HttpWebHandlerAdapter#formatRequest is protected
Closes gh-24352
2020-01-16 14:54:29 +00:00
Sam Brannen 1c270d8d06 Fix Checkstyle violation 2020-01-13 18:21:36 +01:00
Rossen Stoyanchev 29fe65d23c Upgrade to Dysprosium snapshots
See gh-24349
2020-01-13 16:49:42 +00:00
Rossen Stoyanchev cbc57460b7 Support for maxInMemorySize in SSE reader
Closes gh-24312
2020-01-13 14:57:14 +00:00
Sébastien Deleuze bc7d010485 Update CORS support
This commit updates CORS support in order to check Origin header
in CorsUtils#isPreFlightRequest which does not change how Spring
MVC or WebFlux process CORS request but is more correct in term
of behavior since it is a public API potentially used in another
contexts.

It also removes an unnecessary check in
AbstractHandlerMethodMapping#hasCorsConfigurationSource and processes
every preflight request with PreFlightHandler.

Closes gh-24327
2020-01-13 08:33:14 +01:00
Juergen Hoeller 4936a637fe Polishing 2020-01-09 17:03:17 +01:00
Rossen Stoyanchev 08e9372ded Restore response after beforeCommit action errors
See gh-24186
2020-01-09 11:10:44 +00:00
Rossen Stoyanchev 01827389ef Polishing contribution
See gh-24292
2020-01-08 16:19:25 +00:00
Oleh Faizulin e96b71acf3 contentLength support for Resource decoding
Expose the known content length, if known, in the InputStreamResource returned by ResourceHttpMessageConverter or
ResourceDecoder.

See gh-24292
2020-01-08 16:19:11 +00:00
Rossen Stoyanchev 9d963abb7d Concrete MediaType check in StringHttpMessageConverter
Closes gh-23287
2020-01-07 15:02:39 +00:00
Brian Clozel ffc1f960f9 Polish
See gh-24238
2020-01-07 09:05:49 +01:00
Rossen Stoyanchev ea6d2ea1ce Multi-value headers in ResponseStatusException
Closes gh-24261
2020-01-06 22:13:55 +00:00
Brian Clozel f9c1565f4e Remove Content-* response headers for error handling
Prior to this commit, when WebFlux handlers added `"Content-*"` response
headers and an error happened while handling the request, all those
headers would not be cleared from the response before error handling.

This commit clears those headers from the response in two places:
* when invoking the handler and adapting the response
* when writing the response body

Not removing those headers might break HTTP clients since they're given
wrong information about how to interpret the HTTP response body: the
error response body might be very different from the original one.

Fixes gh-24238
2020-01-06 16:55:08 +01:00
Rossen Stoyanchev 03ea92df99 Improve RestClientException Javadoc
Closes gh-24288
2020-01-03 11:12:01 +00:00
Sam Brannen 7b6d83a106 Use Gradle test fixture support for spring-web
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 726b1bb1d0 Rename test fixture package in spring-context
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 7cd4ddf5fc Rename test fixture package in spring-beans
See gh-23550
2020-01-02 16:01:35 +01:00
Sam Brannen 4260c34b47 Rename test fixture package in spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 61d4ee594d Use Gradle test fixture support for spring-beans and spring-context
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen 5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Rossen Stoyanchev 956ffe6858 ContentDisposition refactoring
See gh-24220
2019-12-26 17:30:15 +00:00
Rossen Stoyanchev 261956fd08 Improve UriBuilder Javadoc on query params
Add a note on encoding for query parameters specifically mentioning the
"+" sign and a link to the reference docs.

Also remove duplicate Javadoc in UriComponentsBuilder which is already
inherited from UriBuilder.
2019-12-20 11:03:08 +00:00
Rossen Stoyanchev ea4f1ca5d5 Update ContentDisposition to RFC 6266
Close gh-24231
2019-12-19 16:27:40 +00:00
Rossen Stoyanchev 15321a3163 Fix checkstyle violations 2019-12-19 13:06:53 +00:00
Rossen Stoyanchev 41f40c6c22 Escape quotes in filename
Closes gh-24220
2019-12-19 12:23:12 +00:00
Rossen Stoyanchev 0eacb443b0 Reuse InputStream in ResourceRegionHttpMessageConverter
The converter now tries to keep reading from the same InputStream which
should be possible with ordered and non-overlapping regions. When
necessary the InputStream is re-opened.

Closes gh-24214
2019-12-18 16:22:53 +00:00
Rossen Stoyanchev 1dd0a0f009 Fix since tags from prior commit 2019-12-12 22:03:38 +00:00
Rossen Stoyanchev b23617637d Fix cloning issue in CodecConfigurer for multipart writers
Closes gh-24194
2019-12-12 21:58:14 +00:00
Rossen Stoyanchev 11e321b8e7 Add register methods to CodecConfigurer.CustomCodecs
The new register methods replace the now deprecated
encoder, decoder, reader, and writer methods, and also offer a choice
to opt into default properties such maxInMemorySize, if configured.

See gh-24124
2019-12-12 21:58:14 +00:00
Rossen Stoyanchev 9d65830133 CodecConfigurer implementation refactoring
See gh-24124
2019-12-12 21:57:45 +00:00
Rossen Stoyanchev 9b30d46ff4 JSON charset handling in StringHttpMessageConverter
This commit restores the interpretation of JSON as UTF-8 by default that
was removed in #bc205e0 and also ensures a charset is not appended
automatically to "application/json".

Closes gh-24123
2019-12-10 16:52:23 +00:00
Rossen Stoyanchev c8bce9686f ContentDisposition trims charset in filename
Closes gh-24112
2019-12-10 15:38:28 +00:00
Rossen Stoyanchev f180bf7652 Add "application/*+xml" to XML decoders
Closes gh-24164
2019-12-10 15:18:04 +00:00
Rossen Stoyanchev 1b172c1d20 Expose localAddress in WebFlux server
Closes gh-24174
2019-12-10 15:10:13 +00:00
Johnny Lim 1e83e889aa Use hasSize() where possible
See gh-24172
2019-12-10 07:58:53 +01:00
Juergen Hoeller 119dd04ae5 Avoid ByteArrayOutputStream for source values without the need to be encoded
Closes gh-24152
2019-12-09 13:28:39 +01:00
Sam Brannen fc42ca2866 Polish contribution
See gh-24157
2019-12-07 13:41:43 +01:00
yokotaso d7d474f658 Do not cache prototype @ControllerAdvice beans
Spring Framework 5.2 introduced support for caching @ControllerAdvice
beans; however, this caching was also applied incorrectly to
non-singleton beans.

This commit addresses this regression by only caching singleton
@ControllerAdvice beans.

Closes gh-24157
2019-12-07 13:39:30 +01:00
stsypanov 484006ce90 Hoist Class.getName() from String concatenation to dodge an issue related to profile pollution 2019-12-06 17:36:07 +01:00
Rossen Stoyanchev b866d4209c Add UriUtils.encodeQueryParams
Closes gh-24043
2019-12-04 17:33:31 +00:00
Brian Clozel 21053780ef Polish 2019-12-02 23:13:44 +01:00
Brian Clozel decbb9ccf9 Provide default codecs config callback to custom codecs
As a follow-up of gh-23961, this change provides a way for custom codecs
to align with the default codecs' behavior on common features like
buffer size limits and logging request details.

Closes gh-24118
Co-authored-by: Rossen Stoyanchev <rstoyanchev@pivotal.io>
2019-12-02 22:52:55 +01:00
Rossen Stoyanchev acfeb77d41 Polishing
See gh-23961
2019-12-02 14:12:59 +00:00