@@ -13,6 +13,7 @@ import qualified Data.ByteString.Lazy as L
13import qualified Data.Text as TS
13import qualified Data.Text as TS
14import qualified Data.Text.Encoding as TE
14import qualified Data.Text.Encoding as TE
15import Control.Monad.Trans.Resource (withInternalState, runResourceT)
15import Control.Monad.Trans.Resource (withInternalState, runResourceT)
16+import Network.HTTP2( HTTP2Error (..), ErrorCodeId (..) )
17import Network.Wai
18import Network.Wai
18import Network.Wai.Test
19import Network.Wai.Test
@@ -94,6 +95,9 @@ caseParseRequestBody = do
94 let expectedfile3 = [("yaml", FileInfo "README" "application/octet-stream" "Photo blog using Hack.\n")]
95 let expectedfile3 = [("yaml", FileInfo "README" "application/octet-stream" "Photo blog using Hack.\n")]
95 let expected3 = (expectedsmap3, expectedfile3)
96 let expected3 = (expectedsmap3, expectedfile3)
98+ let unknownErrorException c (ConnectionError (UnknownErrorCode code) _) = c == code
99+ unknownErrorException _ _ = False
98 let def = defaultParseRequestBodyOptions
102 let def = defaultParseRequestBodyOptions
99 it "parsing actual post multipart/form-data" $ do
103 it "parsing actual post multipart/form-data" $ do
@@ -119,17 +123,21 @@ caseParseRequestBody = do
120 it "exceeding file size" $ do
124 it "exceeding file size" $ do
121 SRequest req4 _bod4 <- toRequest'' ctype3 content3
125 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
124 it "exceeding total file size" $ do
129 it "exceeding total file size" $ do
125 SRequest req4 _bod4 <- toRequest'' ctype3 content3
130 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
127 SRequest req5 _bod5 <- toRequest'' ctype3 content5
133 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
130 it "exceeding max parm value size" $ do
137 it "exceeding max parm value size" $ do
131 SRequest req4 _bod4 <- toRequest'' ctype2 content2
138 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
134 it "exceeding max header lines" $ do
142 it "exceeding max header lines" $ do
135 SRequest req4 _bod4 <- toRequest'' ctype2 content2
143 SRequest req4 _bod4 <- toRequest'' ctype2 content2
@@ -137,7 +145,8 @@ caseParseRequestBody = do
138 it "exceeding header line size" $ do
146 it "exceeding header line size" $ do
139 SRequest req4 _bod4 <- toRequest'' ctype3 content4
147 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
142 it "Testing parseRequestBodyEx with application/x-www-form-urlencoded" $ do
151 it "Testing parseRequestBodyEx with application/x-www-form-urlencoded" $ do
143 let content = "thisisalongparameterkey=andthisbeanevenlongerparametervaluehelloworldhowareyou"
152 let content = "thisisalongparameterkey=andthisbeanevenlongerparametervaluehelloworldhowareyou"