Skip to content

Accept Header Only Includes First Content Type When Multiple Types Are Specified in produces #3084

@AdrianLagartera

Description

@AdrianLagartera

Description

When using OpenFeign with a request mapping that specifies multiple content types in the produces attribute, the Accept header doesn't include all content types

Current Behavior

The generated request only sets the Accept header to application/jose, ignoring the second content type application/json.
Expected Accept Header: application/jose, application/json
Actual Accept Header: application/jose
Configuration
Feign Client Interface:

@FeignClient(name = "example-client", url = "${example.url}")
public interface ExampleClient {
    
    @RequestMapping(
        method = RequestMethod.POST,
        path = "/api/endpoint",
        produces = {"application/jose", "application/json"},
        consumes = {"application/json"}
    )
    ResponseEntity<String> exampleMethod(@PathVariable id, @RequestHeader(value = specific-encryption-header, required = false) String specificEncryption, @RequestBody(required = false) String request);
}

Expected Behavior

When multiple media types are specified in the produces attribute, the Accept header should include all of them, comma-separated, as per HTTP specification (RFC 7231). This allows the server to choose the most appropriate content type from the available options.
Actual Behavior
Only the first media type (application/jose) is included in the Accept header. The second media type (application/json) is ignored.

Steps to Reproduce

Create a Feign client with a method annotated with @RequestMapping
Set the produces attribute to multiple content types: produces = {"application/jose", "application/json"}
Execute the request, and return an application/json

Environment

Spring Cloud Openfeign Core: 4.2.2
Spring Boot Version: 3.4.10
Java Version: 21
OS: MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions