Commit Graph

623 Commits

Author SHA1 Message Date
Rossen Stoyanchev
410fc6d763 UriComponentsBuilder.fromHttpRequest sets port correctly
Cherry-picked from commit d64c48 on master

Issue: SPR-12771
2015-03-05 21:54:46 -05:00
Juergen Hoeller
7eb4679f28 RestTemplate avoids use of warn level for response errors
Protected handleResponse method replaces former private logResponseStatus/handleResponseError methods.

Issue: SPR-12760
(cherry picked from commit 594a14a)
2015-02-27 22:33:55 +01:00
Juergen Hoeller
6be554cba5 Polishing
(cherry picked from commit cc33d3f)
2015-02-25 20:38:18 +01:00
Juergen Hoeller
d77af71e9c Revised common validation methods in AbstractMessageConverterMethodArgumentResolver
The protected validation methods are analogous to ModelAttributeMethodProcessor now.

Issue: SPR-12655
(cherry picked from commit 7191050)
2015-02-19 23:53:16 +01:00
Sebastien Deleuze
5db4e4bab0 Adjust log level for invalid SockJS or Websocket requests 2015-02-19 16:06:06 +01:00
Sebastien Deleuze
7cc56e1630 Improve error handling in WebUtils.isValidOrigin()
With this commit, WebUtils.isValidOrigin() logs an error message instead
of throwing an IllegalArgumentException when Origin header value is
invalid (for example when it does not contain the scheme).

Issue: SPR-12697
2015-02-19 14:12:10 +01:00
Juergen Hoeller
8dbe753963 Polishing 2015-02-18 17:54:16 +01:00
Sebastien Deleuze
23fa37b08b Change SockJS and Websocket default allowedOrigins to same origin
This commit adds support for a same origin check that compares
Origin header to Host header. It also changes the default setting
from all origins allowed to only same origin allowed.

Issues: SPR-12697, SPR-12685
(cherry picked from commit 6062e15)
2015-02-18 17:26:55 +01:00
Juergen Hoeller
fab8dd3d0b Combined backport of Jackson configuration enhancements: Locale/TimeZone settings, refined module configuration
Issue: SPR-12594
Issue: SPR-12634
2015-02-11 19:03:54 +01:00
Juergen Hoeller
0706889222 Polishing
(cherry picked from commit 058714b)
2015-02-10 22:58:16 +01:00
Juergen Hoeller
25644dbdb9 Revised validation javadoc, plus protected validate/isBindingErrorFatal template methods
Issue: SPR-12655
(cherry picked from commit 7585be8)
2015-02-10 22:00:11 +01:00
Rossen Stoyanchev
4a423e50a8 Add fromHttpRequest to UriComponentsBuilder
Before this change, detection of X-Forwarded-* headers was only built
into ServletUriComponentsBuilder.

This change adds a new method for creating a UriComponentsBuilder from
an existing HttpRequest. This is equivalent to the fromUri method +
X-Forwarded-* header values.
2015-02-10 06:54:10 +01:00
Brian Clozel
0225a7776c Revisit empty body response support in HTTP client
Prior to this commit, HTTP responses without body (response status 204
or 304, Content-Length: 0) were handled properly by RestTemplates. But
some other cases were not properly managed, throwing exceptions for
valid HTTP responses.

This commit better handles HTTP responses, using a response wrapper that
can tell if a response:

* has no message body (HTTP status 1XX, 204, 304 or Content-Length:0)
* has an empty message body

This covers rfc7230 Section 3.3.3.

Issue: SPR-8016
2015-02-09 15:10:39 +01:00
Brian Clozel
4550b4a254 Avoid loss of body content in AbstractRequestLoggingFilter
Prior to this commit, the `ContentCachingRequestWrapper` class would
cache the response content only if the reponse would be consumed using
its InputStream. In case of a Form request, Spring MVC consumes the
response using the `getParameter*` Servlet API methods. This causes the
cached content to never be written.

This commit makes the `ContentCachingResponseWrapper` write the request
body to the cache buffer by using the `getParameter*` API, thus avoiding
those issues.

Issue: SPR-7913
2015-02-09 15:08:35 +01:00
Stephane Nicoll
7ffa845aa8 Fix broken build
Add required  `@Deprecated` annotation.
2015-02-09 10:19:41 +01:00
Rossen Stoyanchev
49c21a0a06 Update javadoc for MultipartFile.transferTo
Issue: SPR-12650
2015-02-02 17:30:34 -05:00
Rossen Stoyanchev
d9d8a79c30 Update Netty4ClientHttpRequestFactory buffer size
This change deprecates the maxRequestSize property and adds
maxResponseSize instead. The latter is required to create Netty's
HttpObjectAggregator and aggregates responses.

The maxRequestSize property is already removed in the master branch
and will not be available starting with 4.2.

Issue: SPR-12623
2015-02-02 16:15:42 -05:00
Juergen Hoeller
bfba988a0d AbstractRequestLoggingFilter allows for dedicated shouldLog check in CommonsRequestLoggingFilter
Issue: SPR-12609
(cherry picked from commit d4dac25)
2015-01-21 12:34:05 +01:00
Juergen Hoeller
8c700b19da Polishing 2014-12-30 21:04:28 +01:00
Juergen Hoeller
dcb821edb5 Polishing
(cherry picked from commit 730bd02)
2014-12-30 15:07:19 +01:00
Juergen Hoeller
86b8112c90 Polishing 2014-12-29 15:13:40 +01:00
Stephane Nicoll
71783c5d86 Allow default settings of a custom HttpClient to apply
Previously the default settings of a custom HttpClient were always
ignored since a RequestConfig instance was always set no matter if
some customizations were applied or not.

This commit keeps an internal RequestConfig object instance that is
only initialized if the user applies a customization. If he does not, the
default settings of the HttpClient are used as it should.

Note that if the HttpComponents API exposed the default RequestConfig
of a given HttpClient, we would be able to merge our customizations with
the one specified by the client. Unfortunately, such API does not exist
and the "defaultSettingsOfHttpClientLostOnExecutorCustomization" test
illustrates that limitation.

Issue: SPR-12540
2014-12-29 09:36:54 +01:00
Rossen Stoyanchev
ea05e0b1ad Improve @SessionAttributes support during redirect
Before this change attributes listed with @SessionAttributes would not
be saved in the session when there was a redirect and the controller
method declared a parameter of type RedirectAttributes.

This change ensures it's the "default" model that is always the one
checked for @SessionAttributes under all circumstances since
RedirectAttributes is really only meant to provide String values to
insert into or append to the the redirect URL.

Issue: SPR-12542
2014-12-23 14:24:44 -05:00
Rossen Stoyanchev
ea2943feca Polish ModelAndViewContainer and update tests 2014-12-23 14:24:43 -05:00
Juergen Hoeller
c114c08922 Preparations for Jackson 2.5
Issue: SPR-12565
2014-12-22 18:46:57 +01:00
Stephane Nicoll
aafdcecf53 Customize connection request timeout
Prior to this commit it was not possible to easily customize the
connection request timeout used by the HttpClient. Both
`HttpComponentsClientHttpRequestFactory` and
`HttpComponentsClientHttpRequestFactoryTests` have been updated to
support a `connectionRequestTimeout` property.

Issue: SPR-12166
2014-12-22 16:31:07 +01:00
Stephane Nicoll
24b82746b5 Polish upgrade to HttpComponents 4.3
Polish fbe605123 to make explicit the fact that a null RequestConfig
can be used to force the defaults of the current HttpClient.

Issue: SPR-11113
2014-12-22 14:31:24 +01:00
Stephane Nicoll
fbe6051233 Upgrade HttpComponentsHIRE to HttpComponents 4.3
Previously, HttpComponentsHttpInvokerRequestExecutor was not compatible
with the new API of HttpComponents 4.3. Specifically, it is not possible
to update the socket and read timeouts on the HttpClient itself anymore.

We actually already updated HttpComponentsClientHttpRequestFactory for a
similar problem in SPR-11442: if we detect an older HttpClient
implementation, we update the timeout directly on the client. If that's
not the case, we keep the value in the factory itself and use it when a
new HttpRequest needs to be created.

This commit also uses the new API to create a default HttpClient and
therefore requires HttpComponents 4.3. As mentioned above, it is still
possible to use deprecated HttpClient instances against this executor.

Issue: SPR-11113
2014-12-22 11:02:32 +01:00
Rossen Stoyanchev
0524a82c09 Update unprocessableEntity to allow body
Issue: SPR-12515
2014-12-08 16:19:52 -05:00
Juergen Hoeller
1daa5eb383 ResponseEntity provides static "unprocessableEntity()" convenience method as well
Issue: SPR-12515
2014-12-07 15:34:39 +01:00
Rossen Stoyanchev
189ec75789 Add ability to clone to UriComponentsBuilder hierarchy
Issue: SPR-12494
2014-12-05 12:16:15 -05:00
Sebastien Deleuze
2fccf3ff44 Add support for autowiring Jackson handlers
This commit introduces the SpringHandlerInstantiator
class, a Jackson HandlerInstantiator that allows to autowire
Jackson handlers (JsonSerializer, JsonDeserializer, KeyDeserializer,
TypeResolverBuilder and TypeIdResolver) if needed.

SpringHandlerInstantiator is automatically used with
@EnableWebMvc and <mvc:annotation-driven />.

Issue: SPR-10768
2014-12-05 17:37:28 +01:00
Juergen Hoeller
d1f8968595 ControllerAdvice basePackages specifically refer to actual packages (avoiding accidental prefix matches with other packages)
Issue: SPR-12509
2014-12-05 13:25:48 +01:00
Brian Clozel
98870251f9 Better empty response body support in RestTemplate
Prior to this change, RestTemplate returned an empty response body if:

* HTTP return status 204 or 304
* Content-length header equals 0

This change adds a new condition for this, better supporting RFC7230
section 3.4, for connections that are closed without response body:

* No Content-length header
* No Transfer-encoding: chunked header value
* a Connection: close header value

See SPR-7911 for previous efforts in that space.

Issue: SPR-8016
2014-12-05 09:57:41 +01:00
Brian Clozel
b2878a4f60 Merge pull request #704 from aantono/master
Fixed the output stream incomplete data by explicitly flushing the OutputStreamWriter
2014-12-05 09:51:55 +01:00
Alex Antonov
bf8d99d7e4 Fixed the output stream incomplete data by explicitly flushing the OutputStreamWriter 2014-12-04 16:46:15 -06:00
Juergen Hoeller
4013fe03a5 Revised ControllerAdvice basePackages handling (based on package names instead of java.lang.Package)
Issue: SPR-12506
2014-12-04 17:56:01 +01:00
Alex Antonov
b041cffe5d Fix for NPE when creating ProtobufHttpMessageConverter without ExtensionRegistryInitializer 2014-12-03 12:26:18 -06:00
Sebastien Deleuze
fbd85925de Use Jackson improved default configuration everywhere
With this commit, Jackson builder is now used in spring-websocket
to create the ObjectMapper instance.

It is not possible to use the builder for spring-messaging
and spring-jms since these modules don't have a dependency on
spring-web, thus they now just customize the same features:
 - MapperFeature#DEFAULT_VIEW_INCLUSION is disabled
 - DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES is disabled

Issue: SPR-12293
2014-12-03 09:49:41 +01:00
Roy Clarkson
83ecf5ca1d Fix issue where FormHttpMessageConverter fails to write multipart data
FormHttpMessageConverter incorrectly determines that the media type
"multipart/form-data; charset=utf-8" is not multipart. This commit
allows the media type to contain a charset parameter.
2014-12-02 16:06:49 -05:00
Juergen Hoeller
2496d68e9f Relaxed final declarations and protected doInvoke methods
Issue: SPR-12484
2014-12-01 15:07:24 +01:00
Juergen Hoeller
decc5cd1ae Extracted ContentCachingRequestWrapper and ContentCachingResponseWrapper
Issue: SPR-12477
2014-11-28 17:17:02 +01:00
Juergen Hoeller
a6e7044523 Correct since declarations in Netty 4 client support 2014-11-26 11:29:58 +01:00
Juergen Hoeller
929cda6790 Allow custom @Validated annotations for handler method parameters
Issue: SPR-12406
2014-11-24 23:34:24 +01:00
Juergen Hoeller
aadb93f30c Rearranged WebAsyncTask constructor interdependencies and assertions
Issue: SPR-12457
2014-11-22 18:02:12 +01:00
Juergen Hoeller
05bdc2cf77 Consistent declaration and use of UTF-8 Charset constants, plus related polishing 2014-11-11 02:38:30 +01:00
Rossen Stoyanchev
53eec48ffd Fix HttpUrlConnection DELETE without body
The following commit allowed HTTP DELETE with body:
584b831bb9

However it broke buffered requests even without a body since JDK 1.6
and 1.7 do not support calls to getOutputStream with HTTP DELETE.

This commit set the doOutput flag back to false if the actual buffered
body is 0 length.

Issue: SPR-12361
2014-11-10 14:20:59 -05:00
Juergen Hoeller
bf9295bec3 ShallowEtagHeaderFilter skips "Cache-Control" header check on Servlet 2.5
Issue: SPR-12414
2014-11-06 22:48:08 +01:00
Rossen Stoyanchev
d8941ca098 Normalize 2+ '/' in path in UriComponentsBuilder
Issue: SPR-12398
2014-10-30 14:51:04 -04:00
Juergen Hoeller
1146d5ba1d Polishing 2014-10-29 22:44:59 +01:00