Safe Haskell | None |
---|---|
Language | Haskell2010 |
Restricted ManagerSettings
for https://haskell-lang.org/library/http-client
-
- Portions from http-client-tls Copyright (c) 2013 Michael Snoyman
- Portions from http-client-restricted Copyright 2018 Joey Hess id@joeyh.name
-
- License: MIT
Synopsis
- data Decision
- type Restriction = AddrInfo -> Decision
- data ConnectionRestricted = ConnectionRestricted {
- crHostName :: String
- crAddress :: AddrInfo
- restrictManagerSettings :: Maybe ConnectionContext -> Maybe TLSSettings -> Restriction -> ManagerSettings -> ManagerSettings
- mkRestrictedManagerSettings :: Restriction -> Maybe ConnectionContext -> Maybe TLSSettings -> ManagerSettings
- wrapOurExceptions :: ManagerSettings -> Request -> IO a -> IO a
- restrictedRawConnection :: Restriction -> IO (Maybe HostAddress -> String -> Int -> IO Connection)
- restrictedTlsConnection :: Maybe ConnectionContext -> Maybe TLSSettings -> Restriction -> IO (Maybe HostAddress -> String -> Int -> IO Connection)
- getConnection :: Restriction -> Maybe TLSSettings -> Maybe ConnectionContext -> IO (Maybe HostAddress -> String -> Int -> IO Connection)
- convertConnection :: Connection -> IO Connection
Documentation
type Restriction = AddrInfo -> Decision Source #
data ConnectionRestricted Source #
Blocked requests raise this exception, wrapped as InternalException
.
ConnectionRestricted | |
|
Instances
Show ConnectionRestricted Source # | |
Defined in Network.HTTP.Client.Restricted showsPrec :: Int -> ConnectionRestricted -> ShowS # show :: ConnectionRestricted -> String # showList :: [ConnectionRestricted] -> ShowS # | |
Exception ConnectionRestricted Source # | |
restrictManagerSettings :: Maybe ConnectionContext -> Maybe TLSSettings -> Restriction -> ManagerSettings -> ManagerSettings Source #
Adjusts a ManagerSettings to enforce a Restriction. The restriction will be checked each time a Request is made, and for each redirect followed.
This overrides the managerRawConnection
and managerTlsConnection
with its own implementations that check
the Restriction. They should otherwise behave the same as the
ones provided by http-client-tls.
This function is not exported, because using it with a ManagerSettings produced by something other than http-client-tls would result in surprising behavior, since its connection methods would not be used.
mkRestrictedManagerSettings :: Restriction -> Maybe ConnectionContext -> Maybe TLSSettings -> ManagerSettings Source #
Makes a TLS-capable ManagerSettings with a Restriction applied to it.
The Restriction will be checked each time a Request is made, and for each redirect followed.
Aside from checking the Restriction, it should behave the same as
mkManagerSettingsContext
from http-client-tls.
main = do manager <- newManager $ mkRestrictedManagerSettings myRestriction Nothing Nothing request <- parseRequest "http://httpbin.org/get" response <- httpLbs request manager print $ responseBody response
See mkManagerSettingsContext
for why
it can be useful to provide a ConnectionContext
.
Note that SOCKS is not supported.
wrapOurExceptions :: ManagerSettings -> Request -> IO a -> IO a Source #
restrictedRawConnection :: Restriction -> IO (Maybe HostAddress -> String -> Int -> IO Connection) Source #
restrictedTlsConnection :: Maybe ConnectionContext -> Maybe TLSSettings -> Restriction -> IO (Maybe HostAddress -> String -> Int -> IO Connection) Source #
getConnection :: Restriction -> Maybe TLSSettings -> Maybe ConnectionContext -> IO (Maybe HostAddress -> String -> Int -> IO Connection) Source #
convertConnection :: Connection -> IO Connection Source #