warp 3.0.0.6 → 3.0.0.7
raw patch · 5 files changed
+53/−3 lines, 5 files
Files
- Network/Wai/Handler/Warp/IORef.hs +4/−0
- Network/Wai/Handler/Warp/Request.hs +2/−2
- Network/Wai/Handler/Warp/Timeout.hs +4/−0
- test/RequestSpec.hs +42/−0
- warp.cabal +1/−1
Network/Wai/Handler/Warp/IORef.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE CPP #-} +#ifndef MIN_VERSION_base+#define MIN_VERSION_base(x,y,z) 1+#endif+ module Network.Wai.Handler.Warp.IORef ( module Data.IORef #if !MIN_VERSION_base(4,6,0)
Network/Wai/Handler/Warp/Request.hs view
@@ -203,7 +203,7 @@ -- update the length, and continue processing. push' Nothing = do bst <- readSource' src- when (S.null bs) $ throwIO IncompleteHeaders+ when (S.null bst) $ throwIO IncompleteHeaders push src status bst where len' = len + bsLen@@ -241,6 +241,6 @@ {-# INLINE checkCR #-} checkCR :: ByteString -> Int -> Int-checkCR bs pos = if 13 == S.index bs p then p else pos -- 13 is CR+checkCR bs pos = if pos > 0 && 13 == S.index bs p then p else pos -- 13 is CR where !p = pos - 1
Network/Wai/Handler/Warp/Timeout.hs view
@@ -42,6 +42,10 @@ , TimeoutThread (..) ) where +#ifndef MIN_VERSION_base+#define MIN_VERSION_base(x,y,z) 1+#endif+ #if MIN_VERSION_base(4,6,0) import Control.Concurrent (mkWeakThreadId, ThreadId) #else
test/RequestSpec.hs view
@@ -59,6 +59,35 @@ test "bytes=9500-" $ Just [HH.ByteRangeFrom 9500] test "foobytes=9500-" Nothing test "bytes=0-0,-1" $ Just [HH.ByteRangeFromTo 0 0, HH.ByteRangeSuffix 1]++ describe "headerLines" $ do+ it "can handle a nomarl case" $ do+ src <- mkSourceFunc ["Status: 200\r\nContent-Type: text/plain\r\n\r\n"] >>= mkSource+ x <- headerLines src+ x `shouldBe` ["Status: 200", "Content-Type: text/plain"]++ it "can handle a nasty case (1)" $ do+ src <- mkSourceFunc ["Status: 200", "\r\nContent-Type: text/plain", "\r\n\r\n"] >>= mkSource+ x <- headerLines src+ x `shouldBe` ["Status: 200", "Content-Type: text/plain"]++ it "can handle a nasty case (1)" $ do+ src <- mkSourceFunc ["Status: 200", "\r", "\nContent-Type: text/plain", "\r", "\n\r\n"] >>= mkSource+ x <- headerLines src+ x `shouldBe` ["Status: 200", "Content-Type: text/plain"]++ it "can handle a nasty case (1)" $ do+ src <- mkSourceFunc ["Status: 200", "\r", "\n", "Content-Type: text/plain", "\r", "\n", "\r", "\n"] >>= mkSource+ x <- headerLines src+ x `shouldBe` ["Status: 200", "Content-Type: text/plain"]++ it "can handle an illegal case (1)" $ do+ src <- mkSourceFunc ["\nStatus:", "\n 200", "\nContent-Type: text/plain", "\r\n\r\n"] >>= mkSource+ x <- headerLines src+ x `shouldBe` []+ y <- headerLines src+ y `shouldBe` ["Status: 200", "Content-Type: text/plain"]+ where blankSafe = headerLinesList ["f", "oo\n", "bar\nbaz\n\r\n"] whiteSafe = headerLinesList ["foo\r\nbar\r\nbaz\r\n\r\n hi there"]@@ -101,3 +130,16 @@ overLargeHeader :: Selector InvalidRequest overLargeHeader e = e == OverLargeHeader++mkSourceFunc :: [S8.ByteString] -> IO (IO S8.ByteString)+mkSourceFunc bss = do+ ref <- newIORef bss+ return $ reader ref+ where+ reader ref = do+ xss <- readIORef ref+ case xss of+ [] -> return S.empty+ (x:xs) -> do+ writeIORef ref xs+ return x
warp.cabal view
@@ -1,5 +1,5 @@ Name: warp-Version: 3.0.0.6+Version: 3.0.0.7 Synopsis: A fast, light-weight web server for WAI applications. License: MIT License-file: LICENSE