http-reverse-proxy 0.6.0.1 → 0.6.0.2
raw patch · 4 files changed
+45/−5 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−2
- Network/HTTP/ReverseProxy.hs +5/−2
- README.md +35/−0
- http-reverse-proxy.cabal +1/−1
ChangeLog.md view
@@ -1,11 +1,13 @@+ ## 0.6.0.2 -* Add `wpsLogRequest` function which provides the ability to log the- constructed `Request`.+* Fix docker registry reverse proxying by preserving the 'Content-Length' response header to HTTP/2 and HEAD requests. [#45](https://github.com/fpco/http-reverse-proxy/pull/45) ## 0.6.0.1 * Introduce a "semi cached body" to let the beginning of a request body be retried [#34](https://github.com/fpco/http-reverse-proxy/issues/34)+* Add `wpsLogRequest` function which provides the ability to log the+ constructed `Request`. ## 0.6.0
Network/HTTP/ReverseProxy.hs view
@@ -271,7 +271,7 @@ -- -- Default: no op --- -- @since 0.6.0.2+ -- @since 0.6.0.1 } -- | How to set the X-Real-IP request header.@@ -426,9 +426,12 @@ (awaitForever (\bs -> yield (Chunk $ fromByteString bs) >> yield Flush)) (wpsProcessBody wps req $ const () <$> res) src = bodyReaderSource $ HC.responseBody res+ noChunked = HT.httpMajor (WAI.httpVersion req) >= 2 || WAI.requestMethod req == HT.methodHead sendResponse $ WAI.responseStream (HC.responseStatus res)- (filter (\(key, _) -> not $ key `Set.member` strippedHeaders) $ HC.responseHeaders res)+ (filter (\(key, v) -> not (key `Set.member` strippedHeaders) ||+ key == "content-length" && (noChunked || v == "0"))+ (HC.responseHeaders res)) (\sendChunk flush -> runConduit $ src .| conduit .| CL.mapM_ (\mb -> case mb of Flush -> flush
README.md view
@@ -21,3 +21,38 @@ (\_headers -> return $ Right $ ProxyDest "www.example.com" 80) appData ```++## HTTPS example to proxy bing.com++The following example sets up reverse proxying froming to www.bing.com+from localhost port 3000:++``` haskell+import Network.HTTP.Client.TLS+import Network.HTTP.ReverseProxy+import Network.Wai+import Network.Wai.Handler.Warp (run)++main :: IO ()+main = bingExample >>= run 3000++bingExample :: IO Application+bingExample = do+ manager <- newTlsManager+ pure $+ waiProxyToSettings+ ( \request ->+ return $+ WPRModifiedRequestSecure+ ( request+ { requestHeaders = [("Host", "www.bing.com")]+ }+ )+ (ProxyDest "www.bing.com" 443)+ )+ defaultWaiProxySettings {wpsLogRequest = print}+ manager+```++After running it, you can visit [http://localhost:3000](http://localhost:3000) to visit+the search engine's page.
http-reverse-proxy.cabal view
@@ -1,5 +1,5 @@ name: http-reverse-proxy-version: 0.6.0.1+version: 0.6.0.2 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