Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Retrieves documents for a URL, supporting multiple URL schemes that can be disabled at build-time for reduced dependencies.
Synopsis
- data Session
- newSession :: IO Session
- fetchURL :: Session -> [String] -> URI -> IO (String, Either Text ByteString)
- fetchURL' :: Session -> [String] -> URI -> IO (URI, String, Either Text ByteString)
- fetchURLs :: Session -> [String] -> [URI] -> ((URI, String, Either Text ByteString) -> IO a) -> IO [(URI, a)]
- submitURL :: Session -> [String] -> URI -> Text -> String -> IO (URI, String, Either Text ByteString)
- submitURL' :: Session -> [String] -> URI -> ByteString -> ByteString -> [(String, Either String FilePath)] -> IO (URI, String, Either Text ByteString)
- mimeERR :: String
- htmlERR :: String
- dispatchByMIME :: Session -> String -> URI -> IO (Maybe String)
- appsForMIME :: Session -> String -> IO [Application]
- data Application = Application {}
- dispatchByApp :: Session -> Application -> String -> URI -> IO Bool
- saveDownload :: URI -> FilePath -> (URI, String, Either Text ByteString) -> IO URI
- downloadToURI :: (URI, String, Either Text ByteString) -> URI
- data LogRecord = LogRecord {}
- enableLogging :: Session -> IO Session
- retrieveLog :: Session -> IO [LogRecord]
- writeLog :: Handle -> Session -> IO ()
Documentation
newSession :: IO Session Source #
Initializes a default Session object to support HTTPS & Accept-Language if HTTP is enabled.
:: Session | The session of which this request is a part. |
-> [String] | The expected MIMEtypes in priority order. |
-> URI | The URL to retrieve |
-> IO (String, Either Text ByteString) | The MIMEtype & possibly text-decoded response. |
Retrieves a URL-identified resource & it's MIMEtype, possibly decoding it's text.
fetchURL' :: Session -> [String] -> URI -> IO (URI, String, Either Text ByteString) Source #
As per fetchURL
, but also returns the redirected URI.
fetchURLs :: Session -> [String] -> [URI] -> ((URI, String, Either Text ByteString) -> IO a) -> IO [(URI, a)] Source #
Concurrently fetch given URLs.
submitURL :: Session -> [String] -> URI -> Text -> String -> IO (URI, String, Either Text ByteString) Source #
See submitURL', preserved for backwards compatability. This is a little more cumbersome to use, & doesn't support file uploads. Was designed naively based on convenience of initial caller.
submitURL' :: Session -> [String] -> URI -> ByteString -> ByteString -> [(String, Either String FilePath)] -> IO (URI, String, Either Text ByteString) Source #
Uploads given key-value pairs to the specified URL using the specified HTTP method & encoding. The key-value pairs may specify filepaths, in which case the method must be POST and the encoding must be "multipart/form-data" for that data to get sent.
Unsupported encodings (values other than "application/x-www-form-urlencoded", "textplain", or "multipartform-data") omits the key-value pairs from the request.
appsForMIME :: Session -> String -> IO [Application] Source #
dispatchByApp :: Session -> Application -> String -> URI -> IO Bool Source #
saveDownload :: URI -> FilePath -> (URI, String, Either Text ByteString) -> IO URI Source #
write download to a file in the given directory.
downloadToURI :: (URI, String, Either Text ByteString) -> URI Source #
Convert a download into a data: URI