Hello community,

here is the log from the commit of package ghc-wai-extra for openSUSE:Factory 
checked in at 2015-11-23 07:30:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-wai-extra (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-wai-extra.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-wai-extra"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-wai-extra/ghc-wai-extra.changes      
2015-10-20 00:04:38.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-wai-extra.new/ghc-wai-extra.changes 
2015-11-23 07:30:26.000000000 +0100
@@ -1,0 +2,9 @@
+Sun Nov 22 09:48:19 UTC 2015 - mimi...@gmail.com
+
+- update to 3.0.13
+* Autoflush handle
+* Add Network.Wai.Header.contentLength to read the Content-Length header
+    of a response
+* The gzip middleware no longer zips responses smaller than 860 bytes
+
+-------------------------------------------------------------------

Old:
----
  wai-extra-3.0.11.1.tar.gz

New:
----
  wai-extra-3.0.13.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-wai-extra.spec ++++++
--- /var/tmp/diff_new_pack.uUQDB2/_old  2015-11-23 07:30:27.000000000 +0100
+++ /var/tmp/diff_new_pack.uUQDB2/_new  2015-11-23 07:30:27.000000000 +0100
@@ -21,7 +21,7 @@
 %bcond_with tests
 
 Name:           ghc-wai-extra
-Version:        3.0.11.1
+Version:        3.0.13
 Release:        0
 Summary:        Provides some basic WAI handlers and middleware
 License:        MIT

++++++ wai-extra-3.0.11.1.tar.gz -> wai-extra-3.0.13.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-extra-3.0.11.1/ChangeLog.md 
new/wai-extra-3.0.13/ChangeLog.md
--- old/wai-extra-3.0.11.1/ChangeLog.md 2015-10-06 20:41:51.000000000 +0200
+++ new/wai-extra-3.0.13/ChangeLog.md   2015-11-18 08:03:26.000000000 +0100
@@ -1,3 +1,12 @@
+## 3.0.13
+
+* Autoflush handle [#466](https://github.com/yesodweb/wai/pull/466)
+
+## 3.0.12
+
+* Add Network.Wai.Header.contentLength to read the Content-Length header of a 
response
+* The gzip middleware no longer zips responses smaller than 860 bytes
+
 ## 3.0.11
 
 * Add constructor for more detailed custom output formats for RequestLogger
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-extra-3.0.11.1/Network/Wai/Header.hs 
new/wai-extra-3.0.13/Network/Wai/Header.hs
--- old/wai-extra-3.0.11.1/Network/Wai/Header.hs        1970-01-01 
01:00:00.000000000 +0100
+++ new/wai-extra-3.0.13/Network/Wai/Header.hs  2015-11-18 08:03:26.000000000 
+0100
@@ -0,0 +1,18 @@
+-- | Some helpers for dealing with WAI 'Header's.
+
+module Network.Wai.Header
+    ( contentLength
+    ) where
+
+import qualified Data.ByteString.Char8 as S8
+import Network.HTTP.Types as H
+
+-- | More useful for a response. A Wai Request already has a requestBodyLength
+contentLength :: [(HeaderName, S8.ByteString)] -> Maybe Integer
+contentLength hdrs = lookup H.hContentLength hdrs >>= readInt
+
+readInt :: S8.ByteString -> Maybe Integer
+readInt bs =
+    case S8.readInteger bs of
+        Just (i, "") -> Just i
+        _ -> Nothing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-extra-3.0.11.1/Network/Wai/Middleware/Gzip.hs 
new/wai-extra-3.0.13/Network/Wai/Middleware/Gzip.hs
--- old/wai-extra-3.0.11.1/Network/Wai/Middleware/Gzip.hs       2015-08-14 
22:03:39.000000000 +0200
+++ new/wai-extra-3.0.13/Network/Wai/Middleware/Gzip.hs 2015-11-18 
08:03:26.000000000 +0100
@@ -33,6 +33,7 @@
 import Blaze.ByteString.Builder (fromByteString)
 import Control.Exception (try, SomeException)
 import qualified Data.Set as Set
+import Network.Wai.Header
 import Network.Wai.Internal
 import qualified Data.Streaming.Blaze as B
 import qualified Data.Streaming.Zlib as Z
@@ -79,7 +80,7 @@
     case res of
         ResponseRaw{} -> sendResponse res
         ResponseFile{} | gzipFiles set == GzipIgnore -> sendResponse res
-        _ -> if "gzip" `elem` enc && not isMSIE6 && not (isEncoded res)
+        _ -> if "gzip" `elem` enc && not isMSIE6 && not (isEncoded res) && 
(bigEnough res)
                 then
                     case (res, gzipFiles set) of
                         (ResponseFile s hs file Nothing, GzipCacheFolder 
cache) ->
@@ -96,6 +97,16 @@
     isMSIE6 = "MSIE 6" `S.isInfixOf` ua
     isEncoded res = isJust $ lookup hContentEncoding $ responseHeaders res
 
+    bigEnough rsp = case contentLength (responseHeaders rsp) of
+      Nothing -> True -- This could be a streaming case
+      Just len -> len >= minimumLength
+
+    -- For a small enough response, gzipping will actually increase the size
+    -- Potentially for anything less than 860 bytes gzipping could be a net 
loss
+    -- The actual number is application specific though and may need to be 
adjusted
+    -- 
http://webmasters.stackexchange.com/questions/31750/what-is-recommended-minimum-object-size-for-gzip-performance-benefits
+    minimumLength = 860
+
 compressFile :: Status -> [Header] -> FilePath -> FilePath -> (Response -> IO 
a) -> IO a
 compressFile s hs file cache sendResponse = do
     e <- doesFileExist tmpfile
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/wai-extra-3.0.11.1/Network/Wai/Middleware/RequestLogger.hs 
new/wai-extra-3.0.13/Network/Wai/Middleware/RequestLogger.hs
--- old/wai-extra-3.0.11.1/Network/Wai/Middleware/RequestLogger.hs      
2015-10-09 21:47:57.000000000 +0200
+++ new/wai-extra-3.0.13/Network/Wai/Middleware/RequestLogger.hs        
2015-11-18 08:03:26.000000000 +0100
@@ -19,12 +19,17 @@
     , IPAddrSource (..)
     ) where
 
-import System.IO (Handle, stdout)
+import System.IO (Handle, hFlush, stdout)
 import qualified Blaze.ByteString.Builder as B
 import qualified Data.ByteString as BS
 import Data.ByteString.Char8 (pack, unpack)
+import Control.Monad (when)
 import Control.Monad.IO.Class (liftIO)
-import Network.Wai (Request(..), Middleware, responseStatus, Response, 
responseHeaders)
+import Network.Wai
+  ( Request(..), requestBodyLength, RequestBodyLength(..)
+  , Middleware
+  , Response, responseStatus, responseHeaders
+  )
 import System.Log.FastLogger
 import Network.HTTP.Types as H
 import Data.Maybe (fromMaybe)
@@ -41,6 +46,7 @@
 import Data.Default.Class (Default (def))
 import Network.Wai.Logger
 import Network.Wai.Middleware.RequestLogger.Internal
+import Network.Wai.Header (contentLength)
 import Data.Text.Encoding (decodeUtf8')
 
 data OutputFormat = Apache IPAddrSource
@@ -86,13 +92,13 @@
 mkRequestLogger RequestLoggerSettings{..} = do
     let (callback, flusher) =
             case destination of
-                Handle h -> (BS.hPutStr h . logToByteString, return ())
-                Logger l -> (pushLogStr l, flushLogStr l)
+                Handle h -> (BS.hPutStr h . logToByteString, when autoFlush 
(hFlush h))
+                Logger l -> (pushLogStr l, when autoFlush (flushLogStr l))
                 Callback c -> (c, return ())
     case outputFormat of
         Apache ipsrc -> do
             getdate <- getDateGetter flusher
-            apache <- initLogger ipsrc (LogCallback callback (return ())) 
getdate
+            apache <- initLogger ipsrc (LogCallback callback flusher) getdate
             return $ apacheMiddleware apache
         Detailed useColors -> detailedMiddleware
                                   (\str -> callback str >> flusher)
@@ -106,11 +112,7 @@
 
 apacheMiddleware :: ApacheLoggerActions -> Middleware
 apacheMiddleware ala app req sendResponse = app req $ \res -> do
-    let msize = lookup H.hContentLength (responseHeaders res) >>= readInt'
-        readInt' bs =
-            case S8.readInteger bs of
-                Just (i, "") -> Just i
-                _ -> Nothing
+    let msize = contentLength (responseHeaders res)
     apacheLogger ala req (responseStatus res) msize
     sendResponse res
 
@@ -246,11 +248,12 @@
                     -> (BS.ByteString -> BS.ByteString -> [BS.ByteString])
                     -> Middleware
 detailedMiddleware' cb ansiColor ansiMethod ansiStatusCode app req 
sendResponse = do
-    let mlen = lookup H.hContentLength (requestHeaders req) >>= readInt
     (req', body) <-
-        case mlen of
+        -- second tuple item should not be necessary, but a test runner might 
mess it up
+        case (requestBodyLength req, contentLength (requestHeaders req)) of
             -- log the request body if it is small
-            Just len | len <= 2048 -> getRequestBody req
+            (KnownLength len, _) | len <= 2048 -> getRequestBody req
+            (_, Just len)        | len <= 2048 -> getRequestBody req
             _ -> return (req, [])
 
     let reqbodylog _ = if null body then [""] else ansiColor White "  Request 
Body: " <> body <> ["\n"]
@@ -308,10 +311,7 @@
     collectPostParams (postParams, files) = postParams ++
       map (\(k,v) -> (k, "FILE: " <> fileName v)) files
 
-    readInt bs =
-        case reads $ unpack bs of
-            (i, _):_ -> Just (i :: Int)
-            [] -> Nothing
+
 
 statusBS :: Response -> BS.ByteString
 statusBS = pack . show . statusCode . responseStatus
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-extra-3.0.11.1/test/WaiExtraSpec.hs 
new/wai-extra-3.0.13/test/WaiExtraSpec.hs
--- old/wai-extra-3.0.11.1/test/WaiExtraSpec.hs 2015-07-13 00:51:57.000000000 
+0200
+++ new/wai-extra-3.0.13/test/WaiExtraSpec.hs   2015-11-18 08:03:26.000000000 
+0100
@@ -341,10 +341,8 @@
                 }
   where
     params = [("foo", "bar"), ("baz", "bin")]
-    -- FIXME change back once we include post parameter output in logging
-    -- postOutput = T.pack $ "POST \nAccept: \n  Params: " ++ (show params)
     -- the time cannot be known, so match around it
-    postOutput = ("POST /\n  Accept: \n  Status: 200 OK 0", "s\n")
+    postOutput = (T.pack $ "POST /\n  Params: " ++ (show params), "s\n")
     getOutput params' = ("GET /location\n  Params: " <> T.pack (show params') 
<> "\n  Accept: \n  Status: 200 OK 0", "s\n")
 
     debugApp (beginning, ending) req send = do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/wai-extra-3.0.11.1/wai-extra.cabal 
new/wai-extra-3.0.13/wai-extra.cabal
--- old/wai-extra-3.0.11.1/wai-extra.cabal      2015-10-10 00:52:55.000000000 
+0200
+++ new/wai-extra-3.0.13/wai-extra.cabal        2015-11-18 08:03:26.000000000 
+0100
@@ -1,5 +1,5 @@
 Name:                wai-extra
-Version:             3.0.11.1
+Version:             3.0.13
 Synopsis:            Provides some basic WAI handlers and middleware.
 description:
   Provides basic WAI handler and middleware functionality:
@@ -123,6 +123,7 @@
 
   Exposed-modules:   Network.Wai.Handler.CGI
                      Network.Wai.Handler.SCGI
+                     Network.Wai.Header
                      Network.Wai.Middleware.AcceptOverride
                      Network.Wai.Middleware.AddHeaders
                      Network.Wai.Middleware.Approot


Reply via email to