http-download- Verified downloads with retries

Safe HaskellNone





verifiedDownload Source #


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


-> (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

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.

recoveringHttp :: forall env a. HasTerm env => RetryPolicy -> RIO env a -> RIO env a Source #

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

DownloadRequest construction

data DownloadRequest Source #

A request together with some checks to perform.

Construct using the downloadRequest smart constructor and associated setters. The constructor itself is not exposed to avoid breaking changes with additional fields.


mkDownloadRequest :: Request -> DownloadRequest Source #

Construct a new DownloadRequest from the given Request. Use associated setters to modify the value further.


modifyRequest :: (Request -> Request) -> DownloadRequest -> DownloadRequest Source #

Modify the Request inside a DownloadRequest. Especially intended for modifying the User-Agent request header.


setHashChecks :: [HashCheck] -> DownloadRequest -> DownloadRequest Source #

Set the hash checks to be run when verifying.


setLengthCheck :: Maybe LengthCheck -> DownloadRequest -> DownloadRequest Source #

Set the length check to be run when verifying.


setRetryPolicy :: RetryPolicy -> DownloadRequest -> DownloadRequest Source #

Set the retry policy to be used when downloading.


setForceDownload :: Bool -> DownloadRequest -> DownloadRequest Source #

If True, force download even if the file already exists. Useful for download a resource which may change over time.