Announcement Announcement Module
Collapse
No announcement yet.
How to deal with unfair HTTP Accept Headers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to deal with unfair HTTP Accept Headers

    I deployed my roo application in the cloud and run it successfully
    using FF and a recent version of IE.

    I asked a user to try the application. Bad idea.

    He uses an older version of IE (IE<=8 on xp) and in this case,
    the HTTP header Accept does not include "text/html".

    See related discussion at http://www.gethifi.com/blog/browser-...accept-headers

    There are 2 handler methods generated by ROO to choose from:

    Code:
        @RequestMapping(produces = "text/html")
        public String ProjectController.list(...
    and

    Code:
        @RequestMapping(headers = "Accept=application/json")
        @ResponseBody
        public ResponseEntity<String> ProjectController.listJson() {...

    The first method returns html and the second Json.

    When a request does not accept "text/html" as with IE8 on xp, an unexpected Json
    response is returned to the browser. I would have preferred a html response.

    As a quick workaround, I wrote a third handler to catch these incomplete requests:

    Code:
        @RequestMapping(headers = "Accept=application/x-ms-application")
        public String listUnfairBrowser(
             @RequestParam(value = "page", required = false) Integer page,
             @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
           return list(page,size,uiModel);
        }
    Note that "application/x-ms-application" is part of the IE request Accept header.

    Is it possible to assign a priority to one of the many handler methods ?
    Is there another way to support requests from older IE versions ? I fear most of
    my users will be using this platform

  • #2
    My problem was solved by writing a servlet filter which intercepts requests
    and adds the missing 'text/html'

    Comment


    • #3
      Originally posted by sergio de la luna View Post
      My problem was solved by writing a servlet filter which intercepts requests
      and adds the missing 'text/html'
      If true, this is a bug, can you create an issue in JIRA ?

      Comment

      Working...
      X