http-conduit-2.3.2: HTTP client package with conduit interface and HTTPS support.

Safe HaskellNone
LanguageHaskell98

Network.HTTP.Client.Conduit

Contents

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

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 just IO.
  • The Manager is contained by a MonadReader 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

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

data Manager #

Instances
HasHttpManager Manager 
Instance details

Defined in Network.HTTP.Client.Types

withResponseHistory :: Request -> Manager -> (HistoriedResponse BodyReader -> IO a) -> IO a #

brReadSome :: BodyReader -> Int -> IO ByteString #

makeConnection :: IO ByteString -> (ByteString -> IO ()) -> IO () -> IO Connection #

socketConnection :: Socket -> Int -> IO Connection #

withConnection :: Request -> Manager -> (Connection -> IO a) -> IO a #

rawConnectionModifySocket :: (Socket -> IO ()) -> IO (Maybe HostAddress -> String -> Int -> IO Connection) #

rawConnectionModifySocketSize :: (Socket -> IO ()) -> IO (Int -> Maybe HostAddress -> String -> Int -> IO Connection) #

throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m () #

data HistoriedResponse body #

Instances
Functor HistoriedResponse 
Instance details

Defined in Network.HTTP.Client

Foldable HistoriedResponse 
Instance details

Defined in Network.HTTP.Client

Methods

fold :: Monoid m => HistoriedResponse m -> m #

foldMap :: Monoid m => (a -> m) -> HistoriedResponse a -> m #

foldr :: (a -> b -> b) -> b -> HistoriedResponse a -> b #

foldr' :: (a -> b -> b) -> b -> HistoriedResponse a -> b #

foldl :: (b -> a -> b) -> b -> HistoriedResponse a -> b #

foldl' :: (b -> a -> b) -> b -> HistoriedResponse a -> b #

foldr1 :: (a -> a -> a) -> HistoriedResponse a -> a #

foldl1 :: (a -> a -> a) -> HistoriedResponse a -> a #

toList :: HistoriedResponse a -> [a] #

null :: HistoriedResponse a -> Bool #

length :: HistoriedResponse a -> Int #

elem :: Eq a => a -> HistoriedResponse a -> Bool #

maximum :: Ord a => HistoriedResponse a -> a #

minimum :: Ord a => HistoriedResponse a -> a #

sum :: Num a => HistoriedResponse a -> a #

product :: Num a => HistoriedResponse a -> a #

Traversable HistoriedResponse 
Instance details

Defined in Network.HTTP.Client

Methods

traverse :: Applicative f => (a -> f b) -> HistoriedResponse a -> f (HistoriedResponse b) #

sequenceA :: Applicative f => HistoriedResponse (f a) -> f (HistoriedResponse a) #

mapM :: Monad m => (a -> m b) -> HistoriedResponse a -> m (HistoriedResponse b) #

sequence :: Monad m => HistoriedResponse (m a) -> m (HistoriedResponse a) #

Show body => Show (HistoriedResponse body) 
Instance details

Defined in Network.HTTP.Client

Generic (HistoriedResponse body) 
Instance details

Defined in Network.HTTP.Client

Associated Types

type Rep (HistoriedResponse body) :: * -> * #

Methods

from :: HistoriedResponse body -> Rep (HistoriedResponse body) x #

to :: Rep (HistoriedResponse body) x -> HistoriedResponse body #

type Rep (HistoriedResponse body) 
Instance details

Defined in Network.HTTP.Client

type Rep (HistoriedResponse body) = D1 (MetaData "HistoriedResponse" "Network.HTTP.Client" "http-client-0.5.13.1-7n7LiRW7MsG6FEiXBiQ992" False) (C1 (MetaCons "HistoriedResponse" PrefixI True) (S1 (MetaSel (Just "hrRedirects") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [(Request, Response ByteString)]) :*: (S1 (MetaSel (Just "hrFinalRequest") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Request) :*: S1 (MetaSel (Just "hrFinalResponse") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Response body)))))

type GivesPopper a = NeedsPopper a -> IO a #

class HasHttpManager a where #

Minimal complete definition

getHttpManager

Methods

getHttpManager :: a -> Manager #

Instances
HasHttpManager Manager 
Instance details

Defined in Network.HTTP.Client.Types

type NeedsPopper a = Popper -> IO a #

data Proxy #

Constructors

Proxy 
Instances
Eq Proxy 
Instance details

Defined in Network.HTTP.Client.Types

Methods

(==) :: Proxy -> Proxy -> Bool #

(/=) :: Proxy -> Proxy -> Bool #

Ord Proxy 
Instance details

Defined in Network.HTTP.Client.Types

Methods

compare :: Proxy -> Proxy -> Ordering #

(<) :: Proxy -> Proxy -> Bool #

(<=) :: Proxy -> Proxy -> Bool #

(>) :: Proxy -> Proxy -> Bool #

(>=) :: Proxy -> Proxy -> Bool #

max :: Proxy -> Proxy -> Proxy #

min :: Proxy -> Proxy -> Proxy #

Read Proxy 
Instance details

Defined in Network.HTTP.Client.Types

Show Proxy 
Instance details

Defined in Network.HTTP.Client.Types

Methods

showsPrec :: Int -> Proxy -> ShowS #

show :: Proxy -> String #

showList :: [Proxy] -> ShowS #

data Request #

Instances
Show Request 
Instance details

Defined in Network.HTTP.Client.Types

data Response body #

Instances
Functor Response 
Instance details

Defined in Network.HTTP.Client.Types

Methods

fmap :: (a -> b) -> Response a -> Response b #

(<$) :: a -> Response b -> Response a #

Foldable Response 
Instance details

Defined in Network.HTTP.Client.Types

Methods

fold :: Monoid m => Response m -> m #

foldMap :: Monoid m => (a -> m) -> Response a -> m #

foldr :: (a -> b -> b) -> b -> Response a -> b #

foldr' :: (a -> b -> b) -> b -> Response a -> b #

foldl :: (b -> a -> b) -> b -> Response a -> b #

foldl' :: (b -> a -> b) -> b -> Response a -> b #

foldr1 :: (a -> a -> a) -> Response a -> a #

foldl1 :: (a -> a -> a) -> Response a -> a #

toList :: Response a -> [a] #

null :: Response a -> Bool #

length :: Response a -> Int #

elem :: Eq a => a -> Response a -> Bool #

maximum :: Ord a => Response a -> a #

minimum :: Ord a => Response a -> a #

sum :: Num a => Response a -> a #

product :: Num a => Response a -> a #

Traversable Response 
Instance details

Defined in Network.HTTP.Client.Types

Methods

traverse :: Applicative f => (a -> f b) -> Response a -> f (Response b) #

sequenceA :: Applicative f => Response (f a) -> f (Response a) #

mapM :: Monad m => (a -> m b) -> Response a -> m (Response b) #

sequence :: Monad m => Response (m a) -> m (Response a) #

Eq body => Eq (Response body) 
Instance details

Defined in Network.HTTP.Client.Types

Methods

(==) :: Response body -> Response body -> Bool #

(/=) :: Response body -> Response body -> Bool #

Show body => Show (Response body) 
Instance details

Defined in Network.HTTP.Client.Types

Methods

showsPrec :: Int -> Response body -> ShowS #

show :: Response body -> String #

showList :: [Response body] -> ShowS #

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

bodyReaderSource :: MonadIO m => BodyReader -> ConduitM i ByteString m () Source #