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

Media type fails to match types with multiple '+' characters

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 5.0 RC4
    • Component/s: Core

      Description

      The logic in MimeType.includes and MimeType.isCompatibleWith appears to have a bug, in that they assume there will only be one + character in the media type string.

      For example, application/*+json does not include a media type of the form application/x.y+z+json.

      My understanding from the RFC is that multiple + characters are allowed, and everything following the last + defines the syntax suffix.

      The code in MimeType is using

      indexOf('+')

      to locate the syntax suffix. My belief is that it should be using

      lastIndexOf('+')

      instead.

      Steps to reproduce:

      Use RestTemplate to make an HTTP request with a custom Content-Type header of application/x.y+z+json. An error is thrown:

      org.springframework.web.client.RestClientException: Could not write request: no suitable HttpMessageConverter found for request type...
      

      Proposed change: https://github.com/spring-projects/spring-framework/pull/1481

        Attachments

          Activity

            People

            • Assignee:
              rstoya05-aop Rossen Stoyanchev
              Reporter:
              drautb Ben Draut
              Last updater:
              St├ęphane Nicoll
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                47 weeks, 5 days ago