packages feed

http-reverse-proxy 0.2.1 → 0.2.1.1

raw patch · 2 files changed

+16/−14 lines, 2 filesdep +basic-preludedep +containersdep −classy-preludePVP ok

version bump matches the API change (PVP)

Dependencies added: basic-prelude, containers

Dependencies removed: classy-prelude

API changes (from Hackage documentation)

Files

Network/HTTP/ReverseProxy.hs view
@@ -22,18 +22,20 @@     , waiToRaw     ) where -import ClassyPrelude+import BasicPrelude import Data.Conduit import qualified Network.Wai as WAI import qualified Network.HTTP.Conduit as HC import Control.Exception.Lifted (try, finally) import Blaze.ByteString.Builder (fromByteString, flush) import Data.Word8 (isSpace, _colon, toLower, _cr)+import qualified Data.ByteString as S import qualified Data.ByteString.Char8 as S8 import qualified Network.HTTP.Types as HT import qualified Data.CaseInsensitive as CI import qualified Data.Text.Encoding as TE import qualified Data.Text.Lazy.Encoding as TLE+import qualified Data.Text.Lazy as TL import qualified Data.Conduit.Network as DCN import Control.Concurrent.MVar.Lifted (newEmptyMVar, putMVar, takeMVar) import Control.Concurrent.Lifted (fork, killThread)@@ -47,6 +49,7 @@ import qualified Paths_http_reverse_proxy import Network.Wai.Logger.Utils (showSockAddr) import Blaze.ByteString.Builder (Builder)+import qualified Data.Set as Set  -- | Host\/port combination to which we want to proxy. data ProxyDest = ProxyDest@@ -103,7 +106,7 @@ defaultOnExc exc _ = return $ WAI.responseLBS     HT.status502     [("content-type", "text/plain")]-    ("Error connecting to gateway:\n\n" ++ TLE.encodeUtf8 (show exc))+    ("Error connecting to gateway:\n\n" ++ TLE.encodeUtf8 (TL.fromStrict $ show exc))  -- | The different responses that could be generated by a @waiProxyTo@ lookup -- function.@@ -196,7 +199,7 @@                     , HC.port = port                     , HC.path = WAI.rawPathInfo req                     , HC.queryString = WAI.rawQueryString req-                    , HC.requestHeaders = filter (\(key, _) -> not $ key `member` strippedHeaders) $+                    , HC.requestHeaders = filter (\(key, _) -> not $ key `Set.member` strippedHeaders) $                         (case wpsSetIpHeader wps of                             SIHFromSocket -> (("X-Real-IP", S8.pack $ showSockAddr $ WAI.remoteHost req):)                             SIHFromHeader ->@@ -238,13 +241,11 @@                                 Just conduit -> conduit                     return $ WAI.ResponseSource                         (HC.responseStatus res)-                        (filter (\(key, _) -> not $ key `member` strippedHeaders) $ HC.responseHeaders res) $ do+                        (filter (\(key, _) -> not $ key `Set.member` strippedHeaders) $ HC.responseHeaders res) $ do                         yield Flush                         src =$= conduit   where-    strippedHeaders = asSet $ fromList ["content-length", "transfer-encoding", "accept-encoding", "content-encoding"]-    asSet :: Set a -> Set a-    asSet = id+    strippedHeaders = Set.fromList ["content-length", "transfer-encoding", "accept-encoding", "content-encoding"]  -- | Get the HTTP headers for the first request on the stream, returning on -- consumed bytes as leftovers. Has built-in limits on how many bytes it will@@ -263,16 +264,16 @@         push bs'             | "\r\n\r\n" `S8.isInfixOf` bs               || "\n\n" `S8.isInfixOf` bs-              || length bs > 4096 = leftover bs >> return bs-            | otherwise = go $ append bs+              || S8.length bs > 4096 = leftover bs >> return bs+            | otherwise = go $ mappend bs           where             bs = front bs'-    toHeaders = map toHeader . takeWhile (not . null) . drop 1 . S8.lines+    toHeaders = map toHeader . takeWhile (not . S8.null) . drop 1 . S8.lines     toHeader bs =         (CI.mk key, val)       where-        (key, bs') = break (== _colon) bs-        val = takeWhile (/= _cr) $ dropWhile isSpace $ drop 1 bs'+        (key, bs') = S.break (== _colon) bs+        val = S.takeWhile (/= _cr) $ S.dropWhile isSpace $ S.drop 1 bs'  -- | Convert a WAI application into a raw application, using Warp. waiToRaw :: WAI.Application -> DCN.Application IO
http-reverse-proxy.cabal view
@@ -1,5 +1,5 @@ name:                http-reverse-proxy-version:             0.2.1+version:             0.2.1.1 synopsis:            Reverse proxy HTTP requests, either over raw sockets or with WAI description:         Provides a simple means of reverse-proxying HTTP requests. The raw approach uses the same technique as leveraged by keter, whereas the WAI approach performs full request/response parsing via WAI and http-conduit. homepage:            https://github.com/fpco/http-reverse-proxy@@ -26,12 +26,13 @@                      , blaze-builder          >= 0.3                      , http-conduit           >= 1.6                      , wai                    >= 1.3-                     , classy-prelude         >= 0.3+                     , basic-prelude          >= 0.3.5                      , network                      , conduit                >= 0.5                      , warp                   >= 1.3.4                      , data-default                      , wai-logger+                     , containers  test-suite test     type: exitcode-stdio-1.0