@@ -80,7 +80,7 @@ type TestHeaders = '[Header "X-Example1" Int, Header "X-Example2" String]
8080
8181type Api =
8282 "get" :> Get '[JSON] Person
83− :<|> "delete" :> Delete '[JSON] ()
83+ :<|> "deleteEmpty" :> Delete '[] ()
8484 :<|> "capture" :> Capture "name" String :> Get '[JSON,FormUrlEncoded] Person
8585 :<|> "body" :> ReqBody '[FormUrlEncoded,JSON] Person :> Post '[JSON] Person
8686 :<|> "param" :> QueryParam "name" String :> Get '[FormUrlEncoded,JSON] Person
@@ -98,6 +98,7 @@ type Api =
9898 ReqBody '[JSON] [(String, [Rational])] :>
9999 Get '[JSON] (String, Maybe Int, Bool, [(String, [Rational])])
100100 :<|> "headers" :> Get '[JSON] (Headers TestHeaders Bool)
101+ :<|> "deleteContentType" :> Delete '[JSON] ()
101102api :: Proxy Api
102103api = Proxy
103104
@@ -123,6 +124,7 @@ server = serve api (
123124 :<|> (\ _request respond -> respond $ responseLBS badRequest400 [] "rawFailure")
124125 :<|> (\ a b c d -> return (a, b, c, d))
125126 :<|> (return $ addHeader 1729 $ addHeader "eg2" True)
127+ :<|> return ()
126128 )
127129
128130withServer :: (BaseUrl -> IO a) -> IO a
@@ -148,7 +150,7 @@ withFailServer action = withWaiDaemon (return failServer) action
148150spec :: IO ()
149151spec = withServer $ \ baseUrl -> do
150152 let getGet :: EitherT ServantError IO Person
151− getDelete :: EitherT ServantError IO ()
153+ getDeleteEmpty :: EitherT ServantError IO ()
152154 getCapture :: String -> EitherT ServantError IO Person
153155 getBody :: Person -> EitherT ServantError IO Person
154156 getQueryParam :: Maybe String -> EitherT ServantError IO Person
@@ -161,8 +163,9 @@ spec = withServer $ \ baseUrl -> do
161163 getRawFailure :: Method -> EitherT ServantError IO (Int, ByteString, MediaType, [HTTP.Header], C.Response ByteString)
162164 getMultiple :: String -> Maybe Int -> Bool -> [(String, [Rational])] -> EitherT ServantError IO (String, Maybe Int, Bool, [(String, [Rational])])
163165 getRespHeaders :: EitherT ServantError IO (Headers TestHeaders Bool)
166+ getDeleteContentType :: EitherT ServantError IO ()
164167 ( getGet
165− :<|> getDelete
168+ :<|> getDeleteEmpty
166169 :<|> getCapture
167170 :<|> getBody
168171 :<|> getQueryParam
@@ -174,15 +177,20 @@ spec = withServer $ \ baseUrl -> do
174177 :<|> getRawSuccess
175178 :<|> getRawFailure
176179 :<|> getMultiple
177− :<|> getRespHeaders)
180+ :<|> getRespHeaders
181+ :<|> getDeleteContentType)
178182 = client api baseUrl
179183
180184 hspec $ do
181185 it "Servant.API.Get" $ do
182186 (Arrow.left show <$> runEitherT getGet) `shouldReturn` Right alice
183187
184− it "Servant.API.Delete" $ do
185− (Arrow.left show <$> runEitherT getDelete) `shouldReturn` Right ()
188+ describe "Servant.API.Delete" $ do
189+ it "allows empty content type" $ do
190+ (Arrow.left show <$> runEitherT getDeleteEmpty) `shouldReturn` Right ()
191+
192+ it "allows content type" $ do
193+ (Arrow.left show <$> runEitherT getDeleteContentType) `shouldReturn` Right ()
186194
187195 it "Servant.API.Capture" $ do
188196 (Arrow.left show <$> runEitherT (getCapture "Paula")) `shouldReturn` Right (Person "Paula" 0)
@@ -274,11 +282,11 @@ spec = withServer $ \ baseUrl -> do
274282failSpec :: IO ()
275283failSpec = withFailServer $ \ baseUrl -> do
276284 let getGet :: EitherT ServantError IO Person
277− getDelete :: EitherT ServantError IO ()
285+ getDeleteEmpty :: EitherT ServantError IO ()
278286 getCapture :: String -> EitherT ServantError IO Person
279287 getBody :: Person -> EitherT ServantError IO Person
280288 ( getGet
281− :<|> getDelete
289+ :<|> getDeleteEmpty
282290 :<|> getCapture
283291 :<|> getBody
284292 :<|> _ )
@@ -289,7 +297,7 @@ failSpec = withFailServer $ \ baseUrl -> do
289297 hspec $ do
290298 context "client returns errors appropriately" $ do
291299 it "reports FailureResponse" $ do
292− Left res <- runEitherT getDelete
300+ Left res <- runEitherT getDeleteEmpty
293301 case res of
294302 FailureResponse (Status 404 "Not Found") _ _ -> return ()
295303 _ -> fail $ "expected 404 response, but got " <> show res