Safe Haskell | None |
---|---|
Language | Haskell2010 |
A library for listing "files" in an http "directory".
import Network.HTTP.Directory import qualified Data.Text as T main = do mgr <- httpManager files <- httpDirectory mgr "https://example.com/some/dir/" mapM_ T.putStrLn files httpFileSize mgr (head files) >>= print httpLastModified mgr (head files) >>= print
Synopsis
- httpDirectory :: Manager -> String -> IO [Text]
- httpDirectory' :: String -> IO [Text]
- httpRawDirectory :: Manager -> String -> IO [Text]
- httpExists :: Manager -> String -> IO Bool
- httpFileSize :: Manager -> String -> IO (Maybe Integer)
- httpLastModified :: Manager -> String -> IO (Maybe UTCTime)
- httpManager :: IO Manager
- httpRedirect :: Manager -> String -> IO (Maybe ByteString)
- httpRedirect' :: String -> IO (Maybe ByteString)
- httpRedirects :: Manager -> String -> IO [ByteString]
Documentation
httpDirectory :: Manager -> String -> IO [Text] Source #
List the file links (hrefs) in an http directory
Raises an error if the http request fails.
Note if the directory (webpage) url is redirected to a different path
you may need to use httpRedirect
to determine
the actual final url prefix for relative links
(files).
(Filters "non-files/subdirs" @since 0.1.4 (before that was just httpRawDirectory)
httpRawDirectory :: Manager -> String -> IO [Text] Source #
List all the hrefs in an http directory html file.
Raises an error if the http request fails.
Note if the directory (webpage) url is redirected to a different path
you may need to use httpRedirect
to determine
the actual final url prefix for relative links
(files).
Since: 0.1.4
httpFileSize :: Manager -> String -> IO (Maybe Integer) Source #
Try to get the filesize (Content-Length field) of an http file
Raises an error if the http request fails.
httpLastModified :: Manager -> String -> IO (Maybe UTCTime) Source #
Try to get the modification time (Last-Modified field) of an http file
Raises an error if the http request fails.
Since: 0.1.1
httpManager :: IO Manager Source #
alias for 'newManager tlsManagerSettings' so one does not need to import http-client etc
Since: 0.1.2
httpRedirect :: Manager -> String -> IO (Maybe ByteString) Source #
Return final redirect for an url
httpRedirect' :: String -> IO (Maybe ByteString) Source #
Like httpRedirect but uses own Manager.
Since: 0.1.4
httpRedirects :: Manager -> String -> IO [ByteString] Source #
Returns the list of http redirects for an url in reverse order (ie last redirect is listed first)