@@ -53,6 +53,23 @@ errorOrderApi = Proxy
53errorOrderServer :: Server ErrorOrderApi
53errorOrderServer :: Server ErrorOrderApi
54errorOrderServer = \_ _ _ -> throwE err402
54errorOrderServer = \_ _ _ -> throwE err402
56+-- On error priorities:
60+-- 404, 405, 401, 415, 400, 406, 402
62+-- but we changed this to
64+-- 404, 405, 401, 406, 415, 400, 402
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.
56errorOrderSpec :: Spec
73errorOrderSpec :: Spec
57errorOrderSpec =
74errorOrderSpec =
58 describe "HTTP error order" $
75 describe "HTTP error order" $
@@ -86,18 +103,18 @@ errorOrderSpec =
86 request goodMethod goodUrl [badAuth, badContentType, badAccept] badBody
103 request goodMethod goodUrl [badAuth, badContentType, badAccept] badBody
87 `shouldRespondWith` 401
104 `shouldRespondWith` 401
89− it "has 415 as its fourth highest priority error" $ do
106+ it "has 406 as its fourth highest priority error" $ do
90 request goodMethod goodUrl [goodAuth, badContentType, badAccept] badBody
107 request goodMethod goodUrl [goodAuth, badContentType, badAccept] badBody
108+ `shouldRespondWith` 406
110+ it "has 415 as its fifth highest priority error" $ do
111+ request goodMethod goodUrl [goodAuth, badContentType, goodAccept] badBody
91 `shouldRespondWith` 415
112 `shouldRespondWith` 415
93− it "has 400 as its fifth highest priority error" $ do
114+ it "has 400 as its sixth highest priority error" $ do
94− request goodMethod goodUrl [goodAuth, goodContentType, badAccept] badBody
115+ request goodMethod goodUrl [goodAuth, goodContentType, goodAccept] badBody
95 `shouldRespondWith` 400
116 `shouldRespondWith` 400
97− it "has 406 as its sixth highest priority error" $ do
98− request goodMethod goodUrl [goodAuth, goodContentType, badAccept] goodBody
99− `shouldRespondWith` 406
101 it "has handler-level errors as last priority" $ do
118 it "has handler-level errors as last priority" $ do
102 request goodMethod goodUrl [goodAuth, goodContentType, goodAccept] goodBody
119 request goodMethod goodUrl [goodAuth, goodContentType, goodAccept] goodBody
103 `shouldRespondWith` 402
120 `shouldRespondWith` 402