Don't override status code on empty body.
This commit is contained in:
parent
190c75a364
commit
c6071bfb02
2 changed files with 5 additions and 6 deletions
|
@ -139,7 +139,6 @@ processMethodRouter :: Maybe (BL.ByteString, BL.ByteString) -> Status -> Method
|
||||||
-> Request -> RouteResult Response
|
-> Request -> RouteResult Response
|
||||||
processMethodRouter handleA status method headers request = case handleA of
|
processMethodRouter handleA status method headers request = case handleA of
|
||||||
Nothing -> FailFatal err406 -- this should not happen (checked before), so we make it fatal if it does
|
Nothing -> FailFatal err406 -- this should not happen (checked before), so we make it fatal if it does
|
||||||
Just (_, "") -> Route $ responseLBS status204 (fromMaybe [] headers) ""
|
|
||||||
Just (contentT, body) -> Route $ responseLBS status hdrs bdy
|
Just (contentT, body) -> Route $ responseLBS status hdrs bdy
|
||||||
where
|
where
|
||||||
bdy = if allowedMethodHead method request then "" else body
|
bdy = if allowedMethodHead method request then "" else body
|
||||||
|
|
|
@ -157,7 +157,7 @@ getSpec = do
|
||||||
post "/empty" "" `shouldRespondWith` 405
|
post "/empty" "" `shouldRespondWith` 405
|
||||||
|
|
||||||
it "returns headers" $ do
|
it "returns headers" $ do
|
||||||
get "/emptyWithHeaders" `shouldRespondWith` 204 { matchHeaders = [ "H" <:> "5" ] }
|
get "/emptyWithHeaders" `shouldRespondWith` 200 { matchHeaders = [ "H" <:> "5" ] }
|
||||||
|
|
||||||
it "returns 406 if the Accept header is not supported" $ do
|
it "returns 406 if the Accept header is not supported" $ do
|
||||||
Test.Hspec.Wai.request methodGet "" [(hAccept, "crazy/mime")] ""
|
Test.Hspec.Wai.request methodGet "" [(hAccept, "crazy/mime")] ""
|
||||||
|
@ -410,13 +410,13 @@ headerSpec = describe "Servant.API.Header" $ do
|
||||||
let delete' x = Test.Hspec.Wai.request methodDelete x [("MyHeader", "5")]
|
let delete' x = Test.Hspec.Wai.request methodDelete x [("MyHeader", "5")]
|
||||||
|
|
||||||
it "passes the header to the handler (Int)" $
|
it "passes the header to the handler (Int)" $
|
||||||
delete' "/" "" `shouldRespondWith` 204
|
delete' "/" "" `shouldRespondWith` 200
|
||||||
|
|
||||||
with (return (serve headerApi expectsString)) $ do
|
with (return (serve headerApi expectsString)) $ do
|
||||||
let delete' x = Test.Hspec.Wai.request methodDelete x [("MyHeader", "more from you")]
|
let delete' x = Test.Hspec.Wai.request methodDelete x [("MyHeader", "more from you")]
|
||||||
|
|
||||||
it "passes the header to the handler (String)" $
|
it "passes the header to the handler (String)" $
|
||||||
delete' "/" "" `shouldRespondWith` 204
|
delete' "/" "" `shouldRespondWith` 200
|
||||||
|
|
||||||
|
|
||||||
type RawApi = "foo" :> Raw
|
type RawApi = "foo" :> Raw
|
||||||
|
|
Loading…
Reference in a new issue