Skip to content

Unable to set "Content-Type" header by @RequestHeader annotation #363

Description

@PhillipMek

Spring Boot 2.3.1
Spring Cloud OpenFeign 2.2.3
Java 11

Hi!
It looks like there is an issue introduced by change #314.

I have following method in my Feign client:

@PostMapping("/api/v2/topics/{topicName}")
Response sendMessage(
            @PathVariable("topicName") String topicName,
            @RequestBody Message message,
            @RequestHeader(value = HttpHeaders.CONTENT_TYPE) String contentHeader);

So, here I'm able to set "Content-Type" header dynamically by passing contentHeader param and this works until Spring Cloud Hoxton.SR5. When I set "spring-cloud-dependencies" version to "Hoxton.SR5" my app start failed with exception:
org.springframework.util.InvalidMimeTypeException: Invalid mime type "{Content-Type}": does not contain '/'

Exception thrown from method org.springframework.cloud.openfeign.support.SpringMvcContract#isMultipartFormData because in the given example of Feign method we have placeholder instead of particular header value and code

MediaType.valueOf(type); // here type = "{Content-Type}"

failed with InvalidMimeTypeException.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions