@@ -53,6 +53,23 @@ errorOrderApi = Proxy
5353errorOrderServer :: Server ErrorOrderApi
5454errorOrderServer = \_ _ _ -> throwE err402
5555
56+-- On error priorities:
57+--
58+-- We originally had
59+--
60+-- 404, 405, 401, 415, 400, 406, 402
61+--
62+-- but we changed this to
63+--
64+-- 404, 405, 401, 406, 415, 400, 402
65+--
66+-- for servant-0.7.
67+--
68+-- This change is due to the body check being irreversible (to support
69+-- streaming). Any check done after the body check has to be made fatal,
70+-- breaking modularity. We've therefore moved the accept check before
71+-- the body check, to allow it being recoverable and modular, and this
72+-- goes along with promoting the error priority of 406.
5673errorOrderSpec :: Spec
5774errorOrderSpec =
5875 describe "HTTP error order" $
@@ -86,18 +103,18 @@ errorOrderSpec =
86103 request goodMethod goodUrl [badAuth, badContentType, badAccept] badBody
87104 `shouldRespondWith` 401
88105
89− it "has 415 as its fourth highest priority error" $ do
106+ it "has 406 as its fourth highest priority error" $ do
90107 request goodMethod goodUrl [goodAuth, badContentType, badAccept] badBody
108+ `shouldRespondWith` 406
109+
110+ it "has 415 as its fifth highest priority error" $ do
111+ request goodMethod goodUrl [goodAuth, badContentType, goodAccept] badBody
91112 `shouldRespondWith` 415
92113
93− it "has 400 as its fifth highest priority error" $ do
94− request goodMethod goodUrl [goodAuth, goodContentType, badAccept] badBody
114+ it "has 400 as its sixth highest priority error" $ do
115+ request goodMethod goodUrl [goodAuth, goodContentType, goodAccept] badBody
95116 `shouldRespondWith` 400
96117
97− it "has 406 as its sixth highest priority error" $ do
98− request goodMethod goodUrl [goodAuth, goodContentType, badAccept] goodBody
99− `shouldRespondWith` 406
100−
101118 it "has handler-level errors as last priority" $ do
102119 request goodMethod goodUrl [goodAuth, goodContentType, goodAccept] goodBody
103120 `shouldRespondWith` 402