Commit Graph

566 Commits

Author SHA1 Message Date
Rossen Stoyanchev a9a068e678 SPR-8867 Fix issue with Content-Length header and UTF-8 charset.
The AbstractHttpMessageConverter was using the requested Content-Type
rather than the actual response Content-Type to determine the length
of the content. This can lead to a problem when a controller returns
a ResponseEntity with a Content-Type header that ignores (overrides)
the requested Content-Type. The fix ensures that actual response 
Content-Type is the one used both to write to the response and to 
determine the length of the content.
2011-11-28 18:42:57 +00:00
Juergen Hoeller b55040cf02 Servlet/PortletContextResource's getFile prefers "file:" URL resolution over calling getRealPath (SPR-8461) 2011-11-28 16:51:42 +00:00
Juergen Hoeller 3f7dccddd2 added getObjectMapper() accessor to MappingJacksonHttpMessageConverter (SPR-8605) 2011-11-28 14:34:59 +00:00
Rossen Stoyanchev 947b5fefff SPR-8851 Switch to logging debug messages in AbstractWebArgumentResolverAdapter 2011-11-18 16:18:55 +00:00
Rossen Stoyanchev 60ee0bb8f4 SPR-8020 Support UriComponentsBuilder as a controller method argument.
The UriComponentsBuilder instance passed into the method is initialized
with current request information including host, scheme, port, context
path, and the servlet mapping's literal part.

Also added shortcut methods to buildAndExpand in UriComponentsBuilder.
2011-11-18 14:36:44 +00:00
Rossen Stoyanchev 01cc76f8e3 SPR-8697 Flag '*/subtype' as illegal. 2011-11-17 20:15:49 +00:00
Rossen Stoyanchev 63e235f215 SPR-8750 Refine 'Content-Type' update in MockHttpServletRequest/Response.
The initial solution kept these three in full sync at all times:
contentType field, characterEncoding field, 'Content-Type' header.
That is correct behavior, however it breaks existing tests that rely
on contentType and characterEncoding being equal to exactly what 
they were set to.

For example, consider:
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");

Ideally both contentType and the 'Content-Type' header would now be
"text/plain;charset=UTF-8". However, existing tests would expect 
that contentType is equal to "text/plain".

To avoid breaking existing tests, contentType and characterEncoding
will continue to be equal to exactly what they were set to while
the 'Content-Type' header will always include both the content 
type and the charset.

The only exception to this rule is when a 'Content-Type' header
is set explicitly, the contentType and characterEncoding fields will 
be updated accordingly, possibly overriding the existing values.
2011-11-17 15:07:15 +00:00
Rossen Stoyanchev 7918810366 SPR-8750 Update MockHttpServletRequest/Response handling of contentType.
The Content-Type header and the contentType field in HttpServletRequest/Response
are now always in sync. When a header is added the contentType field is updated
as well and vice versa. 

Similarly when the Content-Type header or the contentType field includes a charset 
field, the character encoding is updated and vice versa.
2011-11-16 23:28:48 +00:00
Chris Beams 70c28a0bc5 Add Apache license header where missing in src/main 2011-11-16 18:23:56 +00:00
Rossen Stoyanchev 2a39f34d33 SPR-8803 Refine UriComponentsBuilder.replaceQueryParam().
If no values are given, the query parameter is removed.
2011-11-10 15:08:24 +00:00
Rossen Stoyanchev c9acaaf9d8 SPR-8823 ServletUriComponentsBuilder polish and reference doc update. 2011-11-08 17:49:38 +00:00
Rossen Stoyanchev d1d48ac940 SPR-8823 Add ServletUriComponentsBuilder. 2011-11-07 21:04:23 +00:00
Rossen Stoyanchev bef75aab07 Polish synchronization of model attributes with the session. 2011-11-04 22:14:13 +00:00
Rossen Stoyanchev d3f4c69f00 SPR-8803 Add UriComponentsBuilder methods to replace path/query. 2011-11-04 16:43:03 +00:00
Arjen Poutsma 78fbceff82 Added check for illegal characters when creating an encoded UriComponents object 2011-11-03 11:57:25 +00:00
Arjen Poutsma e8dd35ce5e Added check for expanding already encoded UriComponents object 2011-11-02 11:49:45 +00:00
Rossen Stoyanchev 1164f5a9fc SPR-8782 Raise helpful error when RedirectAttributes is used with old infrastructure classes. 2011-11-01 11:46:09 +00:00
Juergen Hoeller 2fdc2b5822 fixed StandardServlet/PortletEnvironment to check for JNDI (for Google App Engine compatibility) 2011-10-20 10:46:16 +00:00
Juergen Hoeller ca5f38c5e4 marked Apache HttpComponents dependency as optional (SPR-8788); cleanup of conversation dependencies 2011-10-20 09:55:09 +00:00
Chris Beams f60a40be44 Polish Environment subsystem Javadoc 2011-10-11 18:51:26 +00:00
Juergen Hoeller 0d02ef5fe5 removed conversation prototype from 3.1 codebase 2011-10-11 16:22:15 +00:00
Rossen Stoyanchev b08c7f6e00 SPR-6801 @ModelAttribute instantiation refinement.
Instantiate the model attribute from a URI var or a request param only
if the name matches and there is a registered Converter<String, ?>.
2011-09-27 22:48:12 +00:00
Arjen Poutsma 5afe139285 SPR-8706 - UriUrils.decode() not properly rejecting invalid escaped URLs 2011-09-27 08:55:07 +00:00
Arjen Poutsma 67fda70cb8 SPR-8713 - DefaultResponseErrorHandler IOException Bug 2011-09-27 08:16:33 +00:00
Rossen Stoyanchev 48f7dcc464 POLISH CREATION OF DATA BINDERS FOR @RequestMapping METHODS
Make it possible to hook in custom ServletRequestDataBinderFactory
by overriding RequestMappingHandlerAdapter. 

Create ExtendedServletRequestDataBinder to add URI template vars
to the binding values taking advantage of a new extension hook in
ServletRequestDataBinder to provide additional values to bind.
2011-09-26 09:27:09 +00:00
Rossen Stoyanchev 6bc4ea058c POLISH ARGUMENT RESOLVERS AND RETURN VALUE HANDLERS. 2011-09-24 11:34:07 +00:00
Rossen Stoyanchev fb526f534a SPR-8700 REFINE ORDER OF ARGUMENT RESOLUTION AND RETURN VALUE HANDLING.
1. Consider single-purpose return value types like HttpEntity, Model,
View, and ModelAndView ahead of annotations like @ResponseBody and
@ModelAttribute. And reversely consider multi-purpose return value 
types like Map, String, and void only after annotations like
@RB and @MA.

2. Order custom argument resolvers and return value handlers after the
built-in ones also clarifying the fact they cannot be used to override
the built-in ones in Javadoc throughout.

3. Provide hooks in RequestMappingHandlerAdapter that subclasses can use
to programmatically modify the list of argument resolvers and return
value handlers, also adding new getters so subclasses can get access
to what they need for the override.

4. Make SessionStatus available through ModelAndViewContainer and 
provide an argument resolver for it.

5. Init test and javadoc improvements.
2011-09-22 16:00:22 +00:00
Rossen Stoyanchev 7a3f02bce9 SPR-8688 Don't use Servlet request params for form 'PUT' in ServletServerHttpRequest. 2011-09-20 09:18:47 +00:00
Rossen Stoyanchev 71cc38aaff SPR-6464 Update reference doc with FlashMap and RedirectAttributes information. 2011-09-16 16:44:11 +00:00
Rossen Stoyanchev b2d88ba858 SPR-6464 Polish following code review. 2011-09-15 18:12:30 +00:00
Arjen Poutsma aeba9d244a SPR-5973: now dealing with path followed by segments (and vice-versa) correctly. 2011-09-15 10:24:21 +00:00
Arjen Poutsma 38f05678c1 SPR-5973: UriComponents now encapsulates uri template variables 2011-09-14 14:36:49 +00:00
Arjen Poutsma 3f2ea7f50e SPR-5973: UriComponents now encapsulates a PathCompont, switching between string paths and path segment lists automatically. 2011-09-14 14:09:57 +00:00
Arjen Poutsma 1b61f27f5b polishing 2011-09-14 14:01:21 +00:00
Arjen Poutsma 663f056329 SPR-5973: UriComponents no longer a Map, moved all static methods from UriComponents to builder, added expand method to UriComponents 2011-09-13 14:12:54 +00:00
Rossen Stoyanchev 28a696ba51 SPR-8676 Fix minor issue in how ServletServletHttpRequest detects form content-type requests 2011-09-13 12:35:05 +00:00
Rossen Stoyanchev 2799e710bc SPR-6464 Add 'setAlwaysUseRedirectAttributes' flag.
When set to 'true' the flag makes RedirectAttributes the only way to add 
attributes for a redirect thus ignoring the content of the default model 
even if RedirectAttributes is not in the list of controller method args.
2011-09-13 07:53:17 +00:00
Arjen Poutsma c8add61a72 SPR-5973: Using UriComponents in more places, replaced UriBuilder by UriComponentsBuilder, UriComponents is now immutable. 2011-09-12 14:39:58 +00:00
Arjen Poutsma f0ed37c233 SPR-5973: UriUtils.parse returns UriComponents 2011-09-09 11:01:05 +00:00
Arjen Poutsma 65baafa032 SPR-5973: Made UriComponent enum inner type of UriComponents 2011-09-09 10:57:13 +00:00
Arjen Poutsma 6c58da0e55 SPR-5973: Added UriComponents type 2011-09-09 10:49:10 +00:00
Rossen Stoyanchev 56c8c69c4c SPR-8642 IMPROVE ERROR REPORTING WHEN RESOLVING MULTIPART REQUEST METHOD ARGUMENTS
Separate client from server errors as much as possible in this order:
- raise MultipartException when resolving a multipart arg and the 
  request is not a multipart request (400)
- raise IllegalArgumentException when the arg type is MultipartFile 
  but the request is not of type MultipartHttpServletRequest (500)
- raise MissingServletRequestPartException when a MultipartResolver
  is in use but the part is not found (400)
- detect presence of Servlet 3.0 before using standard multipart 
  parsing to find a request part or raise 
  IllegalArgumentException (500)

Unfortunately it is not always possible to separate client from 
server errors mainly because the Servlet 3.0 API does not 
distinguish between the case of 0 request parts vs multipart 
processing not being configured.
2011-09-09 09:09:10 +00:00
Arjen Poutsma b6c1e88e4a SPR-5973: Cleaning it up 2011-09-08 11:01:56 +00:00
Arjen Poutsma 5f208936ec Added parse methods 2011-09-07 13:58:51 +00:00
Arjen Poutsma 99f68d3620 SPR-5973: javadoc 2011-09-07 11:49:15 +00:00
Arjen Poutsma 420d11911b SPR-5973: Extract UriComponentTemplate out of UriTemplate 2011-09-07 11:26:22 +00:00
Arjen Poutsma 1d75e1b250 SPR-5973: Changed UriComponent from inner type to top-level enum 2011-09-07 10:40:40 +00:00
Arjen Poutsma f1c68f243e Changed ClientHttpRequestInterceptor array to List 2011-09-07 08:39:58 +00:00
Arjen Poutsma 9a25efbbda SPR-5973: UriBuilder 2011-09-06 15:42:33 +00:00
Rossen Stoyanchev 91251812b1 Polish @ExceptionHandler method resolution. Allow subclasses to plug in additional @ExceptionHandler methods. 2011-09-02 11:04:23 +00:00