Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use Accept */* header #2699

Closed
swoogles opened this issue Feb 23, 2024 · 4 comments
Closed

Cannot use Accept */* header #2699

swoogles opened this issue Feb 23, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@swoogles
Copy link
Contributor

swoogles commented Feb 23, 2024

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.

@swoogles swoogles added the bug Something isn't working label Feb 23, 2024
@brndt
Copy link

brndt commented Mar 11, 2024

I have the same ussue using Postman that adds this header by default.

@allaryin
Copy link

Curl adds this header by default as well.

@allaryin
Copy link

Setting my accept header forcibly to "application/json" does, in fact, make zio return correctly...

@swoogles
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants