@@ -16,6 +16,7 @@ import System.IO (hClose)
16import Network (connectTo, PortID (PortNumber))
16import Network (connectTo, PortID (PortNumber))
17import Network.Wai.Handler.Warp
17import Network.Wai.Handler.Warp
18import Data.Maybe (mapMaybe)
18import Data.Maybe (mapMaybe)
19+import Control.Concurrent (threadDelay)
20main :: IO ()
21main :: IO ()
21main = hspec spec
22main = hspec spec
@@ -30,6 +31,7 @@ testRange range out crange = it title $ withApp defaultSettings app $ \port -> d
30 S.hPutStr handle "Range: bytes="
31 S.hPutStr handle "Range: bytes="
31 S.hPutStr handle range
32 S.hPutStr handle range
32 S.hPutStr handle "\r\n\r\n"
33 S.hPutStr handle "\r\n\r\n"
33 bss <- fmap (lines . filter (/= '\r') . S8.unpack) $ S.hGetSome handle 1024
35 bss <- fmap (lines . filter (/= '\r') . S8.unpack) $ S.hGetSome handle 1024
34 hClose handle
36 hClose handle
35 out `shouldBe` last bss
37 out `shouldBe` last bss
@@ -51,6 +53,7 @@ testPartial :: Integer -- ^ offset
51testPartial offset count out = it title $ withApp defaultSettings app $ \port -> do
53testPartial offset count out = it title $ withApp defaultSettings app $ \port -> do
52 handle <- connectTo "127.0.0.1" $ PortNumber $ fromIntegral port
54 handle <- connectTo "127.0.0.1" $ PortNumber $ fromIntegral port
53 S.hPutStr handle "GET / HTTP/1.0\r\n\r\n"
55 S.hPutStr handle "GET / HTTP/1.0\r\n\r\n"
54 bss <- fmap (lines . filter (/= '\r') . S8.unpack) $ S.hGetSome handle 1024
57 bss <- fmap (lines . filter (/= '\r') . S8.unpack) $ S.hGetSome handle 1024
55 hClose handle
58 hClose handle
56 out `shouldBe` last bss
59 out `shouldBe` last bss