| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.HTTP.Download.Verified
- verifiedDownload :: (MonadReader env m, HasHttpManager env, MonadIO m) => DownloadRequest -> Path Abs File -> Sink ByteString (ReaderT env IO) () -> m Bool
- data DownloadRequest = DownloadRequest {
- drRequest :: Request
- drHashChecks :: [HashCheck]
- drLengthCheck :: Maybe LengthCheck
- data HashCheck = forall a . (Show a, HashAlgorithm a) => HashCheck {}
- data CheckHexDigest
- type LengthCheck = Int
- data VerifiedDownloadException
- = WrongContentLength Request Int ByteString
- | WrongStreamLength Request Int Int
- | WrongDigest Request String CheckHexDigest String
Documentation
Arguments
| :: (MonadReader env m, HasHttpManager env, MonadIO m) | |
| => DownloadRequest | |
| -> Path Abs File | destination |
| -> Sink ByteString (ReaderT env IO) () | custom hook to observe progress |
| -> m Bool | Whether a download was performed |
Copied and extended version of Network.HTTP.Download.download.
Has the following additional features: * Verifies that response content-length header (if present) matches expected length * Limits the download to (close to) the expected # of bytes * Verifies that the expected # bytes were downloaded (not too few) * Verifies md5 if response includes content-md5 header * Verifies the expected hashes
Throws VerifiedDownloadException, and whatever else "download" throws.
data DownloadRequest Source
A request together with some checks to perform.
Constructors
| DownloadRequest | |
Fields
| |
Instances
data CheckHexDigest Source
Constructors
| CheckHexDigestString String | |
| CheckHexDigestByteString ByteString | |
| CheckHexDigestHeader ByteString |
Instances
type LengthCheck = Int Source
data VerifiedDownloadException Source
An exception regarding verification of a download.
Constructors
| WrongContentLength Request Int ByteString | |
| WrongStreamLength Request Int Int | |
| WrongDigest Request String CheckHexDigest String |