packages feed

http-reverse-proxy 0.1.1.4 → 0.1.1.5

raw patch · 3 files changed

+44/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Network/HTTP/ReverseProxy.hs view
@@ -146,7 +146,7 @@                     , HC.path = WAI.rawPathInfo req                     , HC.queryString = WAI.rawQueryString req                     , HC.requestHeaders = filter (\(key, _) -> not $ key `member` strippedHeaders) $ WAI.requestHeaders req-                    , HC.requestBody = HC.RequestBodySourceChunked $ mapOutput fromByteString $ WAI.requestBody req+                    , HC.requestBody = body                     , HC.redirectCount = 0 #if MIN_VERSION_http_conduit(1, 9, 0)                     , HC.checkStatus = \_ _ _ -> Nothing@@ -155,6 +155,18 @@ #endif                     , HC.responseTimeout = wpsTimeout wps                     }+                bodySrc = mapOutput fromByteString $ WAI.requestBody req+                bodyChunked = HC.RequestBodySourceChunked bodySrc+#if MIN_VERSION_wai(1, 4, 0)+                body =+                    case WAI.requestBodyLength req of+                        WAI.KnownLength i -> HC.RequestBodySource+                            (fromIntegral i)+                            bodySrc+                        WAI.ChunkedBody -> bodyChunked+#else+                body = bodyChunked+#endif             ex <- try $ HC.http req' manager             case ex of                 Left e -> wpsOnExc wps e req@@ -162,8 +174,9 @@                     (src, _) <- unwrapResumable $ HC.responseBody res                     return $ WAI.ResponseSource                         (HC.responseStatus res)-                        (filter (\(key, _) -> not $ key `member` strippedHeaders) $ HC.responseHeaders res)-                        (src =$= awaitForever (\bs -> yield (Chunk $ fromByteString bs) >> yield Flush))+                        (filter (\(key, _) -> not $ key `member` strippedHeaders) $ HC.responseHeaders res) $ do+                        yield Flush+                        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.1.4+version:             0.1.1.5 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
test/main.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                 #-} {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-} import           Blaze.ByteString.Builder   (fromByteString)@@ -7,6 +8,8 @@                                              try) import           Control.Monad              (forever) import           Control.Monad.IO.Class     (liftIO)+import qualified Data.ByteString            as S+import qualified Data.ByteString.Char8      as S8 import qualified Data.ByteString.Lazy.Char8 as L8 import           Data.Conduit               (Flush (..), await, runResourceT,                                              yield, ($$+-))@@ -95,6 +98,30 @@                         res <- HC.http req manager                         HC.responseBody res $$+- await                     mbs `shouldBe` Just (Just "hello")+#if MIN_VERSION_wai(1, 4, 0)+        it "passes on body length" $+            let app req = return $ responseLBS+                    status200+                    [("uplength", show' $ Network.Wai.requestBodyLength req)]+                    ""+                body = "some body"+                show' Network.Wai.ChunkedBody = "chunked"+                show' (Network.Wai.KnownLength i) = S8.pack $ show i+             in withMan $ \manager ->+                withWApp app $ \port1 ->+                withWApp (waiProxyTo (const $ return $ Right $ ProxyDest "127.0.0.1" port1) defaultOnExc manager) $ \port2 -> do+                    req' <- HC.parseUrl $ "http://127.0.0.1:" ++ show port2+                    let req = req'+                            { HC.requestBody = HC.RequestBodyBS body+                            }+                    mlen <- runResourceT $ do+                        res <- HC.http req manager+                        return $ lookup "uplength" $ HC.responseHeaders res+                    mlen `shouldBe` Just (show'+                                            $ Network.Wai.KnownLength+                                            $ fromIntegral+                                            $ S.length body)+#endif     describe "waiToRaw" $ do         it "works" $ do             let content = "waiToRaw"