make it easier to use curl for unusual url schemes

Use curl when annex.security.allowed-url-schemes includes an url scheme not
supported by git-annex internally, as long as
annex.security.allowed-ip-addresses is configured to allow using curl.

Sponsored-by: Luke Shumaker on Patreon
This commit is contained in:
Joey Hess 2022-08-15 12:22:01 -04:00
parent 2fc9a0096f
commit 840bd50390
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 37 additions and 4 deletions

View file

@ -1,6 +1,6 @@
{- Url downloading.
-
- Copyright 2011-2021 Joey Hess <id@joeyh.name>
- Copyright 2011-2022 Joey Hess <id@joeyh.name>
-
- License: BSD-2-clause
-}
@ -40,6 +40,7 @@ module Utility.Url (
noBasicAuth,
applyBasicAuth',
extractFromResourceT,
conduitUrlSchemes,
) where
import Common
@ -111,10 +112,13 @@ defUrlOptions = UrlOptions
<*> pure (DownloadWithConduit (DownloadWithCurlRestricted mempty))
<*> pure id
<*> newManager tlsManagerSettings
<*> pure (S.fromList $ map mkScheme ["http", "https", "ftp"])
<*> pure conduitUrlSchemes
<*> pure Nothing
<*> pure noBasicAuth
conduitUrlSchemes :: S.Set Scheme
conduitUrlSchemes = S.fromList $ map mkScheme ["http", "https", "ftp"]
mkUrlOptions :: Maybe UserAgent -> Headers -> UrlDownloader -> Manager -> S.Set Scheme -> Maybe (URI -> String) -> GetBasicAuth -> UrlOptions
mkUrlOptions defuseragent reqheaders urldownloader =
UrlOptions useragent reqheaders urldownloader applyrequest