Is Micronaut mishandling the request content-type header?

Viewed 504

Given this simple controller, it appears Micronaut is rejecting requests with a "415 Unsupported Media Type" based on the request's content type header on a GET request.

@Controller
class BadController() {

    @Get("/blah")
    @Produces("image/svg+xml")
    fun getBlah(): HttpResponse<*> {
        return HttpResponse.ok("</some-svg>")
    }
}

For example:

curl -v http://localhost:8080/blah -H "Content-Type: text/plain" 
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /blah HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: text/plain
> 
< HTTP/1.1 415 Unsupported Media Type
< Date: Mon, 7 Jan 2019 16:31:48 GMT
< transfer-encoding: chunked
< connection: close
< 
* Closing connection 0

MDN's content-type header doco makes it sound like the header wouldn't even be used by the server for GET's because the client isn't sending content:

In requests, (such as POST or PUT), the client tells the server what type of data is actually sent.

https://web.archive.org/web/20210816145541/https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type

0 Answers
Related