packages feed

wai-extra 3.0.22.0 → 3.0.22.1

raw patch · 12 files changed

+61/−74 lines, 12 filesdep −blaze-builderdep ~bytestringdep ~streaming-commonsdep ~wai-logger

Dependencies removed: blaze-builder

Dependency ranges changed: bytestring, streaming-commons, wai-logger

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 3.0.22.1++* Drop dependency on blaze-builder, requiring streaming-commons >= 0.2+ ## 3.0.22.0  * Support for streaming-commons 0.2
Network/Wai/EventSource/EventStream.hs view
@@ -9,8 +9,7 @@     eventToBuilder     ) where -import Blaze.ByteString.Builder-import Blaze.ByteString.Builder.Char8+import Data.ByteString.Builder #if __GLASGOW_HASKELL__ < 710 import Data.Monoid #endif@@ -39,18 +38,18 @@     Newline as a Builder. -} nl :: Builder-nl = fromChar '\n'+nl = char7 '\n'   {-|     Field names as Builder -} nameField, idField, dataField, retryField, commentField :: Builder-nameField = fromString "event:"-idField = fromString "id:"-dataField = fromString "data:"-retryField = fromString "retry:"-commentField = fromChar ':'+nameField = string7 "event:"+idField = string7 "id:"+dataField = string7 "data:"+retryField = string7 "retry:"+commentField = char7 ':'   {-|@@ -66,7 +65,7 @@ -} eventToBuilder :: ServerEvent -> Maybe Builder eventToBuilder (CommentEvent txt) = Just $ field commentField txt-eventToBuilder (RetryEvent   n)   = Just $ field retryField (fromShow n)+eventToBuilder (RetryEvent   n)   = Just $ field retryField (string8 . show $ n) eventToBuilder (CloseEvent)       = Nothing eventToBuilder (ServerEvent n i d)= Just $     (name n $ evid i $ mconcat (map (field dataField) d)) `mappend` nl
Network/Wai/Handler/CGI.hs view
@@ -19,8 +19,8 @@ import Data.Char (toLower) import qualified System.IO import qualified Data.String as String-import Blaze.ByteString.Builder (fromByteString, toLazyByteString, flush)-import Blaze.ByteString.Builder.Char8 (fromChar, fromString)+import Data.ByteString.Builder (byteString, toLazyByteString, char7, string8)+import Data.ByteString.Builder.Extra (flush) import Data.ByteString.Lazy.Internal (defaultChunkSize) import System.IO (Handle) import Network.HTTP.Types (Status (..), hRange, hContentType, hContentLength)@@ -30,12 +30,7 @@ import Data.Monoid (mconcat, mempty, mappend) #endif -#if MIN_VERSION_streaming_commons(0, 2, 0)-import qualified Data.Streaming.ByteString.Builder as Blaze-#else-import qualified Data.Streaming.Blaze as Blaze-#endif-+import qualified Data.Streaming.ByteString.Builder as Builder import Data.Function (fix) import Control.Monad (unless, void) @@ -136,11 +131,7 @@                 return ResponseReceived             _ -> do                 let (s, hs, wb) = responseToStream res-#if MIN_VERSION_streaming_commons(0, 2, 0)-                (blazeRecv, blazeFinish) <- Blaze.newBuilderRecv Blaze.defaultStrategy-#else-                (blazeRecv, blazeFinish) <- Blaze.newBlazeRecv Blaze.defaultStrategy-#endif+                (blazeRecv, blazeFinish) <- Builder.newBuilderRecv Builder.defaultStrategy                 wb $ \b -> do                     let sendBuilder builder = do                             popper <- blazeRecv builder@@ -149,30 +140,30 @@                                 unless (B.null bs) $ do                                     outputH bs                                     loop-                    sendBuilder $ headers s hs `mappend` fromChar '\n'+                    sendBuilder $ headers s hs `mappend` char7 '\n'                     b sendBuilder (sendBuilder flush)                 blazeFinish >>= maybe (return ()) outputH                 return ResponseReceived   where     headers s hs = mconcat (map header $ status s : map header' (fixHeaders hs))-    status (Status i m) = (fromByteString "Status", mconcat-        [ fromString $ show i-        , fromChar ' '-        , fromByteString m+    status (Status i m) = (byteString "Status", mconcat+        [ string8 $ show i+        , char7 ' '+        , byteString m         ])-    header' (x, y) = (fromByteString $ CI.original x, fromByteString y)+    header' (x, y) = (byteString $ CI.original x, byteString y)     header (x, y) = mconcat         [ x-        , fromByteString ": "+        , byteString ": "         , y-        , fromChar '\n'+        , char7 '\n'         ]     sfBuilder s hs sf fp = mconcat         [ headers s hs-        , header $ (fromByteString sf, fromString fp)-        , fromChar '\n'-        , fromByteString sf-        , fromByteString " not supported"+        , header $ (byteString sf, string8 fp)+        , char7 '\n'+        , byteString sf+        , byteString " not supported"         ]     fixHeaders h =         case lookup hContentType h of
Network/Wai/Header.hs view
@@ -14,5 +14,5 @@ readInt :: S8.ByteString -> Maybe Integer readInt bs =     case S8.readInteger bs of-        Just (i, "") -> Just i+        Just (i, rest) | S8.null rest -> Just i         _ -> Nothing
Network/Wai/Middleware/Gzip.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types, ScopedTypeVariables #-} --------------------------------------------------------- -- |@@ -31,18 +30,14 @@ import Network.HTTP.Types ( Status, Header, hContentEncoding, hUserAgent                           , hContentType, hContentLength) import System.Directory (doesFileExist, createDirectoryIfMissing)-import Blaze.ByteString.Builder (fromByteString)+import Data.ByteString.Builder (byteString)+import qualified Data.ByteString.Builder.Extra as Blaze (flush) import Control.Exception (try, SomeException) import qualified Data.Set as Set import Network.Wai.Header import Network.Wai.Internal-#if MIN_VERSION_streaming_commons(0, 2, 0) import qualified Data.Streaming.ByteString.Builder as B-#else-import qualified Data.Streaming.Blaze as B-#endif import qualified Data.Streaming.Zlib as Z-import qualified Blaze.ByteString.Builder as Blaze import Control.Monad (unless) import Data.Function (fix) import Control.Exception (throwIO)@@ -187,11 +182,7 @@         Just m | gzipCheckMime set m ->             let hs' = fixHeaders hs              in wb $ \body -> sendResponse $ responseStream s hs' $ \sendChunk flush -> do-#if MIN_VERSION_streaming_commons(0, 2, 0)                     (blazeRecv, _) <- B.newBuilderRecv B.defaultStrategy-#else-                    (blazeRecv, _) <- B.newBlazeRecv B.defaultStrategy-#endif                     deflate <- Z.initDeflate 1 (Z.WindowBits 31)                     let sendBuilder builder = do                             popper <- blazeRecv builder@@ -210,7 +201,7 @@                             case result of                                 Z.PRDone -> return ()                                 Z.PRNext bs' -> do-                                    sendChunk $ fromByteString bs'+                                    sendChunk $ byteString bs'                                     loop                                 Z.PRError e -> throwIO e 
Network/Wai/Middleware/Jsonp.hs view
@@ -18,8 +18,8 @@ import Network.Wai.Internal import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as B8-import Blaze.ByteString.Builder (copyByteString)-import Blaze.ByteString.Builder.Char8 (fromChar)+import Data.ByteString.Builder.Extra (byteStringCopy)+import Data.ByteString.Builder (char7) #if __GLASGOW_HASKELL__ < 710 import Data.Monoid (mappend) #endif@@ -60,10 +60,10 @@         sendResponse $ case checkJSON hs of             Nothing -> r             Just hs' -> responseBuilder s hs' $-                copyByteString c-                `mappend` fromChar '('+                byteStringCopy c+                `mappend` char7 '('                 `mappend` b-                `mappend` fromChar ')'+                `mappend` char7 ')'     go c r =         case checkJSON hs of             Just hs' -> addCallback c s hs' wb@@ -81,9 +81,9 @@      addCallback cb s hs wb =         wb $ \body -> sendResponse $ responseStream s hs $ \sendChunk flush -> do-            sendChunk $ copyByteString cb `mappend` fromChar '('+            sendChunk $ byteStringCopy cb `mappend` char7 '('             _ <- body sendChunk flush-            sendChunk $ fromChar ')'+            sendChunk $ char7 ')'  changeVal :: Eq a           => a
Network/Wai/Middleware/RequestLogger.hs view
@@ -20,7 +20,7 @@     ) where  import System.IO (Handle, hFlush, stdout)-import qualified Blaze.ByteString.Builder as B+import qualified Data.ByteString.Builder as B (Builder, byteString) import qualified Data.ByteString as BS import Data.ByteString.Char8 (pack) import Control.Monad (when)@@ -130,7 +130,7 @@     t1 <- getCurrentTime     date <- liftIO getdate     -- We use Nothing for the response size since we generally don't know it-    builderIO <- newIORef $ B.fromByteString ""+    builderIO <- newIORef $ B.byteString ""     res' <- recordChunks builderIO res     rspRcv <- sendResponse res'     _ <- liftIO . cb .
Network/Wai/Middleware/RequestLogger/JSON.hs view
@@ -2,7 +2,8 @@  module Network.Wai.Middleware.RequestLogger.JSON (formatAsJSON) where -import qualified Blaze.ByteString.Builder as BB+import qualified Data.ByteString.Builder as BB (toLazyByteString)+import Data.ByteString.Lazy (toStrict) import Data.Aeson import Data.CaseInsensitive (original) import Data.Monoid ((<>))@@ -31,7 +32,7 @@         , "size"   .= responseSize         , "body"   .=           if statusCode status >= 400-            then Just . decodeUtf8 . BB.toByteString $ response+            then Just . decodeUtf8 . toStrict . BB.toLazyByteString $ response             else Nothing         ]       , "time"     .= decodeUtf8 date
Network/Wai/Test.hs view
@@ -52,8 +52,7 @@ import qualified Web.Cookie as Cookie import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as S8-import Blaze.ByteString.Builder (toLazyByteString, toByteString)-import qualified Blaze.ByteString.Builder as B+import Data.ByteString.Builder (toLazyByteString) import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy.Char8 as L8 import qualified Network.HTTP.Types as H@@ -114,7 +113,7 @@ setPath :: Request -> S8.ByteString -> Request setPath req path = req {     pathInfo = segments-  , rawPathInfo = B.toByteString (H.encodePathSegments segments)+  , rawPathInfo = (L8.toStrict . toLazyByteString) (H.encodePathSegments segments)   , queryString = query   , rawQueryString = (H.renderQuery True query)   }@@ -143,7 +142,7 @@   let cookiePairs = [ (Cookie.setCookieName c, Cookie.setCookieValue c)                     | c <- map snd $ Map.toList cookiesForRequest                     ]-  let cookieValue = toByteString $ Cookie.renderCookies cookiePairs+  let cookieValue = L8.toStrict . toLazyByteString $ Cookie.renderCookies cookiePairs       addCookieHeader rest         | null cookiePairs = rest         | otherwise = ("Cookie", cookieValue) : rest
example/Main.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module Main where -import Blaze.ByteString.Builder.Char.Utf8 (fromString)+import Data.ByteString.Builder (string8) import Control.Concurrent (forkIO, threadDelay) import Control.Concurrent.Chan import Control.Monad@@ -27,15 +27,15 @@ eventChan chan = forever $ do     threadDelay 1000000     time <- getPOSIXTime-    writeChan chan (ServerEvent Nothing Nothing [fromString . show $ time])+    writeChan chan (ServerEvent Nothing Nothing [string8 . show $ time])  eventIO :: IO ServerEvent eventIO = do     threadDelay 1000000     time <- getPOSIXTime-    return $ ServerEvent (Just $ fromString "io")+    return $ ServerEvent (Just $ string8 "io")                          Nothing-                         [fromString . show $ time]+                         [string8 . show $ time]  main :: IO () main = do
test/Network/Wai/TestSpec.hs view
@@ -16,12 +16,16 @@ import           Network.HTTP.Types (status200)  import qualified Data.ByteString.Lazy.Char8 as L8-import           Blaze.ByteString.Builder (toByteString)+import           Data.ByteString.Builder (Builder, toLazyByteString)+import           Data.ByteString (ByteString)  import qualified Web.Cookie as Cookie  main :: IO () main = hspec spec++toByteString :: Builder -> ByteString+toByteString = L8.toStrict . toLazyByteString  spec :: Spec spec = do
wai-extra.cabal view
@@ -1,5 +1,5 @@ Name:                wai-extra-Version:             3.0.22.0+Version:             3.0.22.1 Synopsis:            Provides some basic WAI handlers and middleware. description:   Provides basic WAI handler and middleware functionality:@@ -88,20 +88,19 @@  Library   Build-Depends:     base                      >= 4.6 && < 5-                   , bytestring                >= 0.9.1.4+                   , bytestring                >= 0.10.4                    , wai                       >= 3.0.3.0  && < 3.3                    , old-locale                >= 1.0.0.2  && < 1.1                    , time                      >= 1.1.4                    , network                   >= 2.6.1.0                    , directory                 >= 1.0.1                    , transformers              >= 0.2.2-                   , blaze-builder             >= 0.2.1.4  && < 0.5                    , http-types                >= 0.7                    , text                      >= 0.7                    , case-insensitive          >= 0.2                    , data-default-class                    , fast-logger               >= 2.4.5    && < 2.5-                   , wai-logger                >= 2.2.6    && < 2.4+                   , wai-logger                >= 2.3.2    && < 2.4                    , ansi-terminal                    , resourcet                 >= 0.4.6    && < 1.3                    , void                      >= 0.5@@ -111,7 +110,7 @@                    , word8                    , lifted-base               >= 0.1.2                    , deepseq-                   , streaming-commons+                   , streaming-commons         >= 0.2                    , unix-compat                    , cookie                    , vault@@ -171,7 +170,7 @@                      , wai                      , time                      , http-types-                     , blaze-builder+                     , bytestring   else     buildable: False   default-language:    Haskell2010@@ -200,7 +199,6 @@                    , resourcet                    , bytestring                    , HUnit-                   , blaze-builder                    , cookie                    , time                    , case-insensitive