Commit Graph

1446 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Brian Clozel
21053780ef Polish 2019-12-02 23:13:44 +01:00
Rossen Stoyanchev
acfeb77d41 Polishing
See gh-23961
2019-12-02 14:12:59 +00:00
Brian Clozel
d4209392d2 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-23961
2019-12-02 14:12:59 +00:00
Brian Clozel
1560bbd81e Revert "Allow ExchangeStrategies customizations in WebClient"
This reverts commit b3020bc484.
2019-12-02 10:39:53 +01:00
Brian Clozel
b3020bc484 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-23961
2019-11-29 22:26:52 +01:00
Rossen Stoyanchev
395c1e415c Polishing contribution
See gh-24074
2019-11-29 15:54:58 +00:00
Rossen Stoyanchev
b44daa8b71 Remove the few remaining usages of UriTemplate
Also update Javadoc of UriTemplate to point to UriComponentsBuilder and
UriBuilderFactory as more flexible options.

See gh-24094
2019-11-28 11:28:49 +00:00
Johnny Lim
4aa013c508 Remove duplicate checks in ResponseCookieTests 2019-11-28 07:15:15 +00:00
Rossen Stoyanchev
70a3dbff24 WebSession creation does not block
Closes gh-24027
2019-11-26 10:48:39 +00:00
Christoph Dreis
b234c77b67 Add missing verify() in EncoderHttpMessageWriterTests
Closes gh-24062
2019-11-25 10:51:00 +00:00
Rossen Stoyanchev
7bed4f36da Add missing verify() in Jackson2TokenizerTests
Closes gh-24056
2019-11-22 16:38:43 +00:00
Rossen Stoyanchev
21b2fc1f01 Improve HttpHandlerConnection completion
Before this commit the connector waited for a completed response (via
ServerHttpResponse#setComplete or ServerHttpResponse#writeWith) or an
error signal in handling, but it didn't deal explicitly with the case
where both can occur.

This commit explicitly waits for the completion of handling (success
or error) before passing the response downstream. If an error occurs
after response completion, it is wrapped in a dedicated exception that
also provides access to the completed response.

Close gh-24051
2019-11-22 10:28:05 +00:00
Rossen Stoyanchev
f4e0288357 Remove mentions of Tomcat async request timeout value
Close gh-24030
2019-11-19 17:08:43 +00:00
Juergen Hoeller
1607f1db0b Fix Checkstyle nohttp violation 2019-11-15 10:50:28 +01:00
Rossen Stoyanchev
c33cb26a73 Polishing contribution
See gh-1885
2019-11-14 17:38:01 +00:00
Mark Hobson
46fe74d2f9 Preserve media type parameters when setting charset
Issue: SPR-17040
2019-11-14 17:38:01 +00:00
Rossen Stoyanchev
04aa3d05da Refactor solution for respones error details
See gh-1956
2019-11-13 14:24:12 +00:00
jerzykrlk
91ec274b10 SPR-17130 http error details in the exception message 2019-11-13 14:24:12 +00:00
Rossen Stoyanchev
1261e64465 Minor refactoring
Apply default Accept header for HttpUrlConnection only.

See gh-23855
2019-11-08 08:44:04 +00:00
Lorenzo Torracchi
afae8c3045 Avoid default "Accept" from HttpUrlConnection
Closes gh-23740
2019-11-08 08:43:25 +00:00
Arjen Poutsma
bf36f49dc5 Corrupt multipart should not hang SynchronossPartHttpMessageReader
This commit notifies the Synchronoss listener that the buffer stream
has ended.

Closes gh-23768
2019-11-07 09:10:07 +01:00
Rossen Stoyanchev
3a241b546f Relax domain name checks in ResponseCookie
Closes gh-23924
2019-11-06 17:54:39 +00:00
Sam Brannen
29599a93a4 Re-enable support for invalid Expires attributes in MockCookie
Changes introduced in commit 9b2087618b
caused a regression for Cookie support in MockHttpServletResponse.
Specifically, an Expires attribute that cannot be parsed using
`ZonedDateTime.parse()` now results in an exception; whereas,
previously an entry such as `Expires=0` was allowed.

This commit fixes this issue in MockCookie by catching and ignoring any
DateTimeException thrown while attempting to parse an Expires attribute.

Closes gh-23911
2019-11-06 18:28:28 +01:00
Sam Brannen
92228f0fc0 Test status quo for @RequestHeader UUID conversion support
See gh-23939
2019-11-06 13:49:44 +01:00
Sam Brannen
9f00eb68e9 Clean up warnings 2019-10-30 19:14:58 +01:00
Sam Brannen
cef4478b7b Treat InvalidPathException like an IOException in MockServletContext
Prior to this commit, if MockServletContext was configured with a
FileSystemResourceLoader, invocations of the following methods on a
Microsoft Windows operating system resulted in an InvalidPathException
if the supplied path contained a colon (such as "C:\\temp"). This is
inconsistent with the behavior on non-Windows operating systems. In
addition, for comparable errors resulting in an IOException, those
methods (except getRealPath()) return null instead of throwing the
exception.

- getResourcePaths()
- getResource()
- getResourceAsStream()
- getRealPath()

This commit makes handling of InvalidPathException and IOException
consistent for these methods: both exceptions now result in null be
returned by these methods.

Closes gh-23717
2019-10-30 15:59:44 +01:00
Rossen Stoyanchev
34cfbe5d26 ResponseStatusException associated headers
A ResponseStatus exception now exposes extra method to return headers
for the response. This is used in ResponseStatusExceptionHandler to
apply the headers to the response.

Closes gh-23741
2019-10-30 12:10:45 +00:00
Juergen Hoeller
046380988b Nullability refinements 2019-10-30 00:26:11 +01:00
Rossen Stoyanchev
5abf24e7d7 Expose maxInMemorySize via CodecConfigurer
Centralized maxInMemorySize exposed via CodecConfigurer along with
ability to plug in an instance of MultipartHttpMessageWrite.

Closes gh-23884
2019-10-29 12:33:16 +00:00
Rossen Stoyanchev
00ead7a756 Refine multipart parsing limits
See gh-23884
2019-10-29 12:33:16 +00:00