bilge-0.22.0: Library for composing HTTP requests.
Safe HaskellSafe-Inferred
LanguageGHC2021

Bilge.IO

Synopsis

Convenience API

newtype HttpT m a Source #

Constructors

HttpT 

Fields

Instances

Instances details
MonadTransControl HttpT Source # 
Instance details

Defined in Bilge.IO

Associated Types

type StT HttpT a Source #

Methods

liftWith :: Monad m => (Run HttpT -> m a) -> HttpT m a Source #

restoreT :: Monad m => m (StT HttpT a) -> HttpT m a Source #

MonadTrans HttpT Source # 
Instance details

Defined in Bilge.IO

Methods

lift :: Monad m => m a -> HttpT m a #

MonadBaseControl IO (HttpT IO) Source # 
Instance details

Defined in Bilge.IO

Associated Types

type StM (HttpT IO) a Source #

Methods

liftBaseWith :: (RunInBase (HttpT IO) IO -> IO a) -> HttpT IO a Source #

restoreM :: StM (HttpT IO) a -> HttpT IO a Source #

Monad m => MonadReader Manager (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

ask :: HttpT m Manager #

local :: (Manager -> Manager) -> HttpT m a -> HttpT m a #

reader :: (Manager -> a) -> HttpT m a #

MonadBase IO (HttpT IO) Source # 
Instance details

Defined in Bilge.IO

Methods

liftBase :: IO α -> HttpT IO α Source #

MonadFail m => MonadFail (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

fail :: String -> HttpT m a #

MonadIO m => MonadIO (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

liftIO :: IO a -> HttpT m a #

Applicative m => Applicative (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

pure :: a -> HttpT m a #

(<*>) :: HttpT m (a -> b) -> HttpT m a -> HttpT m b #

liftA2 :: (a -> b -> c) -> HttpT m a -> HttpT m b -> HttpT m c #

(*>) :: HttpT m a -> HttpT m b -> HttpT m b #

(<*) :: HttpT m a -> HttpT m b -> HttpT m a #

Functor m => Functor (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

fmap :: (a -> b) -> HttpT m a -> HttpT m b #

(<$) :: a -> HttpT m b -> HttpT m a #

Monad m => Monad (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

(>>=) :: HttpT m a -> (a -> HttpT m b) -> HttpT m b #

(>>) :: HttpT m a -> HttpT m b -> HttpT m b #

return :: a -> HttpT m a #

MonadIO m => MonadHttp (HttpT m) Source # 
Instance details

Defined in Bilge.IO

MonadCatch m => MonadCatch (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

catch :: (HasCallStack, Exception e) => HttpT m a -> (e -> HttpT m a) -> HttpT m a #

MonadMask m => MonadMask (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

mask :: HasCallStack => ((forall a. HttpT m a -> HttpT m a) -> HttpT m b) -> HttpT m b #

uninterruptibleMask :: HasCallStack => ((forall a. HttpT m a -> HttpT m a) -> HttpT m b) -> HttpT m b #

generalBracket :: HasCallStack => HttpT m a -> (a -> ExitCase b -> HttpT m c) -> (a -> HttpT m b) -> HttpT m (b, c) #

MonadThrow m => MonadThrow (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

throwM :: (HasCallStack, Exception e) => e -> HttpT m a #

MonadUnliftIO m => MonadUnliftIO (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

withRunInIO :: ((forall a. HttpT m a -> IO a) -> IO b) -> HttpT m b Source #

type StT HttpT a Source # 
Instance details

Defined in Bilge.IO

type StT HttpT a = StT (ReaderT Manager) a
type StM (HttpT IO) a Source # 
Instance details

Defined in Bilge.IO

type StM (HttpT IO) a = ComposeSt HttpT IO a

class MonadHttp m where Source #

Instances

Instances details
MonadHttp Session Source # 
Instance details

Defined in Bilge.IO

MonadIO m => MonadHttp (HttpT m) Source # 
Instance details

Defined in Bilge.IO

MonadIO m => MonadHttp (SessionT m) Source # 
Instance details

Defined in Bilge.IO

(MonadTrans t, MonadHttp m, Monad m) => MonadHttp (t m) Source # 
Instance details

Defined in Bilge.IO

data Debug Source #

Debug settings may cause debug information to be printed to stdout.

Constructors

Head

Print HTTP request/response header.

Full

Like Head but also print the response body.

Instances

Instances details
Enum Debug Source # 
Instance details

Defined in Bilge.IO

Show Debug Source # 
Instance details

Defined in Bilge.IO

Methods

showsPrec :: Int -> Debug -> ShowS #

show :: Debug -> String #

showList :: [Debug] -> ShowS #

Eq Debug Source # 
Instance details

Defined in Bilge.IO

Methods

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

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

Ord Debug Source # 
Instance details

Defined in Bilge.IO

Methods

compare :: Debug -> Debug -> Ordering #

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

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

(>) :: Debug -> Debug -> Bool #

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

max :: Debug -> Debug -> Debug #

min :: Debug -> Debug -> Debug #

runHttpT :: Manager -> HttpT m a -> m a Source #

http :: MonadHttp m => Request -> (Request -> Request) -> (Response BodyReader -> IO a) -> m a Source #

get :: MonadHttp m => (Request -> Request) -> m (Response (Maybe LByteString)) Source #

Given a Request builder function, perform an actual HTTP request using the respective method and return the response, fully consuming the response body as a lazy ByteString.

put :: MonadHttp m => (Request -> Request) -> m (Response (Maybe LByteString)) Source #

Given a Request builder function, perform an actual HTTP request using the respective method and return the response, fully consuming the response body as a lazy ByteString.

post :: MonadHttp m => (Request -> Request) -> m (Response (Maybe LByteString)) Source #

Given a Request builder function, perform an actual HTTP request using the respective method and return the response, fully consuming the response body as a lazy ByteString.

head :: MonadHttp m => (Request -> Request) -> m (Response (Maybe LByteString)) Source #

Given a Request builder function, perform an actual HTTP request using the respective method and return the response, fully consuming the response body as a lazy ByteString.

delete :: MonadHttp m => (Request -> Request) -> m (Response (Maybe LByteString)) Source #

Given a Request builder function, perform an actual HTTP request using the respective method and return the response, fully consuming the response body as a lazy ByteString.

options :: MonadHttp m => (Request -> Request) -> m (Response (Maybe LByteString)) Source #

Given a Request builder function, perform an actual HTTP request using the respective method and return the response, fully consuming the response body as a lazy ByteString.

trace :: MonadHttp m => (Request -> Request) -> m (Response (Maybe LByteString)) Source #

Given a Request builder function, perform an actual HTTP request using the respective method and return the response, fully consuming the response body as a lazy ByteString.

patch :: MonadHttp m => (Request -> Request) -> m (Response (Maybe LByteString)) Source #

Given a Request builder function, perform an actual HTTP request using the respective method and return the response, fully consuming the response body as a lazy ByteString.

Re-exports

data ManagerSettings Source #

Settings for a Manager. Please use the defaultManagerSettings function and then modify individual settings. For more information, see http://www.yesodweb.com/book/settings-types.

Since 0.1.0

withResponse :: Request -> Manager -> (Response BodyReader -> IO a) -> IO a Source #

Perform a Request using a connection acquired from the given Manager, and then provide the Response to the given function. This function is fully exception safe, guaranteeing that the response will be closed when the inner function exits. It is defined as:

withResponse req man f = bracket (responseOpen req man) responseClose f

It is recommended that you use this function in place of explicit calls to responseOpen and responseClose.

You will need to use functions such as brRead to consume the response body.

Since 0.1.0

data Manager Source #

Keeps track of open connections for keep-alive.

If possible, you should share a single Manager between multiple threads and requests.

Since 0.1.0

Instances

Instances details
HasHttpManager Manager 
Instance details

Defined in Network.HTTP.Client.Types

Monad m => MonadReader Manager (HttpT m) Source # 
Instance details

Defined in Bilge.IO

Methods

ask :: HttpT m Manager #

local :: (Manager -> Manager) -> HttpT m a -> HttpT m a #

reader :: (Manager -> a) -> HttpT m a #

newManager :: ManagerSettings -> IO Manager Source #

Create a Manager. The Manager will be shut down automatically via garbage collection.

Creating a new Manager is a relatively expensive operation, you are advised to share a single Manager between requests instead.

The first argument to this function is often defaultManagerSettings, though add-on libraries may provide a recommended replacement.

Since 0.1.0

withManager :: ManagerSettings -> (Manager -> IO a) -> IO a Source #

Create, use and close a Manager.

Since 0.2.1

defaultManagerSettings :: ManagerSettings Source #

Default value for ManagerSettings.

Note that this value does not have support for SSL/TLS. If you need to make any https connections, please use the http-client-tls package, which provides a tlsManagerSettings value.

Since 0.1.0

type BodyReader = IO ByteString Source #

An IO action that represents an incoming response body coming from the server. Data provided by this action has already been gunzipped and de-chunked, and respects any content-length headers present.

The action gets a single chunk of data from the response body, or an empty bytestring if no more data is available.

Since 0.4.0

brRead :: BodyReader -> IO ByteString Source #

Get a single chunk of data from the response body, or an empty bytestring if no more data is available.

Note that in order to consume the entire request body, you will need to repeatedly call this function until you receive an empty ByteString as a result.

Since 0.1.0

brConsume :: BodyReader -> IO [ByteString] Source #

Strictly consume all remaining chunks of data from the stream.

Since 0.1.0

data HttpException Source #

An exception which may be generated by this library

Since: http-client-0.5.0

Constructors

HttpExceptionRequest Request HttpExceptionContent

Most exceptions are specific to a Request. Inspect the HttpExceptionContent value for details on what occurred.

Since: http-client-0.5.0

InvalidUrlException String String

A URL (first field) is invalid for a given reason (second argument).

Since: http-client-0.5.0