-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
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