Micronaut是否对请求内容类型标头进行了错误处理?

时间:2019-01-07 22:43:08

标签: micronaut

考虑到这个简单的控制器,看来Micronaut正在根据GET请求中请求的内容类型标头拒绝“ 415不支持的媒体类型”的请求。

@Controller
class BadController() {

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

例如:

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的内容类型标头doco听起来好像该标头甚至都不会被服务器用于GET,因为客户端没有发送内容:

  

在请求(例如POST或PUT)中,客户端告诉服务器什么   实际发送的数据类型。

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

0 个答案:

没有答案
相关问题