[ https://issues.apache.org/jira/browse/SLING-1974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12992989#comment-12992989 ]
Felix Meschberger commented on SLING-1974: ------------------------------------------ > Are extensions supported? Not at the moment. > SlingHttpServletRequest.getResponseContentType() We implement that method by looking at the request extension (getResponseContentTypes() returns an Enumeration just containing getResponseContentType()). I think this is a good approach: - getResponseContentType() returns a primary requested type by the client: 1. derived from the request extension (if any) 2. derived from Accept header (as per today's MediaRangeList) - getResponseContentTypes() returns an enumeration containing 1. type derived from the request extension (if any) 2. types derived from Accept header (in q and declaration order) - getResponseContentType(String.. supported) returns the response content type amongst the supported types being returned first by the getResponseContentTypes() enumeration Finally the Sling POST Servlet might use the SlingHttpServletResponse.getResponseContentType("text/html", "text/json") call to get the desired type Alternatively: - keep the SlingHttpServletResponseImpl implementation as it is (and no API extension) - create a request filter overwriting the getResponseContentType and getResponseContentTypes() methods along the lines defined above - have the Sling POST Servlet check the getResponseContentTypes() enumeration and selecting the first supported content type from the enumeration Actually, I would prefer the filter solution because it does not require changes to the API or the engine bundle and is ultimatively flexible. In fact this is a similar solution as we chose for I18N support and the getLocale methods. WDYT ? > Accept header issues in the Sling POST Servlet > ---------------------------------------------- > > Key: SLING-1974 > URL: https://issues.apache.org/jira/browse/SLING-1974 > Project: Sling > Issue Type: Bug > Components: Servlets > Affects Versions: Servlets Post 2.1.0 > Reporter: Felix Meschberger > Fix For: Servlets Post 2.1.2 > > Attachments: SLING-1974.patch > > > As of SLING-1336 the Sling POST Servlet can interpret the Accept request > header to select what response content type to render. > Unfortunately that handling seems broken as for an Accept header like (as > generated by FireFox with the JSONovich plugin installed) : > Accept: > text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,application/json > the JSON response might be selected but sometimes also text/html (we can > observe both behaviours for different server platforms with our application). > The Accept header should probably consider equivalent q values (as for > text/html and application/json in the example) to solve the tie by selecting > the first type list; thus text/html in this example. -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira