on master help sign in
Add 'headerRedacted'
commitd0535073e8c2d84c39705632dafd81cf3ac98e97 authorIvo Stefchev <ivakaetuk@gmail.com> dateSat 6 Aug 2022, 15:35 (4 years ago) parent95f6a21
3 files changed+17−1
CHANGELOG.md+5 Network/HTTP/Req.hs+10 req.cabal+2−1
CHANGELOG.md+5
@@ -1,3 +1,8 @@
1+## Req 3.13.0
2+
3+* Add `headerRedacted` function to add header fields, which will be with
4+ redacted values on print.
5+
16## Req 3.12.0
27
38* Add `isStatusCodeException` function.
Network/HTTP/Req.hs+10
@@ -161,6 +161,7 @@ module Network.HTTP.Req
161161 -- *** Headers
162162 header,
163163 attachHeader,
164+ headerRedacted,
164165
165166 -- *** Cookies
166167 -- $cookies
@@ -255,6 +256,7 @@ import qualified Data.List.NonEmpty as NE
255256import Data.Maybe (fromMaybe)
256257import Data.Proxy
257258import Data.Semigroup (Endo (..))
259+import qualified Data.Set as S
258260import Data.Text (Text)
259261import qualified Data.Text as T
260262import qualified Data.Text.Encoding as T
@@ -1561,6 +1563,14 @@ attachHeader :: ByteString -> ByteString -> L.Request -> L.Request
15611563attachHeader name value x =
15621564 x {L.requestHeaders = (CI.mk name, value) : L.requestHeaders x}
15631565
1566+-- | Same as 'header', but with redacted values on print.
1567+--
1568+-- @since 3.13.0
1569+headerRedacted :: ByteString -> ByteString -> Option scheme
1570+headerRedacted name value = withRequest $ \x ->
1571+ let y = attachHeader name value x
1572+ in y {L.redactHeaders = CI.mk name `S.insert` L.redactHeaders y}
1573+
15641574----------------------------------------------------------------------------
15651575-- Request—Optional parameters—Cookies
15661576
req.cabal+2−1
@@ -40,9 +40,10 @@ library
4040 bytestring >=0.10.8 && <0.12,
4141 case-insensitive >=0.2 && <1.3,
4242 connection >=0.2.2 && <0.4,
43+ containers >=0.5 && <0.7,
4344 exceptions >=0.6 && <0.11,
4445 http-api-data >=0.2 && <0.6,
45− http-client >=0.7 && <0.8,
46+ http-client >=0.7.13.1 && <0.8,
4647 http-client-tls >=0.3.2 && <0.4,
4748 http-types >=0.8 && <10.0,
4849 modern-uri >=0.3 && <0.4,