on 869c80a help sign in
stackage/patching/patches/hoogle-4.2.32.patch
58 lines 2.0 kB history raw
1diff -ru orig/src/General/Web.hs new/src/General/Web.hs
2--- orig/src/General/Web.hs 2014-06-09 15:25:38.583521732 +0300
3+++ new/src/General/Web.hs 2014-06-09 15:25:38.000000000 +0300
4@@ -21,6 +21,9 @@
5 import General.Base
6 import System.FilePath
7 import Network.Wai
8+#if MIN_VERSION_wai(3, 0, 0)
9+import Data.IORef
10+#endif
11 #if MIN_VERSION_wai(2, 0, 0)
12 import Network.Wai.Internal
13 #endif
14@@ -46,7 +49,15 @@
16 responseFlatten :: Response -> IO (Status, ResponseHeaders, LBString)
17 responseFlatten r = do
18-#if MIN_VERSION_wai(2, 0, 0)
19+#if MIN_VERSION_wai(3, 0, 0)
20+ let (s,hs,withBody) = responseToStream r
21+ ref <- newIORef mempty
22+ let addChunk builder = modifyIORef ref (<> builder)
23+ withBody $ \body -> body addChunk (return ())
24+ builder <- readIORef ref
25+ let res = toLazyByteString builder
26+ return (s,hs,res)
27+#elif MIN_VERSION_wai(2, 0, 0)
28 let (s,hs,withSrc) = responseToSource r
29 chunks <- withSrc $ \src -> src $$ consume
30 let res = toLazyByteString $ mconcat [x | Chunk x <- chunks]
31diff -ru orig/src/Web/Server.hs new/src/Web/Server.hs
32--- orig/src/Web/Server.hs 2014-06-09 15:25:38.575521732 +0300
33+++ new/src/Web/Server.hs 2014-06-09 15:25:38.000000000 +0300
34@@ -32,14 +32,23 @@
35 resp <- respArgs q
36 v <- newMVar ()
37 putStrLn $ "Starting Hoogle Server on port " ++ show port
38- runSettings defaultSettings{settingsOnException=exception, settingsPort=port} $ \r -> liftIO $ do
39+ runSettings defaultSettings{settingsOnException=exception, settingsPort=port}
40+#if MIN_VERSION_wai(3, 0, 0)
41+ $ \r sendResponse -> do
42+#else
43+ $ \r -> liftIO $ do
44+#endif
45 start <- getCurrentTime
46 res <- talk resp q r
47 responseEvaluate res
48 stop <- getCurrentTime
49 let t = floor $ diffUTCTime stop start * 1000
50 withMVar v $ const $ putStrLn $ bsUnpack (rawPathInfo r) ++ bsUnpack (rawQueryString r) ++ " ms:" ++ show t
51+#if MIN_VERSION_wai(3, 0, 0)
52+ sendResponse res
53+#else
54 return res
55+#endif
58 #if MIN_VERSION_wai(2, 0, 0)