http-reverse-proxy 0.6.0.3 → 0.6.1.0
raw patch · 3 files changed
+18/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Network.HTTP.ReverseProxy: wpsModifyResponseHeaders :: WaiProxySettings -> Request -> Response () -> ResponseHeaders -> ResponseHeaders
Files
- ChangeLog.md +4/−0
- Network/HTTP/ReverseProxy.hs +13/−3
- http-reverse-proxy.cabal +1/−1
ChangeLog.md view
@@ -1,4 +1,8 @@ +## 0.6.1.0++* Add the `wpsModifyResponseHeaders` option to `WaiProxySettings` to tweak response headers before they are returned upstream. [#48](https://github.com/fpco/http-reverse-proxy/pull/48)+ ## 0.6.0.3 * Fix a regression introduced in 0.6.0.2: wrong 'Content-Length' header is preserved for responses with encoded content. [#47](https://github.com/fpco/http-reverse-proxy/pull/47)
Network/HTTP/ReverseProxy.hs view
@@ -27,6 +27,7 @@ , wpsUpgradeToRaw , wpsGetDest , wpsLogRequest+ , wpsModifyResponseHeaders , SetIpHeader (..) -- *** Local settings , LocalWaiProxySettings@@ -272,6 +273,13 @@ -- Default: no op -- -- @since 0.6.0.1+ , wpsModifyResponseHeaders :: WAI.Request -> HC.Response () -> HT.ResponseHeaders -> HT.ResponseHeaders+ -- ^ Allow to override the response headers before the response is returned upstream. Useful for example+ -- to override overly-strict 'Content-Security-Policy' when the source is known to be trustworthy.+ --+ -- Default: no op+ --+ -- @since 0.6.1.0 } -- | How to set the X-Real-IP request header.@@ -294,6 +302,7 @@ (CI.mk <$> lookup "upgrade" (WAI.requestHeaders req)) == Just "websocket" , wpsGetDest = Nothing , wpsLogRequest = const (pure ())+ , wpsModifyResponseHeaders = \_ _ -> id } renderHeaders :: WAI.Request -> HT.RequestHeaders -> Builder@@ -422,9 +431,10 @@ $ \case Left e -> wpsOnExc wps e req sendResponse Right res -> do- let conduit = fromMaybe+ let res' = const () <$> res+ conduit = fromMaybe (awaitForever (\bs -> yield (Chunk $ fromByteString bs) >> yield Flush))- (wpsProcessBody wps req $ const () <$> res)+ (wpsProcessBody wps req res') src = bodyReaderSource $ HC.responseBody res headers = HC.responseHeaders res notEncoded = isNothing (lookup "content-encoding" headers)@@ -433,7 +443,7 @@ (HC.responseStatus res) (filter (\(key, v) -> not (key `Set.member` strippedHeaders) || key == "content-length" && (notEncoded && notChunked || v == "0"))- headers)+ (wpsModifyResponseHeaders wps req res' headers)) (\sendChunk flush -> runConduit $ src .| conduit .| CL.mapM_ (\mb -> case mb of Flush -> flush
http-reverse-proxy.cabal view
@@ -1,5 +1,5 @@ name: http-reverse-proxy-version: 0.6.0.3+version: 0.6.1.0 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