Commit Graph

2195 Commits

Author SHA1 Message Date
Brian Clozel
f89511e7fe Switch order of multipart Content-Type directives
Since SPR-15205, the `FormHttpMessageConverter` is adding a `charset`
directive to the `Content-Type` request header in order to help servers
understand which charset is being used to encode headers of each part.

As reported in SPR-17030 and others, some servers are not parsing
properly such header values and assume that `boundary` is the last
directive in the `Content-Type` header.

This commit reorders the charset information right before the boundary
declaration to get around those issues.

Issue: SPR-17030
(Cherry-picked from 390bb871d8)
2018-07-20 18:16:53 +02:00
Rossen Stoyanchev
f1c55a3b4a UriComponentsBuilder method to configure URI variables
See Javadoc on UriComponentsBuilder#uriVariables for details.

This helps to prepare for SPR-17027 where the MvcUriComponentsBuilder
already does a partial expand but was forced to build UriComonents
and then create a new UriComponentsBuilder from it to continue. This
change makes it possible to stay with the same builder instance.

Issue: SPR-17027
2018-07-19 19:07:22 -04:00
Rossen Stoyanchev
34a0cdfc33 Minor fixes: UriComponentsBuilder, UriComponents, docs
After the latest changes, two small fixes in the clone method to copy
the encode flag, and in the encodeUriTemplate method to account for
possible null query params.

Improvements in the URI encoding section.

Issue: SPR-17039, SPR-17027
2018-07-19 19:07:22 -04:00
Juergen Hoeller
11fc086309 Prefer ArrayList/ArrayDeque over LinkedList for multi-element holders
LinkedList remains in place where a List is likely to remain empty or single-element (in order to avoid unused capacity).

Issue: SPR-17037

(cherry picked from commit 9c08a48)
2018-07-19 00:08:13 +02:00
Juergen Hoeller
ed54895e53 Consistent exposure of nested parameter type in binding exceptions 2018-07-18 19:56:06 +02:00
Juergen Hoeller
c0040a5508 Polishing 2018-07-18 14:03:54 +02:00
Rossen Stoyanchev
d9d41b4398 Polish 2018-07-17 17:41:44 -04:00
Rossen Stoyanchev
2bf7c18203 Add TEMPLATE_AND_VALUES mode to DefaultUriBuilderFactory
Issue: SPR-17039
2018-07-16 21:25:09 -04:00
Rossen Stoyanchev
9458186e83 Polish DefaultUriBuilderFactory 2018-07-16 21:24:52 -04:00
Rossen Stoyanchev
d81ec55a60 Support for encode() in UriComponentsBuilder
The ability to request to encode before `build()`, and more importantly
before expanding, allows stricter encoding to be applied to URI vars
and consequently to neutralize the effect of characters with reserved
meaning in a URI.

Issue: SPR-17039
2018-07-16 21:24:16 -04:00
Rossen Stoyanchev
6218db9831 Backport of InMemoryWebSession changes
- hooks to check expired sessions in both create and retrieve.
- maxSessions limit on the total number of sessions.
- getSessions method for management purposes
- removeExpiredSessions public API

Issue: SPR-17020, SPR-16713
2018-07-12 16:27:42 -04:00
Rossen Stoyanchev
7ea8ecb6ab Warn when SimpleAsyncTaskExecutor is used
Issue: SPR-16203
2018-07-11 11:21:49 -04:00
Juergen Hoeller
0480e75785 Polishing 2018-07-03 16:23:43 +02:00
Juergen Hoeller
ac1e2879e5 Consistent throwing of HttpMessageNotReadableException (5.0.x revision)
Includes specific fine-tuning of ProtobufHttpMessageConverter and JAXB2 based message converters, as well as revised javadoc for abstract base classes.

Issue: SPR-16995
2018-07-03 16:23:36 +02:00
Juergen Hoeller
ea534b6820 Polishing 2018-06-29 20:07:53 +02:00
Juergen Hoeller
9a20ec9284 Polishing 2018-06-28 18:13:40 +02:00
Juergen Hoeller
6d0f8bf145 Support for new JsonMappingException wording in Jackson 2.9
Issue: SPR-16947
2018-06-28 16:42:35 +02:00
Juergen Hoeller
a631af80c1 Polishing
(cherry picked from commit 40efcc9)
2018-06-28 16:42:14 +02:00
Juergen Hoeller
e388ddfdde WebHttpHandlerBuilder retains ApplicationContext in copy constructor
Issue: SPR-16972

(cherry picked from commit 2a15962)
2018-06-28 16:41:13 +02:00
Brian Clozel
d1c9401dc2 WebClient writes Content-Length for Mono bodies
In SPR-16892, the `EncoderHttpMessageWriter` has been improved to write
`"Content-Length"` HTTP response headers if the response body is of type
`Mono` (i.e. the actual content length is easily accessible without
buffering a possibly large response body). That change was relying on
the fact that the server side is using a `ChannelSendOperator` to delay
the writing of the body until the first signal is received.

This strategy is not effective on the client side, since no such channel
operator is used for `WebClient`. This commit improves
`EncoderHttpMessageWriter` and delays, for `Mono` HTTP message bodies
only, the writing of the body so that we can write the
`"Content-Length"` header information once we've got the body resolved.

Issue: SPR-16949
(Cherry-picked from 4a26f93a0d)
2018-06-19 11:52:26 +02:00
Rossen Stoyanchev
425c311d3c Correctly set maxAge and expires in ResponseCookie
Issue: SPR-16940
2018-06-14 13:16:55 -04:00
Rossen Stoyanchev
49f21ac3ac Polish form writer and converter 2018-06-13 17:15:36 -04:00
Juergen Hoeller
224fcc1712 Remove outdated Servlet environment constraints from annotation javadoc
Includes removal of PathVariable's MultiValueMap support claim.

Issue: SPR-16936

(cherry picked from commit 0b64bcd)
2018-06-12 11:35:55 +02:00
Brian Clozel
96eba8b997 Fix ResourceRegion HttpMessageConverter write checks
This commit fixes the write checks for
`ResourceRegionHttpMessageConverter`, which was previously not checking
properly the parameterized type (e.g. in case of a `List<Something>`).

Issue: SPR-16932
(Cherry-picked from 05ff8b722d)
2018-06-11 22:57:36 +02:00
Brian Clozel
dac97f1b7d Restrict HTTP methods on Reactive HiddenHttpMethodFilter
This commit restricts the allowed HTTP methods on HiddenHttpMethodFilter
(Reactive variant) to the following: PUT, DELETE, PATCH.

This filter is meant to be used to simulate those methods from HTML
forms sent by browsers, so no other methods are allowed.

Issue: SPR-16836
(Cherry-picked from a5cd01a4c8)
2018-06-11 19:17:00 +02:00
Brian Clozel
f2694a8ed9 Restrict HTTP methods on Servlet HiddenHttpMethodFilter
This commit restricts the allowed HTTP methods on HiddenHttpMethodFilter
(Servlet variant) to the following: PUT, DELETE, PATCH.

This filter is meant to be used to simulate those methods from HTML
forms sent by browsers, so no other methods are allowed.

Issue: SPR-16836
(Cherry-picked from f64fa3dea1)
2018-06-11 19:16:44 +02:00
Sebastien Deleuze
b80c13b722 Deprecate JSONP and disable it by default in Jackson view
Issue: SPR-16798
2018-06-08 12:31:40 +02:00
Rossen Stoyanchev
7bfd683816 Eliminate the need for Encoder#getContentLength
Issue: SPR-16892
2018-06-04 16:01:48 -04:00
Juergen Hoeller
bbe5124556 Polishing 2018-05-29 22:16:48 +02:00
Juergen Hoeller
a2d7cc7a69 AbstractRequestLoggingFilter.isIncludeHeaders() declared as protected
Issue: SPR-16881

(cherry picked from commit c754232)
2018-05-29 22:00:24 +02:00
Rossen Stoyanchev
a158ff4c3d Return SslInfo only if X509Certificate[] present
Issue: SPR-16842
2018-05-23 14:58:23 -04:00
Rossen Stoyanchev
0b36c9437e CodecConfigurer internal refactoring
Improve how HTTP message writers are obtained for general use vs for
multipart requests.
2018-05-21 21:15:17 -04:00
Rossen Stoyanchev
72e7687b80 Polish CodecConfigurer related classes
Functionally equivalent updates to package private classes to improve
the code and make it easier to understand.
2018-05-21 21:15:05 -04:00
Rossen Stoyanchev
e3e975d7f9 Support for SslInfo in ServerHttpRequest#mutate
Issue: SPR-16830
2018-05-17 17:29:33 -04:00
Juergen Hoeller
41ab177b6c Fine-tuned assertions and related polishing 2018-05-05 14:59:13 +02:00
Juergen Hoeller
9dc538a7c6 Nullable HttpMethod parameter only on internal doExecute delegate
Issue: SPR-15540

(cherry picked from commit f8c2d7a)
2018-05-02 16:31:33 +02:00
Juergen Hoeller
d74a2730ec SimpleClientHttpResponse catches any Exception on close
Issue: SPR-16773

(cherry picked from commit 21fad8e)
2018-05-02 16:07:22 +02:00
Juergen Hoeller
3e47f4564d Fine-tuned assertions and related polishing in WebFlux builders
(cherry picked from commit 9bff5b4)
2018-05-02 16:04:51 +02:00
Juergen Hoeller
a9548f93e4 Support for non-standard HTTP status in reactive ClientHttpResponse
Issue: SPR-16748

(cherry picked from commit a683472)
2018-05-02 16:04:01 +02:00
Sebastien Deleuze
b55f69deb1 Support decoding Mono in Jaxb2XmlDecoder
Issue: SPR-16759
2018-05-02 11:57:40 +02:00
Rossen Stoyanchev
b0aa08a671 Consistent handling of URISyntaxException
Issue: SPR-16778
2018-04-30 21:05:08 -04:00
Johnny Lim
c6b60f0c00 Polish 2018-04-27 14:09:35 -04:00
sdeleuze
7aba6ca9d6 Fine tune WebFlux server logging verbosity
With this commit, WebFlux server uses warning instead of error log level
for request handling, and also just print the message instead of the
stacktrace which is mostly meaningless in reactive world.

Complementary to this change, Reactor Netty removed additional logging
as part of https://github.com/reactor/reactor-netty/issues/339.

Issue: SPR-16688
2018-04-27 10:36:06 +02:00
sdeleuze
df6e690e33 Reuse PartBodyStreamStorageFactory in SynchronossPartGenerator
Issue: SPR-16727
2018-04-26 11:01:17 +02:00
Rossen Stoyanchev
f7376bdde3 Better assertion message in MockPart
Issue: SPR-16767
2018-04-25 10:00:18 -04:00
Rossen Stoyanchev
66bd277671 Use StringDecoder to split SSE stream
ServerSentEventHttpMessageReader had logic to split on new lines
and buffer until an empty new line (start of a new event). To account
for random data chunking, it later re-assembled the lines for each
event and split again on new lines. However bufferUntil was still
unreliable a chunk may contain nothing but a newline, which doesn't
necessarily mean an empty newline in the overall SSE stream.

This commit simplifies the above by delegating the splitting of the
stream along newlines to StringDecoder.

Issue: SPR-16744
2018-04-19 11:38:43 -04:00
Rossen Stoyanchev
567733d2a1 Restore handling of 0 bytes read
Issue: SPR-16728
2018-04-16 10:01:51 -04:00
Rossen Stoyanchev
c4296fa785 Remove write pausing in Undertow response
Using the simple example shown in the ticket but switching from
Mono<String> to Flux<String> (and 5,000,000 onNext calls) shows that
constant pausing causes significant overhead and is not worth the
trouble vs ignoring the onWritePossible in REQUESTED state.

Issue: SPR-16702
2018-04-11 14:37:35 -04:00
Rossen Stoyanchev
ab78854f1b Avoid inifinite recursion in UndertowServerHttpResponse
Undertow does not provide a way to check if we can write so with the
current implementation of isWritePossible, deep recursion can occur
when writing slows down. We now use a flag to keep track of write
ChannelListener callbacks.

This commit also addresses a related issue in
AbstractListenerWriteProcessor that went undected since #3c2d186
where after a large (single) buffer that is not written fully, the
completion signal is processed before the all data is written.

Issue: SPR-16702
2018-04-11 14:37:19 -04:00
sdeleuze
eda2720471 Add default ctor to Reactive UrlBasedCorsConfigurationSource
Issue: SPR-16712
2018-04-11 14:41:06 +02:00