on master help sign in
removing warnings.
commit60e9955f048cc83671407d9abdcceab8b9e164c6 authorKazu Yamamoto <kazu@iij.ad.jp> dateMon 23 Jun 2014, 13:57 (12 years ago) parentfcc2f4b
8 files changed+13−19
warp/Network/Wai/Handler/Warp.hs−1 warp/Network/Wai/Handler/Warp/Conduit.hs−2 warp/Network/Wai/Handler/Warp/Request.hs+4−5 warp/Network/Wai/Handler/Warp/RequestHeader.hs−1 warp/Network/Wai/Handler/Warp/Response.hs+1−1 warp/Network/Wai/Handler/Warp/Settings.hs−1 warp/test/ExceptionSpec.hs+4−6 warp/test/RequestSpec.hs+4−2
warp/Network/Wai/Handler/Warp.hs−1
@@ -97,7 +97,6 @@ import Network.Wai.Handler.Warp.Types
9797import Control.Exception (SomeException)
9898import Network.Wai (Request, Response)
9999import Network.Socket (SockAddr)
100−import Data.ByteString (ByteString)
101100import Data.Streaming.Network (HostPreference)
102101
103102-- | Port to listen on. Default value: 3000
warp/Network/Wai/Handler/Warp/Conduit.hs−2
@@ -1,12 +1,10 @@
11module Network.Wai.Handler.Warp.Conduit where
22
3−import Control.Applicative
43import Control.Exception
54import Control.Monad (when, unless)
65import Data.ByteString (ByteString)
76import Data.ByteString.Lazy.Char8 (pack)
87import qualified Data.ByteString as S
9−import qualified Data.ByteString.Char8 as S8
108import qualified Data.ByteString.Lazy as L
119import qualified Data.IORef as I
1210import Data.Word (Word, Word8)
warp/Network/Wai/Handler/Warp/Request.hs+4−5
@@ -8,7 +8,6 @@ module Network.Wai.Handler.Warp.Request (
88 , headerLines
99 ) where
1010
11−import Control.Applicative
1211import qualified Control.Concurrent as Conc (yield)
1312import Control.Exception (throwIO)
1413import Data.Array ((!))
@@ -203,9 +202,9 @@ push src (THStatus len lines prepend) bs'
203202 -- No newline find in this chunk. Add it to the prepend,
204203 -- update the length, and continue processing.
205204 push' Nothing = do
206− bs <- readSource' src
205+ bst <- readSource' src
207206 when (S.null bs) $ throwIO IncompleteHeaders
208− push src status bs
207+ push src status bst
209208 where
210209 len' = len + bsLen
211210 prepend' = S.append bs
@@ -233,9 +232,9 @@ push src (THStatus len lines prepend) bs'
233232 in push src status bs''
234233 else do
235234 -- no more bytes in this chunk, ask for more
236− bs <- readSource' src
235+ bst <- readSource' src
237236 when (S.null bs) $ throwIO IncompleteHeaders
238− push src status bs
237+ push src status bst
239238 where
240239 start = end + 1 -- start of next chunk
241240 line = SU.unsafeTake (checkCR bs end) bs
warp/Network/Wai/Handler/Warp/RequestHeader.hs−1
@@ -17,7 +17,6 @@ import Foreign.ForeignPtr (withForeignPtr)
1717import Foreign.Ptr (Ptr, plusPtr, minusPtr, nullPtr)
1818import Foreign.Storable (peek)
1919import qualified Network.HTTP.Types as H
20−import qualified Network.HTTP.Types.URI as H
2120import Network.Wai.Handler.Warp.Types
2221import qualified Network.HTTP.Types.Header as HH
2322-- $setup
warp/Network/Wai/Handler/Warp/Response.hs+1−1
@@ -17,7 +17,7 @@ import Control.Applicative
1717import Control.Exception
1818import Data.Array ((!))
1919import Data.ByteString (ByteString)
20−import Data.Streaming.Blaze (newBlazeRecv, reuseBufferStrategy, allocBuffer)
20+import Data.Streaming.Blaze (newBlazeRecv, reuseBufferStrategy)
2121import qualified Data.ByteString as S
2222import Control.Monad (unless, when)
2323import qualified Data.ByteString.Char8 as B (pack)
warp/Network/Wai/Handler/Warp/Settings.hs−1
@@ -5,7 +5,6 @@ module Network.Wai.Handler.Warp.Settings where
55
66import Control.Exception
77import Control.Monad (when)
8−import qualified Data.ByteString as S
98import qualified Data.Text as T
109import qualified Data.Text.IO as TIO
1110import Data.Streaming.Network (HostPreference)
warp/test/ExceptionSpec.hs+4−6
@@ -4,14 +4,12 @@ module ExceptionSpec (main, spec) where
44
55import Control.Applicative
66import Control.Monad
7−import Control.Concurrent (forkIO, threadDelay)
87import Network.HTTP
98import Network.Stream
109import Network.HTTP.Types hiding (Header)
1110import Network.Wai hiding (Response)
1211import Network.Wai.Internal (Request(..))
1312import Network.Wai.Handler.Warp
14−import System.IO.Unsafe (unsafePerformIO)
1513import Test.Hspec
1614import Control.Exception
1715import qualified Data.Streaming.Network as N
@@ -25,9 +23,9 @@ withTestServer :: (Int -> IO a) -> IO a
2523withTestServer inner = bracket
2624 (N.bindRandomPortTCP "*4")
2725 (sClose . snd)
28− $ \(port, lsocket) -> do
26+ $ \(prt, lsocket) -> do
2927 withAsync (runSettingsSocket defaultSettings lsocket testApp)
30− $ \_ -> inner port
28+ $ \_ -> inner prt
3129
3230testApp :: Application
3331testApp (Network.Wai.Internal.Request {pathInfo = [x]}) f
@@ -61,8 +59,8 @@ spec = describe "responds even if there is an exception" $ do
6159 sc <- rspCode <$> sendGET "http://localhost:2345/bodyError"
6260 sc `shouldBe` (5,0,0)
6361 -}
64− it "ioException" $ withTestServer $ \port -> do
65− sc <- rspCode <$> sendGET (concat $ ["http://localhost:", show port, "/ioException"])
62+ it "ioException" $ withTestServer $ \prt -> do
63+ sc <- rspCode <$> sendGET (concat $ ["http://localhost:", show prt, "/ioException"])
6664 sc `shouldBe` (5,0,0)
6765
6866----------------------------------------------------------------
warp/test/RequestSpec.hs+4−2
@@ -11,7 +11,6 @@ import Test.Hspec
1111import Test.Hspec.QuickCheck
1212import qualified Data.ByteString as S
1313import qualified Data.ByteString.Char8 as S8
14−import qualified Data.ByteString.Lazy as L
1514import qualified Network.HTTP.Types.Header as HH
1615import Data.IORef
1716
@@ -66,11 +65,13 @@ spec = do
6665 tooMany = headerLinesList $ repeat "f\n"
6766 tooLarge = headerLinesList $ repeat "f"
6867
68+headerLinesList :: [S8.ByteString] -> IO (S8.ByteString, [S8.ByteString])
6969headerLinesList orig = do
7070 (res, src) <- headerLinesList' orig
7171 leftover <- readLeftoverSource src
7272 return (leftover, res)
7373
74+headerLinesList' :: [S8.ByteString] -> IO ([S8.ByteString], Source)
7475headerLinesList' orig = do
7576 ref <- newIORef orig
7677 let src = do
@@ -84,6 +85,7 @@ headerLinesList' orig = do
8485 res <- headerLines src'
8586 return (res, src')
8687
88+consumeLen :: Int -> Source -> IO S8.ByteString
8789consumeLen len0 src =
8890 loop id len0
8991 where
@@ -94,7 +96,7 @@ consumeLen len0 src =
9496 if S.null bs
9597 then loop front 0
9698 else do
97− let (x, y) = S.splitAt len bs
99+ let (x, _) = S.splitAt len bs
98100 loop (front . (x:)) (len - S.length x)
99101
100102overLargeHeader :: Selector InvalidRequest