http-reverse-proxy 0.2.0 → 0.2.1
raw patch · 2 files changed
+13/−2 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP.ReverseProxy: wpsProcessBody :: WaiProxySettings -> Response () -> Maybe (Conduit ByteString (ResourceT IO) (Flush Builder))
Files
- Network/HTTP/ReverseProxy.hs +12/−1
- http-reverse-proxy.cabal +1/−1
Network/HTTP/ReverseProxy.hs view
@@ -16,6 +16,7 @@ , wpsOnExc , wpsTimeout , wpsSetIpHeader+ , wpsProcessBody , SetIpHeader (..) -- * WAI to Raw , waiToRaw@@ -45,6 +46,7 @@ import Data.Version (showVersion) import qualified Paths_http_reverse_proxy import Network.Wai.Logger.Utils (showSockAddr)+import Blaze.ByteString.Builder (Builder) -- | Host\/port combination to which we want to proxy. data ProxyDest = ProxyDest@@ -157,6 +159,10 @@ -- Default: SIHFromSocket -- -- Since 0.2.0+ , wpsProcessBody :: HC.Response () -> Maybe (Conduit ByteString (ResourceT IO) (Flush Builder))+ -- ^ Post-process the response body returned from the host.+ --+ -- Since 0.2.1 } -- | How to set the X-Real-IP request header.@@ -171,6 +177,7 @@ { wpsOnExc = defaultOnExc , wpsTimeout = Nothing , wpsSetIpHeader = SIHFromSocket+ , wpsProcessBody = const Nothing } waiProxyToSettings getDest wps manager req0 = do@@ -225,11 +232,15 @@ Left e -> wpsOnExc wps e req Right res -> do (src, _) <- unwrapResumable $ HC.responseBody res+ let conduit =+ case wpsProcessBody wps $ fmap (const ()) res of+ Nothing -> awaitForever (\bs -> yield (Chunk $ fromByteString bs) >> yield Flush)+ Just conduit -> conduit return $ WAI.ResponseSource (HC.responseStatus res) (filter (\(key, _) -> not $ key `member` strippedHeaders) $ HC.responseHeaders res) $ do yield Flush- src =$= awaitForever (\bs -> yield (Chunk $ fromByteString bs) >> yield Flush)+ src =$= conduit where strippedHeaders = asSet $ fromList ["content-length", "transfer-encoding", "accept-encoding", "content-encoding"] asSet :: Set a -> Set a
http-reverse-proxy.cabal view
@@ -1,5 +1,5 @@ name: http-reverse-proxy-version: 0.2.0+version: 0.2.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