zio-http
zio-http copied to clipboard
Cannot use `Accept */*` header
Describe the bug
K8s liveliness/readiness probes attach this header by default - Accept */*
Using the latest snapshot - 3.0.0-RC4+77-66867e7f-SNAPSHOT
gives this error:
199 ZIO HTTP "... java.lang.IllegalArgumentException: None of the media types Chunk"
To Reproduce
object FailsOnAcceptWildcard extends ZIOAppDefault {
val healthRoute =
Endpoint(Method.GET / "health" / "api")
.out[String]
.implement {
Handler.fromZIO(
ZIO.succeed("API is healthy!")
)
}
def run =
Server
.serve(healthRoute.toHttpApp)
.provide(Server.default)
.exitCode
}
Then execute:
curl -I -X 'GET' 'localhost:9007/health/api' -H 'accept: */*'
Expected behaviour Should return a 200. Users shouldn't need to change the default K8s probe behavior.
I have the same ussue using Postman that adds this header by default.
Curl adds this header by default as well.
Setting my accept header forcibly to "application/json" does, in fact, make zio return correctly...
Setting my accept header forcibly to "application/json" does, in fact, make zio return correctly...
Yep, you can work around it by providing different headers in whatever client you're using.
But 3 major tools:
- Kubernetes
- Postman
- Curl (And I'm sure there are others)
All send a default header value that breaks zio-http. A web server can't realistically demand that all of these tools change their behavior in order to work together.