Skip to content

HttpClient doesn't handle Content-Type charset values with quotation marks. #12247

@valtercorreia

Description

@valtercorreia

Expected Behavior

As per HTTP Semantics, text/html; charset="utf-8" is a valid specification of the charset value and the Micronaut HttpClient should be able to decode a response with such a body.

Actual Behaviour

The HttpClient fails to decode a response with a Content-Type header where the charset is specified in quotation marks. For example, content-type: text/html; charset="utf-8".

Steps To Reproduce

Something like:

@MicronautTest
public class Test {

    @Inject
    @Client("/")
    HttpClient httpClient;

    @Test
    void testHelloWorldEndpoint() {
        String response = httpClient.toBlocking().retrieve("/hello");
    }

    @Controller("/")
    static class HelloWorldController {

        @Get("/hello")
        @Produces("text/plain; charset=\"utf-8\"")
        public String hello() {
            return "Hello, World!";
        }
    }

}

Environment Information

  • Operating System: Linux
  • JDK Version: OpenJDK-21

Example Application

No response

Version

4.10.3

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