http-reverse-proxy 0.1.0.3 → 0.1.0.4
raw patch · 3 files changed
+25/−3 lines, 3 filesdep +transformersdep ~blaze-builderdep ~conduitdep ~lifted-basePVP ok
version bump matches the API change (PVP)
Dependencies added: transformers
Dependency ranges changed: blaze-builder, conduit, lifted-base
API changes (from Hackage documentation)
Files
- Network/HTTP/ReverseProxy.hs +1/−1
- http-reverse-proxy.cabal +5/−1
- test/main.hs +19/−1
Network/HTTP/ReverseProxy.hs view
@@ -135,7 +135,7 @@ return $ WAI.ResponseSource (HC.responseStatus res) (filter (\(key, _) -> not $ key `member` strippedHeaders) $ HC.responseHeaders res)- (mapOutput (Chunk . fromByteString) src)+ (src =$= awaitForever (\bs -> yield (Chunk $ fromByteString bs) >> yield Flush)) 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.1.0.3+version: 0.1.0.4 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@@ -43,6 +43,10 @@ , hspec >= 1.3 , warp >= 1.3 , bytestring+ , conduit+ , blaze-builder+ , transformers+ , lifted-base source-repository head type: git
test/main.hs view
@@ -1,14 +1,19 @@ {-# LANGUAGE OverloadedStrings #-} import Control.Concurrent (forkIO, threadDelay) import qualified Data.ByteString.Lazy.Char8 as L8+import Data.Conduit (yield, Flush (..), ($$+-), await, runResourceT) import Data.Conduit.Network (serverSettings, runTCPServer) import qualified Network.HTTP.Conduit as HC import Network.HTTP.ReverseProxy (ProxyDest (..), defaultOnExc, rawProxyTo, waiProxyTo, waiToRaw) import Network.HTTP.Types (status200)-import Network.Wai (responseLBS, Response (ResponseFile))+import Network.Wai (responseLBS, Response (ResponseFile, ResponseSource)) import Network.Wai.Handler.Warp (run) import Test.Hspec (describe, hspec, it, shouldBe)+import Blaze.ByteString.Builder (fromByteString)+import Control.Monad (forever)+import Control.Monad.IO.Class (liftIO)+import System.Timeout.Lifted (timeout) main :: IO () main = hspec $ do@@ -22,6 +27,19 @@ threadDelay 100000 lbs <- HC.simpleHttp "http://localhost:5002" lbs `shouldBe` content+ it "deals with streaming data" $ do+ manager <- HC.newManager HC.def+ forkIO $ run 5003 $ const $ return $ ResponseSource status200 [] $ forever $ do+ yield $ Chunk $ fromByteString "hello"+ yield Flush+ liftIO $ threadDelay 10000000+ forkIO $ run 5004 $ waiProxyTo (const $ return $ Right $ ProxyDest "localhost" 5003) defaultOnExc manager+ threadDelay 100000+ req <- HC.parseUrl "http://localhost:5004"+ mbs <- runResourceT $ timeout 1000000 $ do+ res <- HC.http req manager+ HC.responseBody res $$+- await+ mbs `shouldBe` Just (Just "hello") describe "waiToRaw" $ do it "works" $ do let content = "waiToRaw"