Safe Haskell | None |
---|
- urlGetContents :: String -> IO ByteString
- urlGetContentsPost :: String -> ByteString -> IO ByteString
- download :: Downloader -> String -> Maybe HostAddress -> DownloadOptions -> IO DownloadResult
- post :: Downloader -> String -> Maybe HostAddress -> ByteString -> IO DownloadResult
- downloadG :: (Request -> ResourceT IO Request) -> Downloader -> String -> Maybe HostAddress -> DownloadOptions -> IO DownloadResult
- data DownloadResult
- = DROK ByteString DownloadOptions
- | DRRedirect String
- | DRError String
- | DRNotModified
- type DownloadOptions = [String]
- data DownloaderSettings = DownloaderSettings {
- dsUserAgent :: ByteString
- dsTimeout :: Int
- dsManagerSettings :: ManagerSettings
- dsMaxDownloadSize :: Int
- data Downloader
- withDownloader :: (Downloader -> IO a) -> IO a
- withDownloaderSettings :: DownloaderSettings -> (Downloader -> IO a) -> IO a
- newDownloader :: DownloaderSettings -> IO Downloader
- postRequest :: ByteString -> Request -> Request
- sinkByteString :: MonadIO m => Int -> Sink ByteString m (Maybe ByteString)
Download operations
urlGetContents :: String -> IO ByteStringSource
Download single URL with default DownloaderSettings
.
Fails if result is not DROK
.
urlGetContentsPost :: String -> ByteString -> IO ByteStringSource
Post data and download single URL with default DownloaderSettings
.
Fails if result is not DROK
.
:: Downloader | |
-> String | URL |
-> Maybe HostAddress | Optional resolved |
-> DownloadOptions | |
-> IO DownloadResult |
Perform download
post :: Downloader -> String -> Maybe HostAddress -> ByteString -> IO DownloadResultSource
Perform HTTP POST.
:: (Request -> ResourceT IO Request) | Function to modify |
-> Downloader | |
-> String | URL |
-> Maybe HostAddress | Optional resolved |
-> DownloadOptions | |
-> IO DownloadResult |
Generic version of download
with ability to modify http-conduit Request
.
data DownloadResult Source
Result of download
operation.
DROK ByteString DownloadOptions | Successful download with data and options for next download. |
DRRedirect String | Redirect URL |
DRError String | Error |
DRNotModified | HTTP 304 Not Modified |
Eq DownloadResult | |
Read DownloadResult | |
Show DownloadResult |
type DownloadOptions = [String]Source
If-None-Match
and/or If-Modified-Since
headers.
Downloader
data DownloaderSettings Source
Settings used in downloader.
DownloaderSettings | |
|
data Downloader Source
Keeps http-conduit Manager
and DownloaderSettings
.
withDownloader :: (Downloader -> IO a) -> IO aSource
Create a new Downloader
, use it in the provided function,
and then release it.
withDownloaderSettings :: DownloaderSettings -> (Downloader -> IO a) -> IO aSource
Create a new Downloader
with provided settings,
use it in the provided function, and then release it.
newDownloader :: DownloaderSettings -> IO DownloaderSource
Create a Downloader
with settings.
Utils
postRequest :: ByteString -> Request -> RequestSource
Make HTTP POST request.
sinkByteString :: MonadIO m => Int -> Sink ByteString m (Maybe ByteString)Source
Sink data using 32k buffers to reduce memory fragmentation.
Returns Nothing
if downloaded too much data.