Separate request content-type from the response content-type handling
---------------------------------------------------------------------
Key: WW-2641
URL: https://issues.apache.org/struts/browse/WW-2641
Project: Struts 2
Issue Type: Improvement
Components: Plugin - REST
Affects Versions: 2.1.2
Reporter: Jeromy Evans
Assignee: Jeromy Evans
The REST plugin's ContentTypeHandlerManager assumes the content-type of the
request and content-type of the response are both determined by the request
extension (eg. .json, .xml).
However, a common use-case for browser user-agents is that the request content
type will be "application/x-www-form-urlencoded" or
"application/form-multipart" with a JSON, XML or HTML response content type.
Proposal: split the ContentTypeHandlerManager to implement
getHandlerForRequest() and getHandlerForResponse() methods. The request handler
should inspect the request content type and give precedence to the handler for
the content type first, falling-back to the handler for the extension if not
found/not specified. The Response handler will continue to use the extension
(later it should use the accepts request header).
Registration of ContentTypeHandlers will place the handler in the appropriate
request/response handlers map depending on the extension (if present) and
content type (if present). Overrides will still only apply to the extension at
this time.
This change will also add a new default ContentTypeHandler for
"application/x-www-form-urlencoded" requests.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.