-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Monad abstraction for HTTP allowing lazy transfer and non-I/O simulation -- -- This library implements a monad class with various interesting -- instances: -- -- -- -- By using this monad you can implement HTTP communication in a very -- general way. You may add further functionality by adding custom -- sub-classes. -- -- We inherit all content data types from the HTTP-4000 package, such as -- String as well as strict and lazy ByteString. @package http-monad @version 0.1 -- | Provide the functionality of Network.HTTP.Headers with -- qualified identifier style. module Network.Monad.HTTP.Header -- | HasHeaders is a type class for types containing HTTP headers, -- allowing you to write overloaded header manipulation functions for -- both Request and Response data types, for instance. class HasHeaders x getHeaders :: HasHeaders x => x -> [Header] setHeaders :: HasHeaders x => x -> [Header] -> x type T = Header -- | The Header data type pairs header names & values. data Header :: * Header :: HeaderName -> String -> Header cons :: Name -> String -> T type Name = HeaderName -- | HTTP HeaderName type, a Haskell data constructor for each -- specification-defined header, prefixed with Hdr and -- CamelCased, (i.e., eliding the - in the process.) Should you -- require using a custom header, there's the HdrCustom -- constructor which takes a String argument. -- -- Encoding HTTP header names differently, as Strings perhaps, is an -- equally fine choice..no decidedly clear winner, but let's stick with -- data constructors here. data HeaderName :: * HdrCacheControl :: HeaderName HdrConnection :: HeaderName HdrDate :: HeaderName HdrPragma :: HeaderName HdrTransferEncoding :: HeaderName HdrUpgrade :: HeaderName HdrVia :: HeaderName HdrAccept :: HeaderName HdrAcceptCharset :: HeaderName HdrAcceptEncoding :: HeaderName HdrAcceptLanguage :: HeaderName HdrAuthorization :: HeaderName HdrCookie :: HeaderName HdrExpect :: HeaderName HdrFrom :: HeaderName HdrHost :: HeaderName HdrIfModifiedSince :: HeaderName HdrIfMatch :: HeaderName HdrIfNoneMatch :: HeaderName HdrIfRange :: HeaderName HdrIfUnmodifiedSince :: HeaderName HdrMaxForwards :: HeaderName HdrProxyAuthorization :: HeaderName HdrRange :: HeaderName HdrReferer :: HeaderName HdrUserAgent :: HeaderName HdrAge :: HeaderName HdrLocation :: HeaderName HdrProxyAuthenticate :: HeaderName HdrPublic :: HeaderName HdrRetryAfter :: HeaderName HdrServer :: HeaderName HdrSetCookie :: HeaderName HdrTE :: HeaderName HdrTrailer :: HeaderName HdrVary :: HeaderName HdrWarning :: HeaderName HdrWWWAuthenticate :: HeaderName HdrAllow :: HeaderName HdrContentBase :: HeaderName HdrContentEncoding :: HeaderName HdrContentLanguage :: HeaderName HdrContentLength :: HeaderName HdrContentLocation :: HeaderName HdrContentMD5 :: HeaderName HdrContentRange :: HeaderName HdrContentType :: HeaderName HdrETag :: HeaderName HdrExpires :: HeaderName HdrLastModified :: HeaderName -- | MIME entity headers (for sub-parts) HdrContentTransferEncoding :: HeaderName -- | Allows for unrecognised or experimental headers. HdrCustom :: String -> HeaderName consName :: String -> Name getName :: T -> Name getValue :: T -> String setMany :: HasHeaders x => x -> [T] -> x getMany :: HasHeaders x => x -> [T] modifyMany :: HasHeaders x => ([T] -> [T]) -> x -> x insert :: HasHeaders a => Name -> String -> a -> a -- | Inserts a header with the given name and value. Allows duplicate -- header names. -- -- Adds the new header only if no previous header shares the same name. -- -- Removes old headers with duplicate name. -- -- Inserts multiple headers. insertMany :: HasHeaders a => [T] -> a -> a insertIfMissing :: HasHeaders a => Name -> String -> a -> a -- | Gets a list of headers with a particular Name. retrieveMany :: HasHeaders a => Name -> a -> [T] replace :: HasHeaders a => Name -> String -> a -> a -- | Lookup presence of specific Name in a list of Headers Returns the -- value from the first matching header. find :: HasHeaders a => Name -> a -> Maybe String findMany :: HasHeaders a => Name -> a -> [String] lookup :: Name -> [T] -> Maybe String parse :: String -> Exceptional String T parseManyWarn :: [String] -> [Exceptional String T] parseManyStraight :: [String] -> [T] dictionary :: Map String Name matchName :: Name -> T -> Bool module Network.Monad.Body class Monoid body => C body fromString :: C body => String -> body toString :: C body => body -> String isLineTerm :: C body => body -> Bool isEmpty :: C body => body -> Bool class CharType char fromChar :: CharType char => Char -> char toChar :: CharType char => char -> Char instance C ByteString instance C ByteString instance CharType char => C [char] instance CharType Char -- | With this monad we abstract from the IO monad, which also allows us to -- process data lazily or offline. module Network.Monad.Transfer type SyncExceptional m = ExceptionalT ConnError m type AsyncExceptional m = ExceptionalT ConnError m data T m body Cons :: AsyncExceptional m body -> (Int -> AsyncExceptional m body) -> (body -> SyncExceptional m ()) -> T m body readLine :: T m body -> AsyncExceptional m body readBlock :: T m body -> Int -> AsyncExceptional m body writeBlock :: T m body -> body -> SyncExceptional m () liftIOSync :: MonadIO io => IO (Result a) -> SyncExceptional io a liftIOAsync :: (MonadIO io, Monoid a) => IO (Result a) -> AsyncExceptional io a -- | Provide the explicit class dictionary as context via a Reader monad. module Network.Monad.Reader type T body m = ReaderT (T m body) m type SyncExceptional body m = ExceptionalT ConnError (T body m) type AsyncExceptional body m = ExceptionalT ConnError (T body m) readLine :: Monad m => AsyncExceptional body m body readBlock :: Monad m => Int -> AsyncExceptional body m body writeBlock :: Monad m => body -> SyncExceptional body m () module Network.Monad.Transfer.IO transfer :: (HStream body, Monoid body, MonadIO io) => HandleStream body -> T io body run :: (HStream body, Monoid body, MonadIO io) => T body io a -> HandleStream body -> io a module Network.Monad.HTTP send :: (Monad m, C body) => Request body -> SynchronousExceptional body m (Exceptional ConnError (Bool, Response body)) -- | Receive and parse a HTTP request from the given Stream. Should be used -- for server side interactions. receive :: (Monad m, C body) => SynchronousExceptional body m (Exceptional ConnError (Request body)) -- | Very simple function, send a HTTP response over the given stream. This -- could be improved on to use different transfer types. respond :: (Monad m, C body) => Response body -> SynchronousExceptional body m () instance Show body => Show (ChunkedResponse body) instance Monoid body => Monoid (ChunkedResponse body) -- | Transfer type without IO interaction. Optimal for testing. module Network.Monad.Transfer.Offline type T body = RWS ConnError [body] body class C body => Body body splitAt :: Body body => Int -> body -> (body, body) breakAfter :: Body body => (Char -> Bool) -> body -> (body, body) withBuffer :: C body => (body -> (a, body)) -> AsyncExceptional (T body) a transfer :: Body body => T (T body) body run :: Body body => T body (T body) a -> ConnError -> body -> (a, body, [body]) instance Body ByteString instance Body ByteString instance CharType char => Body [char] module Network.Monad.Transfer.ChunkyLazyIO class C body => Body body length :: Body body => body -> Int transfer :: (HStream body, Body body) => Int -> HandleStream body -> T T body run :: (HStream body, Body body) => T body T a -> Int -> HandleStream body -> IO a instance Body ByteString instance Body ByteString instance CharType char => Body [char]