on master help sign in
Using chunk size from lazy bytestrings
commitb3f1e24833bc6b1b7b732c7ff29f75bb43501158 authorMichael Snoyman <michael@snoyman.com> dateMon 1 Feb 2010, 14:38 (17 years ago) parent8d121cc
2 files changed+4−4
Network/Wai/Handler/CGI.hs+2−2 Network/Wai/Handler/SimpleServer.hs+2−2
Network/Wai/Handler/CGI.hs+2−2
@@ -12,6 +12,7 @@ import Control.Arrow ((***))
1212import Data.Char (toLower)
1313import qualified System.IO
1414import Control.Concurrent
15+import Data.ByteString.Lazy.Internal (defaultChunkSize)
1516
1617safeRead :: Read a => a -> String -> a
1718safeRead d s =
@@ -80,8 +81,7 @@ requestBodyHandle :: System.IO.Handle -> MVar Int -> Enumerator a
8081requestBodyHandle h mlen iter accum = modifyMVar mlen (helper accum) where
8182 helper a 0 = return (0, Right a)
8283 helper a len = do
83− let maxChunkSize = 1024
84− bs <- B.hGet h $ min len maxChunkSize
84+ bs <- B.hGet h $ min len defaultChunkSize
8585 let newLen = len - B.length bs
8686 ea' <- iter a bs
8787 case ea' of
Network/Wai/Handler/SimpleServer.hs+2−2
@@ -40,6 +40,7 @@ import qualified Web.Encodings.StringLike as SL
4040import qualified Safe
4141import Network.Socket.SendFile
4242import Control.Arrow (first)
43+import Data.ByteString.Lazy.Internal (defaultChunkSize)
4344
4445run :: Port -> Application -> IO ()
4546run port = withSocketsDo .
@@ -138,8 +139,7 @@ requestBodyHandle :: Handle -> MVar Int -> Enumerator a
138139requestBodyHandle h mlen iter accum = modifyMVar mlen (helper accum) where
139140 helper a 0 = return (0, Right a)
140141 helper a len = do
141− let maxChunkSize = 1024
142− bs <- BS.hGet h $ min len maxChunkSize
142+ bs <- BS.hGet h $ min len defaultChunkSize
143143 let newLen = len - BS.length bs
144144 ea' <- iter a bs
145145 case ea' of