-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Incremental HTTP iteratee -- -- Incremental iteratee-based HTTP library using the enumerator -- package. @package ihttp @version 0.2.0 -- | Types for ihttp. module Network.IHttp.Types -- | Map of HTTP headers. type HeaderMap = Map ByteString ByteString -- | HTTP request method. data HttpMethod -- | CONNECT ConnectMethod :: HttpMethod -- | DELETE DeleteMethod :: HttpMethod -- | GET GetMethod :: HttpMethod -- | HEAD HeadMethod :: HttpMethod -- | OPTIONS OptionsMethod :: HttpMethod -- | PATCH PatchMethod :: HttpMethod -- | POST PostMethod :: HttpMethod -- | PUT PutMethod :: HttpMethod -- | TRACE TraceMethod :: HttpMethod -- | Methods this library doesn't know. XMethod :: ByteString -> HttpMethod -- | HTTP protocol version. data HttpVersion -- | Version 1.0 of HTTP. Http1_0 :: HttpVersion -- | Version 1.1 of HTTP. Http1_1 :: HttpVersion -- | HTTP request line with status code. data Request Request :: HeaderMap -> HttpMethod -> ByteString -> HttpVersion -> Request -- | Request headers. requestHeaders :: Request -> HeaderMap -- | Request method. requestMethod :: Request -> HttpMethod -- | Request URI. requestUri :: Request -> ByteString -- | HTTP version of request. requestVersion :: Request -> HttpVersion -- | HTTP response line with the status code. data Response Response :: Int -> HeaderMap -> ByteString -> HttpVersion -> Response -- | HTTP response code. responseCode :: Response -> Int -- | Response headers. responseHeaders :: Response -> HeaderMap -- | Response message. responseMessage :: Response -> ByteString -- | Protocol version of response. responseVersion :: Response -> HttpVersion -- | HTTP error. data HttpError -- | Invalid headers from client/server. InvalidHeaderError :: String -> HttpError httpErrorMessage :: HttpError -> String -- | Invalid requests from client. InvalidRequestError :: String -> HttpError httpErrorMessage :: HttpError -> String -- | Invalid responses from server. InvalidResponseError :: String -> HttpError httpErrorMessage :: HttpError -> String -- | Unsupported HTTP version. UnsupportedVersionError :: String -> HttpError httpErrorMessage :: HttpError -> String instance Typeable HttpError instance Eq HttpError instance Eq HttpMethod instance Read HttpMethod instance Show HttpMethod instance Eq HttpVersion instance Ord HttpVersion instance Read HttpVersion instance Show HttpVersion instance Eq Request instance Read Request instance Show Request instance Eq Response instance Read Response instance Show Response instance Show HttpError instance Exception HttpError -- | Enumeratees and other tools. module Network.IHttp.Tools -- | Fully parse a string with the given parser. Throw an iteratee error -- with the given error constructor, if it fails. parseIter :: (Exception ex, Monad m) => Parser b -> (String -> ex) -> ByteString -> Iteratee a m b -- | Fully parse a string with the given parser. parseFull :: Parser a -> ByteString -> Either String a -- | Runs the first computation and then the second, even if the first one -- throws an exception. Iteratee version of finally. iterFinally :: Monad m => Iteratee a m b -> Iteratee a m c -> Iteratee a m b -- | Try the given IO computation and turn IO exceptions into -- iteratee exceptions (Error). iterTry :: MonadIO m => IO b -> Iteratee a m b -- | Turn a method into its corresponding HTTP string. showMethod :: HttpMethod -> ByteString -- | Turn an HTTP version into its corresponding HTTP string. showVersion :: HttpVersion -> ByteString -- | Fast ASCII version of toUpper. asciiToUpper :: Char -> Char -- | HTTP parsers. module Network.IHttp.Parsers -- | Parse an HTTP status code. httpCodeP :: Parser Int -- | Parse first HTTP header line. httpFirstHeaderP :: Parser (ByteString, ByteString) -- | Parse a known HTTP method. httpMethodP :: Parser HttpMethod -- | Parse the given HTTP method. httpMethodP' :: HttpMethod -> Parser HttpMethod -- | Parse an HTTP version in the format HTTP/major.minor. httpVersionP :: Parser HttpVersion -- | Parse the rest of input as a status message. messageP :: Parser ByteString -- | Parse an HTTP request line. requestLineP :: Parser Request -- | Parse an HTTP response line. responseLineP :: Parser Response -- | Iteratees for header parsing. module Network.IHttp.Header -- | Get the next header from the netLinesEmpty-splitted stream. -- The header's content is length-limited by the given argument. If it's -- longer, it's safely truncated in constant space. This iteratee throws -- an iteratee error, if the next lines are not a valid HTTP header or -- the stream ends prematurely. If the next line is an empty line, this -- iteratee returns Nothing. httpHeader :: Monad m => Int -> Iteratee ByteString m (Maybe (ByteString, ByteString)) -- | Get the headers of an HTTP request from a -- netLinesEmpty-splitted byte stream. The first Int -- specifies the maximum length of individual headers. The second -- Int specifies the maximum number of headers. This iteratee -- throws an iteratee error on invalid input, of if the stream ends -- prematurely. -- -- Excess data is truncated safely in constant space. httpHeaders :: Monad m => Int -> Int -> Iteratee ByteString m HeaderMap -- | Enumerate a HeaderMap as a protocol string stream. You can use -- Data.Enumerator.Binary.iterHandle to send it. Note that this -- enumerator never generates continuation lines. It also does not -- enumerate the final empty line. enumHeaders :: Monad m => HeaderMap -> Enumerator ByteString m b -- | Iteratees for requests. module Network.IHttp.Request -- | Get the next full request from a netLinesEmpty-splitted byte -- stream. If the request is invalid or the stream ends prematurely an -- iteratee error is thrown. The first Int specifies the maximum -- header content length. The second Int specifies the maximum -- number of headers. Excess data is truncated safely in constant space. request :: Monad m => Int -> Int -> Iteratee ByteString m Request -- | Get the next request line from a netLinesEmpty-splitted byte -- stream. If the request is invalid or the stream ends prematurely an -- iteratee error is thrown. requestLine :: Monad m => Iteratee ByteString m Request -- | Enumerate a complete request as a protocol string stream. You can use -- Data.Enumerator.Binary.iterHandle to send it. enumRequest :: Monad m => Request -> Enumerator ByteString m b -- | Enumerate a request line with the given method, URI and HTTP version -- as a protocol string stream. You can use -- Data.Enumerator.Binary.iterHandle to send it. enumRequestLine :: Monad m => HttpMethod -> ByteString -> HttpVersion -> Enumerator ByteString m b -- | Iteratees for response. module Network.IHttp.Response -- | Get the next full response from a netLinesEmpty-splitted byte -- stream. If the response is invalid or the stream ends prematurely an -- iteratee error is thrown. The first Int specifies the maximum -- header content length. The second Int specifies the maximum -- number of headers. Excess data is truncated safely in constant space. response :: Monad m => Int -> Int -> Iteratee ByteString m Response -- | Get the next response line form netLinesEmpty-splitted -- stream. If the response line is invalid or the stream ended -- prematurely, then an iteratee error is thrown. responseLine :: Monad m => Iteratee ByteString m Response -- | Enumerate a complete response as a protocol string stream. You can use -- Data.Enumerator.Binary.iterHandle to send it. enumResponse :: Monad m => Response -> Enumerator ByteString m b -- | Enumerate a response line with the given HTTP version, response code -- and message as a protocol string stream. You can use -- Data.Enumerator.Binary.iterHandle to send it. enumResponseLine :: Monad m => HttpVersion -> Int -> ByteString -> Enumerator ByteString m b -- | Simple interface to the HTTP iteratees. module Network.IHttp.Simple -- | HTTP iteratees configuration. data HttpConfig HttpConfig :: Int -> Int -> Int -> HttpConfig -- | Maximum protocol line length. httpMaxLine :: HttpConfig -> Int -- | Maximum header content length. httpMaxHeaderContent :: HttpConfig -> Int -- | Maximum number of headers. httpMaxHeaders :: HttpConfig -> Int -- | Default HTTP iteratee configuration. Other than in very special -- applications you should never need to change these defaults. defHttpConfig :: HttpConfig -- | Get the next full request from the given raw byte stream. getRequest :: Monad m => HttpConfig -> Iteratee ByteString m Request -- | Get the next full response from the given raw byte stream. getResponse :: Monad m => HttpConfig -> Iteratee ByteString m Response -- | Convenience module for the ihttp library. module Network.IHttp