Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Network.HTTP.Client.Conduit
Description
A new, experimental API to replace Network.HTTP.Conduit.
For most users, Network.HTTP.Simple is probably a better choice. For more information, see:
https://haskell-lang.org/library/http-client
For more information on using this module, please be sure to read the documentation in the Network.HTTP.Client module.
Synopsis
- withResponse :: (MonadUnliftIO m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a
- responseOpen :: (MonadIO m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> m (Response (ConduitM i ByteString n ()))
- responseClose :: MonadIO m => Response body -> m ()
- acquireResponse :: (MonadIO n, MonadReader env m, HasHttpManager env) => Request -> m (Acquire (Response (ConduitM i ByteString n ())))
- httpSource :: (MonadResource m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> (Response (ConduitM () ByteString n ()) -> ConduitM () r m ()) -> ConduitM () r m ()
- defaultManagerSettings :: ManagerSettings
- newManager :: MonadIO m => m Manager
- newManagerSettings :: MonadIO m => ManagerSettings -> m Manager
- data Proxy = Proxy {
- proxyHost :: ByteString
- proxyPort :: Int
- data StreamFileStatus = StreamFileStatus {}
- class HasHttpManager a where
- getHttpManager :: a -> Manager
- data Manager
- data ProxyOverride
- data ManagerSettings
- data Response body
- data ResponseTimeout
- data Request
- type GivesPopper a = NeedsPopper a -> IO a
- type NeedsPopper a = Popper -> IO a
- type Popper = IO ByteString
- data RequestBody
- data CookieJar
- data Cookie = Cookie {}
- data HttpExceptionContent
- = StatusCodeException (Response ()) ByteString
- | TooManyRedirects [Response ByteString]
- | OverlongHeaders
- | ResponseTimeout
- | ConnectionTimeout
- | ConnectionFailure SomeException
- | InvalidStatusLine ByteString
- | InvalidHeader ByteString
- | InvalidRequestHeader ByteString
- | InternalException SomeException
- | ProxyConnectException ByteString Int Status
- | NoResponseDataReceived
- | TlsNotSupported
- | WrongRequestBodyStreamSize Word64 Word64
- | ResponseBodyTooShort Word64 Word64
- | InvalidChunkHeaders
- | IncompleteHeaders
- | InvalidDestinationHost ByteString
- | HttpZlibException ZlibException
- | InvalidProxyEnvironmentVariable Text Text
- | ConnectionClosed
- | InvalidProxySettings Text
- data HttpException
- data HistoriedResponse body
- equalCookie :: Cookie -> Cookie -> Bool
- equivCookie :: Cookie -> Cookie -> Bool
- compareCookies :: Cookie -> Cookie -> Ordering
- equalCookieJar :: CookieJar -> CookieJar -> Bool
- equivCookieJar :: CookieJar -> CookieJar -> Bool
- makeConnection :: IO ByteString -> (ByteString -> IO ()) -> IO () -> IO Connection
- socketConnection :: Socket -> Int -> IO Connection
- strippedHostName :: String -> String
- brReadSome :: BodyReader -> Int -> IO ByteString
- parseUrl :: MonadThrow m => String -> m Request
- parseUrlThrow :: MonadThrow m => String -> m Request
- throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m ()
- parseRequest :: MonadThrow m => String -> m Request
- parseRequest_ :: String -> Request
- requestFromURI :: MonadThrow m => URI -> m Request
- requestFromURI_ :: URI -> Request
- getUri :: Request -> URI
- defaultRequest :: Request
- applyBasicAuth :: ByteString -> ByteString -> Request -> Request
- applyBearerAuth :: ByteString -> Request -> Request
- applyBasicProxyAuth :: ByteString -> ByteString -> Request -> Request
- urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request
- setRequestIgnoreStatus :: Request -> Request
- setRequestCheckStatus :: Request -> Request
- setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request
- setQueryStringPartialEscape :: [(ByteString, [EscapeItem])] -> Request -> Request
- streamFile :: FilePath -> IO RequestBody
- observedStreamFile :: (StreamFileStatus -> IO ()) -> FilePath -> IO RequestBody
- getOriginalRequest :: Response a -> Request
- rawConnectionModifySocket :: (Socket -> IO ()) -> IO (Maybe HostAddress -> String -> Int -> IO Connection)
- rawConnectionModifySocketSize :: (Socket -> IO ()) -> IO (Int -> Maybe HostAddress -> String -> Int -> IO Connection)
- withManager :: ManagerSettings -> (Manager -> IO a) -> IO a
- proxyFromRequest :: ProxyOverride
- noProxy :: ProxyOverride
- useProxy :: Proxy -> ProxyOverride
- useProxySecureWithoutConnect :: Proxy -> ProxyOverride
- proxyEnvironment :: Maybe Proxy -> ProxyOverride
- proxyEnvironmentNamed :: Text -> Maybe Proxy -> ProxyOverride
- defaultProxy :: ProxyOverride
- isIpAddress :: ByteString -> Bool
- domainMatches :: ByteString -> ByteString -> Bool
- defaultPath :: Request -> ByteString
- pathMatches :: ByteString -> ByteString -> Bool
- createCookieJar :: [Cookie] -> CookieJar
- destroyCookieJar :: CookieJar -> [Cookie]
- removeExistingCookieFromCookieJar :: Cookie -> CookieJar -> (Maybe Cookie, CookieJar)
- isPotentiallyTrustworthyOrigin :: Bool -> ByteString -> Bool
- evictExpiredCookies :: CookieJar -> UTCTime -> CookieJar
- insertCookiesIntoRequest :: Request -> CookieJar -> UTCTime -> (Request, CookieJar)
- computeCookieString :: Request -> CookieJar -> UTCTime -> Bool -> (ByteString, CookieJar)
- updateCookieJar :: Response a -> Request -> UTCTime -> CookieJar -> (CookieJar, Response a)
- receiveSetCookie :: SetCookie -> Request -> UTCTime -> Bool -> CookieJar -> CookieJar
- insertCheckedCookie :: Cookie -> CookieJar -> Bool -> CookieJar
- generateCookie :: SetCookie -> Request -> UTCTime -> Bool -> Maybe Cookie
- withConnection :: Request -> Manager -> (Connection -> IO a) -> IO a
- responseOpenHistory :: Request -> Manager -> IO (HistoriedResponse BodyReader)
- withResponseHistory :: Request -> Manager -> (HistoriedResponse BodyReader -> IO a) -> IO a
- managerSetInsecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings
- managerSetSecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings
- managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings
- responseTimeoutMicro :: Int -> ResponseTimeout
- responseTimeoutNone :: ResponseTimeout
- responseTimeoutDefault :: ResponseTimeout
- httpLbs :: (MonadIO m, HasHttpManager env, MonadReader env m) => Request -> m (Response ByteString)
- httpNoBody :: (MonadIO m, HasHttpManager env, MonadReader env m) => Request -> m (Response ())
- requestBodySource :: Int64 -> ConduitM () ByteString IO () -> RequestBody
- requestBodySourceChunked :: ConduitM () ByteString IO () -> RequestBody
- bodyReaderSource :: MonadIO m => BodyReader -> ConduitM i ByteString m ()
Conduit-specific interface
withResponse :: (MonadUnliftIO m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a Source #
Conduit powered version of withResponse
. Differences are:
- Response body is represented as a
Producer
. - Generalized to any instance of
MonadUnliftIO
, not justIO
. - The
Manager
is contained by aMonadReader
context.
Since 2.1.0
responseOpen :: (MonadIO m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> m (Response (ConduitM i ByteString n ())) Source #
Conduit-powered version of responseOpen
.
See withResponse
for the differences with responseOpen
.
Since 2.1.0
responseClose :: MonadIO m => Response body -> m () Source #
Generalized version of responseClose
.
Since 2.1.0
acquireResponse :: (MonadIO n, MonadReader env m, HasHttpManager env) => Request -> m (Acquire (Response (ConduitM i ByteString n ()))) Source #
An Acquire
for getting a Response
.
Since 2.1.0
httpSource :: (MonadResource m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> (Response (ConduitM () ByteString n ()) -> ConduitM () r m ()) -> ConduitM () r m () Source #
Same as httpSource
, but uses Manager
from Reader environment instead of the global one.
Since 2.3.6
Manager helpers
defaultManagerSettings :: ManagerSettings Source #
TLS-powered manager settings.
Since 2.1.0
newManager :: MonadIO m => m Manager Source #
Get a new manager using defaultManagerSettings
.
Since 2.1.0
newManagerSettings :: MonadIO m => ManagerSettings -> m Manager Source #
Get a new manager using the given settings.
Since 2.1.0
General HTTP client interface
Constructors
Proxy | |
Fields
|
data StreamFileStatus #
Constructors
StreamFileStatus | |
Instances
Show StreamFileStatus | |
Defined in Network.HTTP.Client.Types | |
Eq StreamFileStatus | |
Defined in Network.HTTP.Client.Types Methods (==) :: StreamFileStatus -> StreamFileStatus -> Bool Source # (/=) :: StreamFileStatus -> StreamFileStatus -> Bool Source # | |
Ord StreamFileStatus | |
Defined in Network.HTTP.Client.Types Methods compare :: StreamFileStatus -> StreamFileStatus -> Ordering Source # (<) :: StreamFileStatus -> StreamFileStatus -> Bool Source # (<=) :: StreamFileStatus -> StreamFileStatus -> Bool Source # (>) :: StreamFileStatus -> StreamFileStatus -> Bool Source # (>=) :: StreamFileStatus -> StreamFileStatus -> Bool Source # max :: StreamFileStatus -> StreamFileStatus -> StreamFileStatus Source # min :: StreamFileStatus -> StreamFileStatus -> StreamFileStatus Source # |
class HasHttpManager a where #
Methods
getHttpManager :: a -> Manager #
Instances
HasHttpManager Manager | |
Defined in Network.HTTP.Client.Types Methods getHttpManager :: Manager -> Manager # |
Instances
HasHttpManager Manager | |
Defined in Network.HTTP.Client.Types Methods getHttpManager :: Manager -> Manager # |
data ProxyOverride #
data ManagerSettings #
Instances
Foldable Response | |
Defined in Network.HTTP.Client.Types Methods fold :: Monoid m => Response m -> m Source # foldMap :: Monoid m => (a -> m) -> Response a -> m Source # foldMap' :: Monoid m => (a -> m) -> Response a -> m Source # foldr :: (a -> b -> b) -> b -> Response a -> b Source # foldr' :: (a -> b -> b) -> b -> Response a -> b Source # foldl :: (b -> a -> b) -> b -> Response a -> b Source # foldl' :: (b -> a -> b) -> b -> Response a -> b Source # foldr1 :: (a -> a -> a) -> Response a -> a Source # foldl1 :: (a -> a -> a) -> Response a -> a Source # toList :: Response a -> [a] Source # null :: Response a -> Bool Source # length :: Response a -> Int Source # elem :: Eq a => a -> Response a -> Bool Source # maximum :: Ord a => Response a -> a Source # minimum :: Ord a => Response a -> a Source # | |
Traversable Response | |
Defined in Network.HTTP.Client.Types | |
Functor Response | |
Show body => Show (Response body) | |
data ResponseTimeout #
Instances
Show ResponseTimeout | |
Defined in Network.HTTP.Client.Types | |
Eq ResponseTimeout | |
Defined in Network.HTTP.Client.Types Methods (==) :: ResponseTimeout -> ResponseTimeout -> Bool Source # (/=) :: ResponseTimeout -> ResponseTimeout -> Bool Source # |
type GivesPopper a = NeedsPopper a -> IO a #
type NeedsPopper a = Popper -> IO a #
type Popper = IO ByteString #
data RequestBody #
Constructors
RequestBodyLBS ByteString | |
RequestBodyBS ByteString | |
RequestBodyBuilder Int64 Builder | |
RequestBodyStream Int64 (GivesPopper ()) | |
RequestBodyStreamChunked (GivesPopper ()) | |
RequestBodyIO (IO RequestBody) |
Instances
IsString RequestBody | |
Defined in Network.HTTP.Client.Types Methods fromString :: String -> RequestBody Source # | |
Monoid RequestBody | |
Defined in Network.HTTP.Client.Types Methods mempty :: RequestBody Source # mappend :: RequestBody -> RequestBody -> RequestBody Source # mconcat :: [RequestBody] -> RequestBody Source # | |
Semigroup RequestBody | |
Defined in Network.HTTP.Client.Types Methods (<>) :: RequestBody -> RequestBody -> RequestBody Source # sconcat :: NonEmpty RequestBody -> RequestBody Source # stimes :: Integral b => b -> RequestBody -> RequestBody Source # |
Constructors
data HttpExceptionContent #
Constructors
Instances
Show HttpExceptionContent | |
Defined in Network.HTTP.Client.Types |
data HttpException #
Instances
Exception HttpException | |
Defined in Network.HTTP.Client.Types Methods toException :: HttpException -> SomeException Source # fromException :: SomeException -> Maybe HttpException Source # | |
Show HttpException | |
Defined in Network.HTTP.Client.Types |
data HistoriedResponse body #
Instances
equalCookie :: Cookie -> Cookie -> Bool #
equivCookie :: Cookie -> Cookie -> Bool #
compareCookies :: Cookie -> Cookie -> Ordering #
equalCookieJar :: CookieJar -> CookieJar -> Bool #
equivCookieJar :: CookieJar -> CookieJar -> Bool #
makeConnection :: IO ByteString -> (ByteString -> IO ()) -> IO () -> IO Connection #
socketConnection :: Socket -> Int -> IO Connection #
strippedHostName :: String -> String #
brReadSome :: BodyReader -> Int -> IO ByteString #
parseUrl :: MonadThrow m => String -> m Request #
parseUrlThrow :: MonadThrow m => String -> m Request #
throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m () #
parseRequest :: MonadThrow m => String -> m Request #
parseRequest_ :: String -> Request #
requestFromURI :: MonadThrow m => URI -> m Request #
requestFromURI_ :: URI -> Request #
applyBasicAuth :: ByteString -> ByteString -> Request -> Request #
applyBearerAuth :: ByteString -> Request -> Request #
applyBasicProxyAuth :: ByteString -> ByteString -> Request -> Request #
urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request #
setRequestCheckStatus :: Request -> Request #
setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request #
setQueryStringPartialEscape :: [(ByteString, [EscapeItem])] -> Request -> Request #
streamFile :: FilePath -> IO RequestBody #
observedStreamFile :: (StreamFileStatus -> IO ()) -> FilePath -> IO RequestBody #
getOriginalRequest :: Response a -> Request #
rawConnectionModifySocket :: (Socket -> IO ()) -> IO (Maybe HostAddress -> String -> Int -> IO Connection) #
rawConnectionModifySocketSize :: (Socket -> IO ()) -> IO (Int -> Maybe HostAddress -> String -> Int -> IO Connection) #
withManager :: ManagerSettings -> (Manager -> IO a) -> IO a #
useProxy :: Proxy -> ProxyOverride #
proxyEnvironment :: Maybe Proxy -> ProxyOverride #
proxyEnvironmentNamed :: Text -> Maybe Proxy -> ProxyOverride #
isIpAddress :: ByteString -> Bool #
domainMatches :: ByteString -> ByteString -> Bool #
defaultPath :: Request -> ByteString #
pathMatches :: ByteString -> ByteString -> Bool #
createCookieJar :: [Cookie] -> CookieJar #
destroyCookieJar :: CookieJar -> [Cookie] #
isPotentiallyTrustworthyOrigin :: Bool -> ByteString -> Bool #
evictExpiredCookies :: CookieJar -> UTCTime -> CookieJar #
computeCookieString :: Request -> CookieJar -> UTCTime -> Bool -> (ByteString, CookieJar) #
responseOpenHistory :: Request -> Manager -> IO (HistoriedResponse BodyReader) #
withResponseHistory :: Request -> Manager -> (HistoriedResponse BodyReader -> IO a) -> IO a #
httpLbs :: (MonadIO m, HasHttpManager env, MonadReader env m) => Request -> m (Response ByteString) Source #
Same as httpLbs
, except it uses the Manager
in the reader environment.
Since 2.1.1
httpNoBody :: (MonadIO m, HasHttpManager env, MonadReader env m) => Request -> m (Response ()) Source #
Same as httpNoBody
, except it uses the Manager
in the reader environment.
This can be more convenient that using withManager
as it avoids the need
to specify the base monad for the response body.
Since 2.1.2
Lower-level conduit functions
requestBodySource :: Int64 -> ConduitM () ByteString IO () -> RequestBody Source #
requestBodySourceChunked :: ConduitM () ByteString IO () -> RequestBody Source #
bodyReaderSource :: MonadIO m => BodyReader -> ConduitM i ByteString m () Source #