-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for client-side HTTP @package HTTP @version 3001.0.0 -- | An library for creating abstract streams. Originally part of -- Gray's\/Bringert's HTTP module. -- -- module Network.Stream -- | Allows stream logging. Refer to debugStream below. data Debug x -- | Streams should make layering of TLS protocol easier in future, they -- allow reading/writing to files etc for debugging, they allow use of -- protocols other than TCP/IP and they allow customisation. -- -- Instances of this class should not trim the input in any way, e.g. -- leave LF on line endings etc. Unless that is exactly the behaviour you -- want from your twisted instances ;) class Stream x readLine :: (Stream x) => x -> IO (Result String) readBlock :: (Stream x) => x -> Int -> IO (Result String) writeBlock :: (Stream x) => x -> String -> IO (Result ()) close :: (Stream x) => x -> IO () -- | Wraps a stream with logging I/O, the first argument is a filename -- which is opened in AppendMode. debugStream :: (Stream a) => String -> a -> IO (Debug a) data ConnError ErrorReset :: ConnError ErrorClosed :: ConnError ErrorParse :: String -> ConnError ErrorMisc :: String -> ConnError -- | This is the type returned by many exported network functions. type Result a = Either ConnError a handleSocketError :: Socket -> Exception -> IO (Result a) bindE :: Either ConnError a -> (a -> Either ConnError b) -> Either ConnError b myrecv :: Socket -> Int -> IO String instance Show ConnError instance Eq ConnError instance (Stream x) => Stream (Debug x) instance Stream Socket -- | An easy access TCP library. Makes the use of TCP in Haskell much -- easier. This was originally part of Gray's\/Bringert's HTTP module. -- -- module Network.TCP -- | The Conn object allows input buffering, and maintenance of some -- admin-type data. data Conn MkConn :: !Socket -> !SockAddr -> !String -> String -> Conn connSock :: Conn -> !Socket connAddr :: Conn -> !SockAddr connBffr :: Conn -> !String connHost :: Conn -> String ConnClosed :: Conn -- | The Connection newtype is a wrapper that allows us to make -- connections an instance of the StreamIn/Out classes, without ghc -- extensions. While this looks sort of like a generic reference to the -- transport layer it is actually TCP specific, which can be seen in the -- implementation of the 'Stream Connection' instance. newtype Connection ConnRef :: IORef Conn -> Connection getRef :: Connection -> IORef Conn -- | Open a connection to port 80 on a remote host. openTCP :: String -> IO Connection -- | This function establishes a connection to a remote host, it uses -- getHostByName which interrogates the DNS system, hence may -- trigger a network connection. -- -- Add a persistant option? Current persistant is default. Use -- Result type for synchronous exception reporting? openTCPPort :: String -> Int -> IO Connection -- | Checks both that the underlying Socket is connected and that the -- connection peer matches the given host name (which is recorded -- locally). isConnectedTo :: Connection -> String -> IO Bool instance Eq Conn instance Stream Connection -- | An easy HTTP interface enjoy. -- -- -- -- -- -- -- -- module Network.HTTP httpVersion :: String -- | An HTTP Request. The Show instance of this type is used for -- message serialisation, which means no body data is output. data Request Request :: URI -> RequestMethod -> [Header] -> String -> Request -- | might need changing in future 1) to support * uri in OPTIONS -- request 2) transparent support for both relative & absolute uris, -- although this should already work (leave scheme & host parts -- empty). rqURI :: Request -> URI rqMethod :: Request -> RequestMethod rqHeaders :: Request -> [Header] rqBody :: Request -> String -- | An HTTP Response. The Show instance of this type is used for -- message serialisation, which means no body data is output, -- additionally the output will show an HTTP version of 1.1 instead of -- the actual version returned by a server. data Response Response :: ResponseCode -> String -> [Header] -> String -> Response rspCode :: Response -> ResponseCode rspReason :: Response -> String rspHeaders :: Response -> [Header] rspBody :: Response -> String -- | The HTTP request method, to be used in the Request object. We -- are missing a few of the stranger methods, but these are not really -- necessary until we add full TLS. data RequestMethod HEAD :: RequestMethod PUT :: RequestMethod GET :: RequestMethod POST :: RequestMethod DELETE :: RequestMethod OPTIONS :: RequestMethod TRACE :: RequestMethod type ResponseCode = (Int, Int, Int) -- | Simple way to get a resource across a non-persistant connection. -- Headers that may be altered: Host Altered only if no Host header is -- supplied, HTTP/1.1 requires a Host header. Connection Where no -- allowance is made for persistant connections the Connection header -- will be set to close simpleHTTP :: Request -> IO (Result Response) -- | Like simpleHTTP, but acting on an already opened stream. simpleHTTP_ :: (Stream s) => s -> Request -> IO (Result Response) sendHTTP :: (Stream s) => s -> Request -> IO (Result Response) -- | Receive and parse a HTTP request from the given Stream. Should be used -- for server side interactions. receiveHTTP :: (Stream s) => s -> IO (Result Request) -- | Very simple function, send a HTTP response over the given stream. This -- could be improved on to use different transfer types. respondHTTP :: (Stream s) => s -> Response -> IO () -- | This class allows us to write generic header manipulation functions -- for both Request and Response data types. class HasHeaders x -- | The Header data type pairs header names & values. data Header Header :: HeaderName -> String -> Header -- | HTTP Header Name type: Why include this at all? I have some reasons 1) -- prevent spelling errors of header names, 2) remind everyone of what -- headers are available, 3) might speed up searches for specific -- headers. -- -- Arguments against: 1) makes customising header names laborious 2) -- increases code volume. 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 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 HdrContentTransferEncoding :: HeaderName -- | Allows for unrecognised or experimental headers. HdrCustom :: String -> HeaderName insertHeader :: (HasHeaders a) => HeaderName -> String -> a -> a insertHeaderIfMissing :: (HasHeaders a) => HeaderName -> 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. insertHeaders :: (HasHeaders a) => [Header] -> a -> a -- | Gets a list of headers with a particular HeaderName. retrieveHeaders :: (HasHeaders a) => HeaderName -> a -> [Header] replaceHeader :: (HasHeaders a) => HeaderName -> String -> a -> a -- | Lookup presence of specific HeaderName in a list of Headers Returns -- the value from the first matching header. findHeader :: (HasHeaders a) => HeaderName -> a -> Maybe String urlEncode :: String -> String urlDecode :: String -> String urlEncodeVars :: [(String, String)] -> String data URIAuthority URIAuthority :: Maybe String -> Maybe String -> String -> Maybe Int -> URIAuthority user :: URIAuthority -> Maybe String password :: URIAuthority -> Maybe String host :: URIAuthority -> String port :: URIAuthority -> Maybe Int -- | Parse the authority part of a URL. -- --
--   RFC 1732, section 3.1:
--   
--         //<user>:<password>@<host>:<port>/<url-path>
--    Some or all of the parts "<user>:<password>@", ":<password>",
--    ":<port>", and "/<url-path>" may be excluded.
--   
parseURIAuthority :: String -> Maybe URIAuthority instance Show RequestMethod instance Eq RequestMethod instance Eq HeaderName instance Eq URIAuthority instance Show URIAuthority instance HasHeaders Response instance Show Response instance HasHeaders Request instance Show Request instance Show HeaderName instance Show Header -- | An HTTP/1.1 compatible wrapper for the HTTP module. module Network.Browser data BrowserState data BrowserAction a data Cookie data Form Form :: RequestMethod -> URI -> [FormVar] -> Form -- | Specifies if a proxy should be used for the request. data Proxy -- | Don't use a proxy. NoProxy :: Proxy -- | Use the proxy given. Should be of the form http://host:port, -- host, host:port, or http://host Proxy :: String -> (Maybe Authority) -> Proxy -- | Apply a browser action to a state. browse :: BrowserAction a -> IO a request :: Request -> BrowserAction (URI, Response) setAllowRedirects :: Bool -> BrowserAction () getAllowRedirects :: BrowserAction Bool data Authority AuthBasic :: String -> String -> String -> URI -> Authority auRealm :: Authority -> String auUsername :: Authority -> String auPassword :: Authority -> String auSite :: Authority -> URI AuthDigest :: String -> String -> String -> String -> Maybe Algorithm -> [URI] -> Maybe String -> [Qop] -> Authority auRealm :: Authority -> String auUsername :: Authority -> String auPassword :: Authority -> String auNonce :: Authority -> String auAlgorithm :: Authority -> Maybe Algorithm auDomain :: Authority -> [URI] auOpaque :: Authority -> Maybe String auQop :: Authority -> [Qop] -- | Interacting with browser state: getAuthorities :: BrowserAction [Authority] setAuthorities :: [Authority] -> BrowserAction () addAuthority :: Authority -> BrowserAction () getAuthorityGen :: BrowserAction (URI -> String -> IO (Maybe (String, String))) setAuthorityGen :: (URI -> String -> IO (Maybe (String, String))) -> BrowserAction () setAllowBasicAuth :: Bool -> BrowserAction () setCookieFilter :: (URI -> Cookie -> IO Bool) -> BrowserAction () defaultCookieFilter :: URI -> Cookie -> IO Bool userCookieFilter :: URI -> Cookie -> IO Bool getCookies :: BrowserAction [Cookie] setCookies :: [Cookie] -> BrowserAction () -- | Adds a cookie to the browser state, removing duplicates. addCookie :: Cookie -> BrowserAction () setErrHandler :: (String -> IO ()) -> BrowserAction () setOutHandler :: (String -> IO ()) -> BrowserAction () setProxy :: Proxy -> BrowserAction () setDebugLog :: Maybe String -> BrowserAction () out :: String -> BrowserAction () err :: String -> BrowserAction () -- | Do an io action ioAction :: IO a -> BrowserAction a defaultGETRequest :: URI -> Request formToRequest :: Form -> Request -- | Returns a URI that is consistent with the first argument uri when read -- in the context of a second. If second argument is not sufficient -- context for determining a full URI then anarchy reins. uriDefaultTo :: URI -> URI -> URI uriTrimHost :: URI -> URI instance Eq Qop instance Show Qop instance Eq Algorithm instance Show Cookie instance Read Cookie instance Functor BrowserAction instance Monad BrowserAction instance Show BrowserState instance Show Algorithm instance Eq Cookie