Skip to content

Content Negotiation with media type parameters: Method producing exact match of Accept content type is not called. #27999

Closed
@thake

Description

@thake

I'm working on an API that produces application/hal+json documents that use the media type profile parameter to support versioning.
The structure of the controller looks like this:

@RestController
@RequestMapping("/hal-documents")
class MyController {
    @GetMapping(produces = ["application/hal+json;charset=UTF-8"])
    fun getWithoutProfile() : ResponseEntity<MyResource> {...}

    @GetMapping(produces = ["""application/hal+json;profile="my-resource-v1""""])
    fun getV1() : ResponseEntity<MyResource> {...}

    @GetMapping(produces = ["""application/hal+json;profile="my-resource-v2""""])
    fun getV2() : ResponseEntity<MyResource> {...}
}

If I execute a request, which Accept-Header exactly matches the media type produced by getV1, the method is not being called. Instead, the request is being routed to getWithoutProfile.

This seems to be wrong. I would expect that the best matching method is being called. Routing works correctly if the charset parameter is removed from the getWithoutProfile method.

Affects: 5.3.15

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions