[Pkg-haskell-commits] darcs: haskell-wai-app-file-cgi: Patch for newer WAI.
Clint Adams
clint at debian.org
Sun Jun 15 12:36:39 UTC 2014
Sun Jun 15 12:35:46 UTC 2014 Clint Adams <clint at debian.org>
* Patch for newer WAI.
M ./changelog +6
A ./patches/0001-WAI-3.0.patch
M ./patches/series +1
Sun Jun 15 12:35:46 UTC 2014 Clint Adams <clint at debian.org>
* Patch for newer WAI.
diff -rN -u old-haskell-wai-app-file-cgi/changelog new-haskell-wai-app-file-cgi/changelog
--- old-haskell-wai-app-file-cgi/changelog 2014-06-15 12:36:39.539606300 +0000
+++ new-haskell-wai-app-file-cgi/changelog 2014-06-15 12:36:39.539606300 +0000
@@ -1,3 +1,9 @@
+haskell-wai-app-file-cgi (2.0.4-2) unstable; urgency=medium
+
+ * Patch for WAI 3.0.
+
+ -- Clint Adams <clint at debian.org> Sat, 14 Jun 2014 17:53:53 -0400
+
haskell-wai-app-file-cgi (2.0.4-1) unstable; urgency=medium
* New upstream version.
diff -rN -u old-haskell-wai-app-file-cgi/patches/0001-WAI-3.0.patch new-haskell-wai-app-file-cgi/patches/0001-WAI-3.0.patch
--- old-haskell-wai-app-file-cgi/patches/0001-WAI-3.0.patch 1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-wai-app-file-cgi/patches/0001-WAI-3.0.patch 2014-06-15 12:36:39.543606299 +0000
@@ -0,0 +1,183 @@
+From 458d3a8df5409e94612519739003e08304864482 Mon Sep 17 00:00:00 2001
+From: Michael Snoyman <michael at snoyman.com>
+Date: Sun, 15 Jun 2014 09:14:17 +0300
+Subject: [PATCH 1/3] WAI 3.0
+
+---
+ Network/Wai/Application/Classic/CGI.hs | 21 +++++++++++----------
+ Network/Wai/Application/Classic/File.hs | 6 +++---
+ Network/Wai/Application/Classic/Redirect.hs | 7 +++----
+ Network/Wai/Application/Classic/RevProxy.hs | 13 +++++++------
+ wai-app-file-cgi.cabal | 3 ++-
+ 5 files changed, 26 insertions(+), 24 deletions(-)
+
+--- a/Network/Wai/Application/Classic/CGI.hs
++++ b/Network/Wai/Application/Classic/CGI.hs
+@@ -5,8 +5,8 @@ module Network.Wai.Application.Classic.C
+ ) where
+
+ import Blaze.ByteString.Builder (Builder)
+-import qualified Control.Exception as E (SomeException, IOException, try, catch)
+-import Control.Monad (when)
++import qualified Control.Exception as E (SomeException, IOException, try, catch, bracket)
++import Control.Monad (when, (<=<))
+ import Data.ByteString (ByteString)
+ import qualified Data.ByteString.Char8 as BS (readInt, unpack, tail)
+ import Data.Conduit
+@@ -15,6 +15,7 @@ import qualified Data.Conduit.List as CL
+ import Network.HTTP.Types
+ import Network.SockAddr
+ import Network.Wai
++import Network.Wai.Conduit
+ import Network.Wai.Application.Classic.Conduit
+ import Network.Wai.Application.Classic.Field
+ import Network.Wai.Application.Classic.Header
+@@ -41,15 +42,15 @@ The program to link this library must ig
+ > installHandler sigCHLD Ignore Nothing
+ -}
+ cgiApp :: ClassicAppSpec -> CgiAppSpec -> CgiRoute -> Application
+-cgiApp cspec spec cgii req = case method of
+- Right GET -> cgiApp' False cspec spec cgii req
+- Right POST -> cgiApp' True cspec spec cgii req
+- _ -> return $ responseLBS methodNotAllowed405 textPlainHeader "Method Not Allowed\r\n" -- xxx
++cgiApp cspec spec cgii req respond = case method of
++ Right GET -> cgiApp' False cspec spec cgii req respond
++ Right POST -> cgiApp' True cspec spec cgii req respond
++ _ -> respond $ responseLBS methodNotAllowed405 textPlainHeader "Method Not Allowed\r\n" -- xxx
+ where
+ method = parseMethod $ requestMethod req
+
+ cgiApp' :: Bool -> ClassicAppSpec -> CgiAppSpec -> CgiRoute -> Application
+-cgiApp' body cspec spec cgii req = responseSourceBracket setup teardown cgi
++cgiApp' body cspec spec cgii req respond = E.bracket setup teardown (respond <=< cgi)
+ where
+ setup = execProcess cspec spec cgii req
+ teardown (rhdl,whdl,pid) = do
+@@ -66,9 +67,9 @@ cgiApp' body cspec spec cgii req = respo
+ type TRYPATH = Either E.IOException String
+
+ toCGI :: Handle -> Request -> IO ()
+-toCGI whdl req = requestBody req $$ CB.sinkHandle whdl
++toCGI whdl req = sourceRequestBody req $$ CB.sinkHandle whdl
+
+-fromCGI :: Handle -> ClassicAppSpec -> Request -> IO (Status, RequestHeaders, Source IO (Flush Builder))
++fromCGI :: Handle -> ClassicAppSpec -> Request -> IO Response
+ fromCGI rhdl cspec req = do
+ (src', hs) <- cgiHeader `E.catch` recover
+ let (st, hdr, hasBody) = case check hs of
+@@ -78,7 +79,7 @@ fromCGI rhdl cspec req = do
+ logger cspec req st Nothing
+ let src | hasBody = src'
+ | otherwise = CL.sourceNull
+- return (st, hdr', src)
++ return $ responseSource st hdr' src
+ where
+ check hs = lookup hContentType hs >> case lookup hStatus hs of
+ Nothing -> Just (ok200, hs)
+--- a/Network/Wai/Application/Classic/File.hs
++++ b/Network/Wai/Application/Classic/File.hs
+@@ -57,7 +57,7 @@ If-Modified-Since:, Range:, If-Range:, I
+ -}
+
+ fileApp :: ClassicAppSpec -> FileAppSpec -> FileRoute -> Application
+-fileApp cspec spec filei req = do
++fileApp cspec spec filei req respond = do
+ RspSpec st body <- case method of
+ Right GET -> processGET hinfo ishtml rfile
+ Right HEAD -> processHEAD hinfo ishtml rfile
+@@ -67,8 +67,8 @@ fileApp cspec spec filei req = do
+ BodyStatus -> bodyStatus st
+ BodyFileNoBody hdr -> bodyFileNoBody st hdr
+ BodyFile hdr afile rng -> bodyFile st hdr afile rng
+- liftIO $ logger cspec req st mlen
+- return response
++ logger cspec req st mlen
++ respond response
+ where
+ reqidx = indexRequestHeader (requestHeaders req)
+ hinfo = HandlerInfo spec req reqidx file langs
+--- a/Network/Wai/Application/Classic/Redirect.hs
++++ b/Network/Wai/Application/Classic/Redirect.hs
+@@ -4,7 +4,6 @@ module Network.Wai.Application.Classic.R
+ redirectApp
+ ) where
+
+-import Control.Monad.IO.Class (liftIO)
+ import Data.ByteString.Char8
+ import Network.HTTP.Types
+ import Network.Wai
+@@ -13,9 +12,9 @@ import Network.Wai.Application.Classic.P
+ import Network.Wai.Application.Classic.Types
+
+ redirectApp :: ClassicAppSpec -> RedirectRoute -> Application
+-redirectApp cspec route req = do
+- liftIO $ logger cspec req status Nothing
+- return $ responseLBS status hdr ""
++redirectApp cspec route req respond = do
++ logger cspec req status Nothing
++ respond $ responseLBS status hdr ""
+ where
+ path = fromByteString $ rawPathInfo req
+ src = redirectSrc route
+--- a/Network/Wai/Application/Classic/RevProxy.hs
++++ b/Network/Wai/Application/Classic/RevProxy.hs
+@@ -4,6 +4,7 @@ module Network.Wai.Application.Classic.R
+
+ import Blaze.ByteString.Builder (Builder)
+ import Control.Applicative
++import Control.Exception (bracket)
+ import Control.Monad
+ import Control.Monad.IO.Class (liftIO)
+ import Data.ByteString (ByteString)
+@@ -14,7 +15,7 @@ import Data.Default.Class
+ import qualified Network.HTTP.Client as H
+ import qualified Network.HTTP.Conduit as H
+ import Network.HTTP.Types
+-import Network.Wai
++import Network.Wai.Conduit
+ import Network.Wai.Application.Classic.Conduit
+ import Network.Wai.Application.Classic.EventSource
+ import Network.Wai.Application.Classic.Field
+@@ -27,7 +28,7 @@ import Network.Wai.Application.Classic.T
+ -- | Relaying any requests as reverse proxy.
+
+ revProxyApp :: ClassicAppSpec -> RevProxyAppSpec -> RevProxyRoute -> Application
+-revProxyApp cspec spec route req = responseSourceBracket setup teardown proxy
++revProxyApp cspec spec route req respond = bracket setup teardown proxy
+ where
+ setup = H.responseOpen httpClientRequest mgr
+ teardown = H.responseClose
+@@ -38,7 +39,7 @@ revProxyApp cspec spec route req = respo
+ ct = lookup hContentType hdr
+ src = toSource ct clientBody
+ logger cspec req status (fromIntegral <$> mlen)
+- return (status, hdr, src)
++ respond $ responseSource status hdr src
+
+ httpClientRequest = reqToHReq req route
+ mgr = revProxyManager spec
+@@ -86,9 +87,9 @@ reqToHReq req route = def {
+ Just (63, q') -> q' -- '?' is 63
+ _ -> q
+
+-bodyToHBody :: RequestBodyLength -> Source IO ByteString -> H.RequestBody
+-bodyToHBody ChunkedBody src = H.requestBodySourceChunkedIO src
+-bodyToHBody (KnownLength len) src = H.requestBodySourceIO (fromIntegral len) src
++bodyToHBody :: RequestBodyLength -> IO ByteString -> H.RequestBody
++bodyToHBody ChunkedBody src = H.RequestBodyStreamChunked ($ src)
++bodyToHBody (KnownLength len) src = H.RequestBodyStream (fromIntegral len) ($ src)
+
+ ----------------------------------------------------------------
+
+--- a/wai-app-file-cgi.cabal
++++ b/wai-app-file-cgi.cabal
+@@ -60,7 +60,8 @@ Library
+ , text
+ , transformers
+ , unix
+- , wai >= 2.0
++ , wai >= 3.0 && < 3.1
++ , wai-conduit
+ , word8
+
+ Test-Suite doctest
diff -rN -u old-haskell-wai-app-file-cgi/patches/series new-haskell-wai-app-file-cgi/patches/series
--- old-haskell-wai-app-file-cgi/patches/series 2014-06-15 12:36:39.539606300 +0000
+++ new-haskell-wai-app-file-cgi/patches/series 2014-06-15 12:36:39.543606299 +0000
@@ -1 +1,2 @@
no-attoparsec-conduit.diff
+0001-WAI-3.0.patch
More information about the Pkg-haskell-commits
mailing list