Copyright | (C) 2015 Futurice Oy |
---|---|
License | BSD-3-Clause |
Maintainer | Oleg Grenrus <oleg.grenrus@iki.fi> |
Safe Haskell | None |
Language | Haskell2010 |
MonadHttp
class with basic HTTP functionality.
- class Monad m => MonadHttp m where
- withResponse :: Request -> (Response (BodyReaderM m) -> m a) -> m a
- brRead :: BodyReaderM m -> m ByteString
- type BodyReaderM m = m ByteString
- newtype HttpT m a = HttpT {}
- evalHttpT :: MonadIO m => HttpT m a -> m a
- httpLbs :: MonadHttp m => Request -> m (Response ByteString)
- brConsume :: MonadHttp m => BodyReaderM m -> m [ByteString]
- data Request :: *
- data Response body :: * -> *
Class
class Monad m => MonadHttp m where Source
The monad capable to do HTTP requests.
withResponse :: Request -> (Response (BodyReaderM m) -> m a) -> m a 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.
brRead :: BodyReaderM m -> m ByteString Source
MonadHttp m => MonadHttp (MaybeT m) Source | |
MonadHttp m => MonadHttp (NoLoggingT m) Source | |
MonadHttp m => MonadHttp (LoggingT m) Source | |
MonadHttp m => MonadHttp (IdentityT m) Source | |
(~) (* -> *) m IO => MonadHttp (HttpT m) Source | TODO: Generalise to MonadIO + MonadMask? |
MonadHttp m => MonadHttp (RandT g m) Source | |
(MonadHttp m, Monoid w) => MonadHttp (WriterT w m) Source | |
(MonadHttp m, Monoid w) => MonadHttp (WriterT w m) Source | |
MonadHttp m => MonadHttp (StateT r m) Source | |
MonadHttp m => MonadHttp (StateT r m) Source | |
MonadHttp m => MonadHttp (ReaderT r m) Source | |
(MonadHttp m, Error e) => MonadHttp (ErrorT e m) Source | |
MonadHttp m => MonadHttp (ExceptT e m) Source | |
MonadHttp m => MonadHttp (CRandT g e m) Source | |
(MonadHttp m, Monoid w) => MonadHttp (RWST r w s m) Source | |
(MonadHttp m, Monoid w) => MonadHttp (RWST r w s m) Source |
type BodyReaderM m = m ByteString Source
Transformer
Http monad transformer, essentially ReaderT
Manager
.
MonadTrans HttpT Source | |
MonadRWS r w s m => MonadRWS r w s (HttpT m) Source | |
MonadSplit g m => MonadSplit g (HttpT m) Source | |
MonadCRandom e m => MonadCRandom e (HttpT m) Source | |
MonadCRandomR e m => MonadCRandomR e (HttpT m) Source | |
MonadError e m => MonadError e (HttpT m) Source | |
MonadReader r m => MonadReader r (HttpT m) Source | |
MonadState s m => MonadState s (HttpT m) Source | |
MonadWriter w m => MonadWriter w (HttpT m) Source | |
Monad m => Monad (HttpT m) Source | |
Functor m => Functor (HttpT m) Source | |
Applicative m => Applicative (HttpT m) Source | |
MonadRandom m => MonadRandom (HttpT m) Source | |
MonadThrow m => MonadThrow (HttpT m) Source | |
MonadCatch m => MonadCatch (HttpT m) Source | |
MonadMask m => MonadMask (HttpT m) Source | |
MonadLogger m => MonadLogger (HttpT m) Source | |
MonadLoggerIO m => MonadLoggerIO (HttpT m) Source | |
MonadIO m => MonadIO (HttpT m) Source | |
MonadCont m => MonadCont (HttpT m) Source | |
(~) (* -> *) m IO => MonadHttp (HttpT m) Source | TODO: Generalise to MonadIO + MonadMask? |
evalHttpT :: MonadIO m => HttpT m a -> m a Source
Lower HttpT
with default Manager
created with tlsManagerSettings
.
Utilities
httpLbs :: MonadHttp m => Request -> m (Response ByteString) Source
A convenience wrapper around withResponse
which reads in the entire
response body and immediately releases resources.
brConsume :: MonadHttp m => BodyReaderM m -> m [ByteString] Source
Strictly consume all remaining chunks of data from the stream.
Re-exports
data Request :: *
All information on how to connect to a host and what should be sent in the HTTP request.
If you simply wish to download from a URL, see parseUrl
.
The constructor for this data type is not exposed. Instead, you should use
either the def
method to retrieve a default instance, or parseUrl
to
construct from a URL, and then use the records below to make modifications.
This approach allows http-client to add configuration options without
breaking backwards compatibility.
For example, to construct a POST request, you could do something like:
initReq <- parseUrl "http://www.example.com/path" let req = initReq { method = "POST" }
For more information, please see http://www.yesodweb.com/book/settings-types.
Since 0.1.0