Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-14506

HeaderContentNegotiationStrategy does not support multiple Accept headers

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 4.3.1
    • Fix Version/s: 4.3.2, 5.0 M1
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      There are two ways to provide multiple values for a given HTTP header.

      Accept: text/plain, application/json

      and

      Accept: text/plain
      Accept: application/json

      The default strategy for parsing the Accept header exists in org.springframework.web.accept.HeaderContentNegotiationStrategy.

      This code currently uses request.getHeader("Accept"), which only returns the 'first' Accept header if there are multiple headers (ie. the second case).

      This means that ONLY the first way works. The second way does not work (it simply returns the result of the first header instead of the complete set).

      The code should be using request.getHeaders("Accept") and looping through each. NOTE: The code still needs to parse out the comma separated list, since it is possible to have both at the same time.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              diamondq Michael Mansell
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 45 weeks, 4 days ago