conduit 1.1

This commit is contained in:
Michael Snoyman 2014-04-03 10:39:26 +03:00
parent d27500194b
commit 9e2e05fd95
2 changed files with 13 additions and 32 deletions

View File

@ -25,6 +25,7 @@ import qualified Data.Text as T
import Data.Text (Text)
import Data.Text.Encoding (encodeUtf8, decodeUtf8)
import qualified Data.CaseInsensitive as CI
import Control.Monad.Trans.Reader (runReaderT)
import Blaze.ByteString.Builder (fromByteString)
@ -41,9 +42,7 @@ import Data.Char (isDigit)
import Data.Conduit
import qualified Network.Wai as Wai
import Network.HTTP.Conduit
import Network.HTTP.Client (responseOpen, responseClose)
import Network.HTTP.Client.Internal (brRead)
import Network.HTTP.Client.Conduit
import Network.HTTP.Types
data RPEntry = RPEntry
@ -126,8 +125,8 @@ mkRequest rpConfig request =
, requestHeaders = filterHeaders $ rewriteHeaders reqRuleMap (Wai.requestHeaders request)
, requestBody =
case Wai.requestBodyLength request of
Wai.ChunkedBody -> requestBodySourceChunkedIO (Wai.requestBody request)
Wai.KnownLength n -> requestBodySourceIO (fromIntegral n) (Wai.requestBody request)
Wai.ChunkedBody -> requestBodySourceChunked (Wai.requestBody request)
Wai.KnownLength n -> requestBodySource (fromIntegral n) (Wai.requestBody request)
, decompress = const False
, redirectCount = 0
, checkStatus = \_ _ _ -> Nothing
@ -139,34 +138,16 @@ mkRequest rpConfig request =
simpleReverseProxy :: Manager -> ReverseProxyConfig -> Wai.Application
simpleReverseProxy mgr rpConfig request = Wai.responseSourceBracket
(responseOpen proxiedRequest mgr)
(runReaderT (responseOpen proxiedRequest) mgr)
responseClose
$ \res -> return
( responseStatus res
, rewriteHeaders respRuleMap $ responseHeaders res
, bodyReaderSource $ responseBody res
, mapOutput (Chunk . fromByteString) (responseBody res)
)
{-
do
response <- http proxiedRequest mgr
(body, _) <- unwrapResumable $ responseBody response
return $
Wai.ResponseSource
(responseStatus response)
(rewriteHeaders respRuleMap $ responseHeaders response)
(mapOutput (Chunk . fromByteString) body)
-}
where
proxiedRequest = mkRequest rpConfig request
respRuleMap = mkRuleMap $ rewriteResponseRules rpConfig
bodyReaderSource br =
loop
where
loop = do
bs <- liftIO $ brRead br
unless (S.null bs) $ do
yield $ Chunk $ fromByteString bs
loop
data ReverseProxyConfig = ReverseProxyConfig
{ reversedHost :: Text

View File

@ -1,11 +1,13 @@
Name: keter
Version: 1.2.1
Version: 1.3.0
Synopsis: Web application deployment manager, focusing on Haskell web frameworks
Description:
Handles deployment of web apps, providing a reverse proxy to achieve zero downtime deployments. For more information, please see the README on Github: <https://github.com/snoyberg/keter#readme>
.
Release history:
.
[1.3.0] Upgrade to conduit 1.1
.
[1.0.1] Permit use of wildcard subdomains and exceptions to wildcards. Convert internal strings to use Data.Text in more places. (Although internationalized domain names are not supported unless entered in punycode in configuration files.)
.
[1.0.0] Significant overhaul. We now support monitoring of much more arbitrary jobs (e.g., background tasks), have a proper plugin system (PostgreSQL is no longer a required component), and have a much better system for tracking hostname mapping changes.
@ -48,9 +50,9 @@ Library
, fsnotify >= 0.0.11
, system-filepath >= 0.4 && < 0.5
, system-fileio >= 0.3 && < 0.4
, conduit >= 0.5
, network-conduit >= 0.6
, network-conduit-tls >= 1.0.0.2
, conduit >= 1.1
, conduit-extra >= 1.1
, network-conduit-tls >= 1.1
, http-reverse-proxy >= 0.3.1 && < 0.4
, unix >= 2.5
, wai-app-static >= 2.0 && < 2.1
@ -58,9 +60,7 @@ Library
, http-types
, regex-tdfa >= 1.1
, attoparsec >= 0.10
, http-conduit >= 2.0
, http-client
, http-client-conduit
, http-conduit >= 2.1
, case-insensitive
, array
, mtl