http-download-0.1.0.1: Verified downloads with retries

Safe HaskellNone
LanguageHaskell2010

Network.HTTP.Download

Synopsis

Documentation

data DownloadRequest Source #

A request together with some checks to perform.

drRetryPolicyDefault :: RetryPolicy Source #

Default to retrying seven times with exponential backoff starting from one hundred milliseconds.

This means the tries will occur after these delays if necessary:

  • 0.1s
  • 0.2s
  • 0.4s
  • 0.8s
  • 1.6s
  • 3.2s
  • 6.4s

data HashCheck Source #

Constructors

(Show a, HashAlgorithm a) => HashCheck 
Instances
Show HashCheck Source # 
Instance details

Defined in Network.HTTP.Download.Verified

Methods

showsPrec :: Int -> HashCheck -> ShowS

show :: HashCheck -> String

showList :: [HashCheck] -> ShowS

data DownloadException Source #

Constructors

RedownloadInvalidResponse Request (Path Abs File) (Response ()) 
RedownloadHttpError HttpException 
Instances
Show DownloadException Source # 
Instance details

Defined in Network.HTTP.Download

Methods

showsPrec :: Int -> DownloadException -> ShowS

show :: DownloadException -> String

showList :: [DownloadException] -> ShowS

Exception DownloadException Source # 
Instance details

Defined in Network.HTTP.Download

Methods

toException :: DownloadException -> SomeException

fromException :: SomeException -> Maybe DownloadException

displayException :: DownloadException -> String

data CheckHexDigest Source #

Constructors

CheckHexDigestString String 
CheckHexDigestByteString ByteString 
CheckHexDigestHeader ByteString 
Instances
Show CheckHexDigest Source # 
Instance details

Defined in Network.HTTP.Download.Verified

Methods

showsPrec :: Int -> CheckHexDigest -> ShowS

show :: CheckHexDigest -> String

showList :: [CheckHexDigest] -> ShowS

IsString CheckHexDigest Source # 
Instance details

Defined in Network.HTTP.Download.Verified

Methods

fromString :: String -> CheckHexDigest

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 

download Source #

Arguments

:: HasTerm env 
=> Request 
-> Path Abs File

destination

-> RIO env Bool

Was a downloaded performed (True) or did the file already exist (False)?

Download the given URL to the given location. If the file already exists, no download is performed. Otherwise, creates the parent directory, downloads to a temporary file, and on file download completion moves to the appropriate destination.

Throws an exception if things go wrong

redownload Source #

Arguments

:: HasTerm env 
=> Request 
-> Path Abs File

destination

-> RIO env Bool 

Same as download, but will download a file a second time if it is already present.

Returns True if the file was downloaded, False otherwise

verifiedDownload Source #

Arguments

:: HasTerm env 
=> DownloadRequest 
-> Path Abs File

destination

-> (Maybe Integer -> ConduitM ByteString Void (RIO env) ())

custom hook to observe progress

-> RIO env 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. Throws IOExceptions related to file system operations. Throws HttpException.