haskell-servant / haskell-servant/servant
Empty reply when mimeRender fails
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
Consider the following custom content type combinator:
```haskell
import Data.Proxy
import Network.HTTP.Media ((//), (/:))
import qualified Network.Wai.Handler.Warp as Warp
import Servant
data Test
instance Accept Test where
contentType _ = "text" // "plain"
instance MimeRender Test a where
mimeRender _ _ = error "not implemented"
main :: IO()
main = Warp.run 8888 $ serve (Proxy @ (Get '[Test] Int)) (return 123)
```
When requesting this server you will get an empty reply:
```
$ curl localhost:8888
curl: (52) Empty reply from server
```
If your server is behind nginx you will likely get a standard 404 page from nginx because of that, for instance I get
```
HTTP/1.1 404 Not Found
Server: nginx/1.14.0
...
```
This is very confusing and I spent a few hours to locate this problem when working with a custom template combinators for servant (inspired by `servant-ede` and `servant-stache` which did not match my needs).
I suggest to fix this by issuing a 500 error instead, but I can't find the place where this has to be fixed right now. I will have a closer look at it later.
Contributor guide
Assessment
This issue has not been assessed yet.