https-everywhere-rules/src/Data/HTTPSEverywhere/Rules.hs

22 lines
777 B
Haskell
Raw Normal View History

module Data.HTTPSEverywhere.Rules (
rewriteURL,
rewriteCookie
) where
2014-08-24 06:40:06 +02:00
import Prelude hiding (null, head)
import Control.Lens ((<&>),(&))
2014-08-10 01:16:57 +02:00
import Data.Bool (bool)
import Network.HTTP.Client (Cookie)
import Network.URI (URI)
2014-08-24 06:40:06 +02:00
import Pipes ((>->))
import Pipes.Prelude (head, null)
import Control.Monad (join)
2014-08-10 01:16:57 +02:00
import Data.HTTPSEverywhere.Rules.Internal (getRulesetsMatching, havingRulesThatTrigger, havingCookieRulesThatTrigger, setSecureFlag)
rewriteURL :: URI -> IO (Maybe URI)
2014-08-24 06:40:06 +02:00
rewriteURL url = getRulesetsMatching url >-> havingRulesThatTrigger url & head <&> join
rewriteCookie :: URI -> Cookie -> IO Cookie
2014-08-10 01:16:57 +02:00
rewriteCookie url cookie = null producer <&> setSecureFlag cookie `bool` cookie
2014-08-24 06:40:06 +02:00
where producer = getRulesetsMatching url >-> havingCookieRulesThatTrigger cookie