mtrudel / bandit

Bandit is a pure Elixir HTTP server for Plug & WebSock applications
MIT License
1.67k stars 80 forks source link

Expose body read timeouts as 408 Request Timeout errors #385

Closed mtrudel closed 2 months ago

mtrudel commented 2 months ago

Fixes #384

mtrudel commented 2 months ago

This solution explicitly raises an HTTPError because returning an error tuple from Plug.Conn.Adapter.read_req_body/2 doesn't provide us with a way to track the failed read on the connection, so there's no way to meaningfully manage the connection once this happens. This puts a lot of onus on the user to properly ensure that nothing further gets done on the connection,

It also makes it really tricky to send a useful error to the client, and also to ensure that the connection is closed afterwards.

Moreover, it keeps the flow for this case the same as it is for all other HTTP error cases; the proper client signalling here just falls out of Bandit's design.