Results 1 to 3 of 3

Thread: How to deal with unfair HTTP Accept Headers

  1. #1

    Default 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. #2

    Default

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

  3. #3
    Join Date
    Jan 2010
    Location
    Mislata - Valencia - Spain
    Posts
    162

    Default

    Quote 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 ?
    Mario Martínez Sánchez
    Project Manager & Software Architect
    --------------------------
    Disid Technologies S.L.
    http://www.disid.com
    --------------------------
    gvNIX
    http://gvnix.googlecode.com
    http://www.gvnix.org

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •