ghcup-0.1.17.10: ghc toolchain installer
Copyright(c) Julian Ospald 2020
LicenseLGPL-3.0
Maintainerhasufell@hasufell.de
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

GHCup.Download

Description

Module for handling all download related functions.

Generally we support downloading via:

  • curl (default)
  • wget
  • internal downloader (only when compiled)
Synopsis

Documentation

getDownloadInfo Source #

Arguments

:: (MonadReader env m, HasPlatformReq env, HasGHCupInfo env) 
=> Tool 
-> Version

tool version

-> Excepts '[NoDownload] m DownloadInfo 

download Source #

Arguments

:: (MonadReader env m, HasSettings env, HasDirs env, MonadMask m, MonadThrow m, HasLog env, MonadIO m) 
=> URI 
-> Maybe URI

URI for gpg sig

-> Maybe Text

expected hash

-> FilePath

destination dir (ignored for file:// scheme)

-> Maybe FilePath

optional filename

-> Bool

whether to read an write etags

-> Excepts '[DigestError, DownloadFailed, GPGError] m FilePath 

Tries to download from the given http or https url and saves the result in continuous memory into a file. If the filename is not provided, then we: 1. try to guess the filename from the url path 2. otherwise create a random file

The file must not exist.

downloadCached Source #

Download into tmpdir or use cached version, if it exists. If filename is omitted, infers the filename from the url.

downloadCached' Source #

Arguments

:: (MonadReader env m, HasDirs env, HasSettings env, MonadMask m, MonadThrow m, HasLog env, MonadIO m, MonadUnliftIO m) 
=> DownloadInfo 
-> Maybe FilePath

optional filename

-> Maybe FilePath

optional destination dir (default: cacheDir)

-> Excepts '[DigestError, DownloadFailed, GPGError] m FilePath 

checkDigest Source #

Arguments

:: (MonadReader env m, HasDirs env, HasSettings env, MonadIO m, MonadThrow m, HasLog env) 
=> Text

the hash

-> FilePath 
-> Excepts '[DigestError] m () 

getCurlOpts :: IO [String] Source #

Get additional curl args from env. This is an undocumented option.

getWgetOpts :: IO [String] Source #

Get additional wget args from env. This is an undocumented option.

getGpgOpts :: IO [String] Source #

Get additional gpg args from env. This is an undocumented option.

urlBaseName Source #

Arguments

:: ByteString

the url path (without scheme and host)

-> ByteString 

Get the url base name.

>>> urlBaseName "/foo/bar/baz"
"baz"

getLastHeader :: Text -> Text Source #

Curl saves all intermediate connect headers as well, not just the last one, so we make an effort to take the last HTTP block only. Passing '--suppress-connect-headers' would be better, but it isn't supported by all versions, also see: https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/213

>>> getLastHeader "\n\nHTTP/1.0 200 Connection established\n\nHTTP/1.1 304 Not Modified\n"
"HTTP/1.1 304 Not Modified\n"
>>> getLastHeader "HTTP/1.1 304 Not Modified\n"
"HTTP/1.1 304 Not Modified\n"