@@ -13,6 +13,7 @@ import qualified Data.ByteString.Lazy as L
1313import qualified Data.Text as TS
1414import qualified Data.Text.Encoding as TE
1515import Control.Monad.Trans.Resource (withInternalState, runResourceT)
16+import Network.HTTP2( HTTP2Error (..), ErrorCodeId (..) )
1617
1718import Network.Wai
1819import Network.Wai.Test
@@ -94,6 +95,9 @@ caseParseRequestBody = do
9495 let expectedfile3 = [("yaml", FileInfo "README" "application/octet-stream" "Photo blog using Hack.\n")]
9596 let expected3 = (expectedsmap3, expectedfile3)
9697
98+ let unknownErrorException c (ConnectionError (UnknownErrorCode code) _) = c == code
99+ unknownErrorException _ _ = False
100+
97101
98102 let def = defaultParseRequestBodyOptions
99103 it "parsing actual post multipart/form-data" $ do
@@ -119,17 +123,21 @@ caseParseRequestBody = do
119123
120124 it "exceeding file size" $ do
121125 SRequest req4 _bod4 <- toRequest'' ctype3 content3
122− (parseRequestBodyEx ( setMaxRequestFileSize 2 def ) lbsBackEnd req4) `shouldThrow` anyErrorCall
126+ (parseRequestBodyEx ( setMaxRequestFileSize 2 def ) lbsBackEnd req4)
127+ `shouldThrow` unknownErrorException 413
123128
124129 it "exceeding total file size" $ do
125130 SRequest req4 _bod4 <- toRequest'' ctype3 content3
126− (parseRequestBodyEx ( setMaxRequestFilesSize 20 def ) lbsBackEnd req4) `shouldThrow` anyErrorCall
131+ (parseRequestBodyEx ( setMaxRequestFilesSize 20 def ) lbsBackEnd req4)
132+ `shouldThrow` unknownErrorException 413
127133 SRequest req5 _bod5 <- toRequest'' ctype3 content5
128− (parseRequestBodyEx ( setMaxRequestFilesSize 20 def ) lbsBackEnd req5) `shouldThrow` anyErrorCall
134+ (parseRequestBodyEx ( setMaxRequestFilesSize 20 def ) lbsBackEnd req5)
135+ `shouldThrow` unknownErrorException 413
129136
130137 it "exceeding max parm value size" $ do
131138 SRequest req4 _bod4 <- toRequest'' ctype2 content2
132− (parseRequestBodyEx ( setMaxRequestParmsSize 10 def ) lbsBackEnd req4) `shouldThrow` anyErrorCall
139+ (parseRequestBodyEx ( setMaxRequestParmsSize 10 def ) lbsBackEnd req4)
140+ `shouldThrow` unknownErrorException 413
133141
134142 it "exceeding max header lines" $ do
135143 SRequest req4 _bod4 <- toRequest'' ctype2 content2
@@ -137,7 +145,8 @@ caseParseRequestBody = do
137145
138146 it "exceeding header line size" $ do
139147 SRequest req4 _bod4 <- toRequest'' ctype3 content4
140− (parseRequestBodyEx ( setMaxHeaderLineLength 8190 def ) lbsBackEnd req4) `shouldThrow` anyErrorCall
148+ (parseRequestBodyEx ( setMaxHeaderLineLength 8190 def ) lbsBackEnd req4)
149+ `shouldThrow` unknownErrorException 431
141150
142151 it "Testing parseRequestBodyEx with application/x-www-form-urlencoded" $ do
143152 let content = "thisisalongparameterkey=andthisbeanevenlongerparametervaluehelloworldhowareyou"