Commit Graph

914 Commits

Author SHA1 Message Date
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
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
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
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