Skip to content

Spring Web @RequestHeader(Map<String,String>) throws RuntimeException #14051

Open

Description

Describe the bug
I'm trying to access all request headers using Spring @RequestHeader in the same way that @Context HttpHeaders headers would provide access to all request headers.

When starting the application with mvn quarkus:dev, I get the following exception

Caused by: java.lang.RuntimeException: RESTEASY003875: Unable to find a constructor that takes a String param or a
valueOf() or fromString() method for javax.ws.rs.HeaderParam("headers") on public java.lang.String
org.acme.SpringGreetingController.hello(java.util.Map) for basetype: java.util.Map

Expected behavior
A populated Map with HTTP headers, preferably a MultiValuedMap.

Actual behavior
Above exception.

To Reproduce

See reproducer. Note, I'd like to use the Spring MultiValueMap, although the reproducer uses a Map.
The reproducer is literally a project generated from code.quarkus.io with the Spring Web extension, with the hello() method updated as follows;

    public String hello(@RequestHeader MultiValueMap<String, String> headers) {
        headers.forEach((key, value) -> {
            System.out.println(key + "->" + value);
        })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

area/springIssues relating to the Spring integrationkind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions