wai-handler-launch 1.0.0 → 1.1.0
raw patch · 2 files changed
+30/−26 lines, 2 filesdep ~blaze-builder-conduitdep ~conduitdep ~waiPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: blaze-builder-conduit, conduit, wai, warp, zlib-conduit
API changes (from Hackage documentation)
Files
- Network/Wai/Handler/Launch.hs +18/−13
- wai-handler-launch.cabal +12/−13
Network/Wai/Handler/Launch.hs view
@@ -21,8 +21,8 @@ #else import System.Cmd (rawSystem) #endif-import Data.Conduit.Zlib (ungzip)-import Data.Conduit.Blaze (builderToByteString)+import Data.Conduit.Zlib (decompressFlush, WindowBits (WindowBits))+import Data.Conduit.Blaze (builderToByteStringFlush) import qualified Data.Conduit as C import qualified Data.Conduit.List as CL @@ -48,38 +48,43 @@ let (s, hs, body) = responseSource res let (isEnc, headers') = fixHeaders id hs let headers'' = filter (\(x, _) -> x /= "content-length") headers'- let fixEnc src = if isEnc then src C.$= ungzip else src+ let fixEnc src =+ if isEnc then+ src C.$= decompressFlush (WindowBits 31)+ else src return $ ResponseSource s headers''- $ fixEnc (body C.$= builderToByteString)+ $ fixEnc (body C.$= builderToByteStringFlush) C.$= insideHead- C.$= CL.map fromByteString+ C.$= CL.map (fmap fromByteString) toInsert :: S.ByteString toInsert = "<script>setInterval(function(){var x;if(window.XMLHttpRequest){x=new XMLHttpRequest();}else{x=new ActiveXObject(\"Microsoft.XMLHTTP\");}x.open(\"GET\",\"/_ping\",false);x.send();},60000)</script>" -insideHead :: C.Conduit S.ByteString IO S.ByteString+insideHead :: C.Conduit (C.Flush S.ByteString) IO (C.Flush S.ByteString) insideHead =- C.conduitState (Just (S.empty, whole)) push close+ C.conduitState (Just (S.empty, whole)) push' close where whole = "<head>"+ push' state (C.Chunk x) = (fmap . fmap) C.Chunk (push state x)+ push' state C.Flush = return $ C.StateProducing state [C.Flush] push (Just (held, atFront)) x | atFront `S.isPrefixOf` x = do let y = S.drop (S.length atFront) x- return (Nothing, C.Producing [held, atFront, toInsert, y])+ return $ C.StateProducing Nothing [held, atFront, toInsert, y] | whole `S.isInfixOf` x = do let (before, rest) = S.breakSubstring whole x let after = S.drop (S.length whole) rest- return (Nothing, C.Producing [held, before, whole, toInsert, after])+ return $ C.StateProducing Nothing [held, before, whole, toInsert, after] | x `S.isPrefixOf` atFront = do let held' = held `S.append` x atFront' = S.drop (S.length x) atFront- return (Just (held', atFront'), C.Producing [])+ return $ C.StateProducing (Just (held', atFront')) [] | otherwise = do let (held', atFront', x') = getOverlap whole x- return (Just (held', atFront'), C.Producing [held, x'])- push Nothing x = return (Nothing, C.Producing [x])+ return $ C.StateProducing (Just (held', atFront')) [held, x']+ push Nothing x = return $ C.StateProducing Nothing [x] - close (Just (held, _)) = return [held, toInsert]+ close (Just (held, _)) = return [C.Chunk held, C.Chunk toInsert] close Nothing = return [] getOverlap :: S.ByteString -> S.ByteString -> (S.ByteString, S.ByteString, S.ByteString)
wai-handler-launch.cabal view
@@ -1,5 +1,5 @@ Name: wai-handler-launch-Version: 1.0.0+Version: 1.1.0 Synopsis: Launch a web app in the default browser. Description: This handles cross-platform launching and inserts Javascript code to ping the server. When the server no longer receives pings, it shuts down. License: BSD3@@ -12,23 +12,22 @@ Library Exposed-modules: Network.Wai.Handler.Launch- build-depends: base >= 4 && < 5- , wai >= 1.0 && < 1.1- , warp >= 1.0 && < 1.1- , http-types >= 0.6 && < 0.7- , transformers >= 0.2.2 && < 0.3- , bytestring >= 0.9.1.4 && < 0.10- , blaze-builder >= 0.2.1.4 && < 0.4- , conduit- , blaze-builder-conduit- , zlib-conduit+ build-depends: base >= 4 && < 5+ , wai >= 1.1 && < 1.2+ , warp >= 1.1 && < 1.2+ , http-types >= 0.6 && < 0.7+ , transformers >= 0.2.2 && < 0.3+ , bytestring >= 0.9.1.4 && < 0.10+ , blaze-builder >= 0.2.1.4 && < 0.4+ , conduit >= 0.2+ , blaze-builder-conduit >= 0.2+ , zlib-conduit >= 0.2 if os(windows) c-sources: windows.c cpp-options: -DWINDOWS extra-libraries: Shell32 else+ build-depends: process >= 1.0 && < 1.2 if os(darwin) cpp-options: -DMAC- else- build-depends: process >= 1.0 && < 1.2