warp 3.0.0.3 → 3.0.0.4
raw patch · 10 files changed
+20/−26 lines, 10 files
Files
- Network/Wai/Handler/Warp.hs +0/−1
- Network/Wai/Handler/Warp/Conduit.hs +0/−2
- Network/Wai/Handler/Warp/ReadInt.hs +2/−2
- Network/Wai/Handler/Warp/Request.hs +4/−5
- Network/Wai/Handler/Warp/RequestHeader.hs +0/−1
- Network/Wai/Handler/Warp/Response.hs +1/−1
- Network/Wai/Handler/Warp/Settings.hs +0/−1
- test/ExceptionSpec.hs +8/−10
- test/RequestSpec.hs +4/−2
- warp.cabal +1/−1
Network/Wai/Handler/Warp.hs view
@@ -97,7 +97,6 @@ import Control.Exception (SomeException) import Network.Wai (Request, Response) import Network.Socket (SockAddr)-import Data.ByteString (ByteString) import Data.Streaming.Network (HostPreference) -- | Port to listen on. Default value: 3000
Network/Wai/Handler/Warp/Conduit.hs view
@@ -1,12 +1,10 @@ module Network.Wai.Handler.Warp.Conduit where -import Control.Applicative import Control.Exception import Control.Monad (when, unless) import Data.ByteString (ByteString) import Data.ByteString.Lazy.Char8 (pack) import qualified Data.ByteString as S-import qualified Data.ByteString.Char8 as S8 import qualified Data.ByteString.Lazy as L import qualified Data.IORef as I import Data.Word (Word, Word8)
Network/Wai/Handler/Warp/ReadInt.hs view
@@ -32,14 +32,14 @@ -- use Int64 here and then make a generic 'readInt' that allows conversion to -- Int and Integer. -{- NOINLINE readInt64MH #-}+{-# NOINLINE readInt64 #-} readInt64 :: ByteString -> Int64 readInt64 bs = S.foldl' (\ !i !c -> i * 10 + fromIntegral (mhDigitToInt c)) 0 $ S.takeWhile isDigit bs data Table = Table !Addr# -{- NOINLINE mhDigitToInt #-}+{-# NOINLINE mhDigitToInt #-} mhDigitToInt :: Word8 -> Int mhDigitToInt (W8# i) = I# (word2Int# (indexWord8OffAddr# addr (word2Int# i))) where
Network/Wai/Handler/Warp/Request.hs view
@@ -8,7 +8,6 @@ , headerLines ) where -import Control.Applicative import qualified Control.Concurrent as Conc (yield) import Control.Exception (throwIO) import Data.Array ((!))@@ -203,9 +202,9 @@ -- No newline find in this chunk. Add it to the prepend, -- update the length, and continue processing. push' Nothing = do- bs <- readSource' src+ bst <- readSource' src when (S.null bs) $ throwIO IncompleteHeaders- push src status bs+ push src status bst where len' = len + bsLen prepend' = S.append bs@@ -233,9 +232,9 @@ in push src status bs'' else do -- no more bytes in this chunk, ask for more- bs <- readSource' src+ bst <- readSource' src when (S.null bs) $ throwIO IncompleteHeaders- push src status bs+ push src status bst where start = end + 1 -- start of next chunk line = SU.unsafeTake (checkCR bs end) bs
Network/Wai/Handler/Warp/RequestHeader.hs view
@@ -17,7 +17,6 @@ import Foreign.Ptr (Ptr, plusPtr, minusPtr, nullPtr) import Foreign.Storable (peek) import qualified Network.HTTP.Types as H-import qualified Network.HTTP.Types.URI as H import Network.Wai.Handler.Warp.Types import qualified Network.HTTP.Types.Header as HH -- $setup
Network/Wai/Handler/Warp/Response.hs view
@@ -17,7 +17,7 @@ import Control.Exception import Data.Array ((!)) import Data.ByteString (ByteString)-import Data.Streaming.Blaze (newBlazeRecv, reuseBufferStrategy, allocBuffer)+import Data.Streaming.Blaze (newBlazeRecv, reuseBufferStrategy) import qualified Data.ByteString as S import Control.Monad (unless, when) import qualified Data.ByteString.Char8 as B (pack)
Network/Wai/Handler/Warp/Settings.hs view
@@ -5,7 +5,6 @@ import Control.Exception import Control.Monad (when)-import qualified Data.ByteString as S import qualified Data.Text as T import qualified Data.Text.IO as TIO import Data.Streaming.Network (HostPreference)
test/ExceptionSpec.hs view
@@ -4,14 +4,12 @@ import Control.Applicative import Control.Monad-import Control.Concurrent (forkIO, threadDelay) import Network.HTTP import Network.Stream import Network.HTTP.Types hiding (Header) import Network.Wai hiding (Response) import Network.Wai.Internal (Request(..)) import Network.Wai.Handler.Warp-import System.IO.Unsafe (unsafePerformIO) import Test.Hspec import Control.Exception import qualified Data.Streaming.Network as N@@ -25,9 +23,9 @@ withTestServer inner = bracket (N.bindRandomPortTCP "*4") (sClose . snd)- $ \(port, lsocket) -> do+ $ \(prt, lsocket) -> do withAsync (runSettingsSocket defaultSettings lsocket testApp)- $ \_ -> inner port+ $ \_ -> inner prt testApp :: Application testApp (Network.Wai.Internal.Request {pathInfo = [x]}) f@@ -49,20 +47,20 @@ spec = describe "responds even if there is an exception" $ do {- Disabling these tests. We can consider forcing evaluation in Warp. it "statusError" $ do- sc <- rspCode <$> sendGET "http://localhost:2345/statusError"+ sc <- rspCode <$> sendGET "http://127.0.0.1:2345/statusError" sc `shouldBe` (5,0,0) it "headersError" $ do- sc <- rspCode <$> sendGET "http://localhost:2345/headersError"+ sc <- rspCode <$> sendGET "http://127.0.0.1:2345/headersError" sc `shouldBe` (5,0,0) it "headerError" $ do- sc <- rspCode <$> sendGET "http://localhost:2345/headerError"+ sc <- rspCode <$> sendGET "http://127.0.0.1:2345/headerError" sc `shouldBe` (5,0,0) it "bodyError" $ do- sc <- rspCode <$> sendGET "http://localhost:2345/bodyError"+ sc <- rspCode <$> sendGET "http://127.0.0.1:2345/bodyError" sc `shouldBe` (5,0,0) -}- it "ioException" $ withTestServer $ \port -> do- sc <- rspCode <$> sendGET (concat $ ["http://localhost:", show port, "/ioException"])+ it "ioException" $ withTestServer $ \prt -> do+ sc <- rspCode <$> sendGET (concat $ ["http://127.0.0.1:", show prt, "/ioException"]) sc `shouldBe` (5,0,0) ----------------------------------------------------------------
test/RequestSpec.hs view
@@ -11,7 +11,6 @@ import Test.Hspec.QuickCheck import qualified Data.ByteString as S import qualified Data.ByteString.Char8 as S8-import qualified Data.ByteString.Lazy as L import qualified Network.HTTP.Types.Header as HH import Data.IORef @@ -66,11 +65,13 @@ tooMany = headerLinesList $ repeat "f\n" tooLarge = headerLinesList $ repeat "f" +headerLinesList :: [S8.ByteString] -> IO (S8.ByteString, [S8.ByteString]) headerLinesList orig = do (res, src) <- headerLinesList' orig leftover <- readLeftoverSource src return (leftover, res) +headerLinesList' :: [S8.ByteString] -> IO ([S8.ByteString], Source) headerLinesList' orig = do ref <- newIORef orig let src = do@@ -84,6 +85,7 @@ res <- headerLines src' return (res, src') +consumeLen :: Int -> Source -> IO S8.ByteString consumeLen len0 src = loop id len0 where@@ -94,7 +96,7 @@ if S.null bs then loop front 0 else do- let (x, y) = S.splitAt len bs+ let (x, _) = S.splitAt len bs loop (front . (x:)) (len - S.length x) overLargeHeader :: Selector InvalidRequest
warp.cabal view
@@ -1,5 +1,5 @@ Name: warp-Version: 3.0.0.3+Version: 3.0.0.4 Synopsis: A fast, light-weight web server for WAI applications. License: MIT License-file: LICENSE