diff options
author | Richard Hartmann <richih@debian.org> | 2014-02-25 12:38:25 +0100 |
---|---|---|
committer | Richard Hartmann <richih@debian.org> | 2014-02-25 12:38:25 +0100 |
commit | d1147087b30b67a139e51235e977be27dc69765d (patch) | |
tree | 81898d4b8fd8ec569ddcc6150406866682fdb1ff /Annex/Url.hs | |
parent | 5fea20f32fbeba57b3be8f57b2a6f11da05641db (diff) | |
parent | 6cc6cf01d1644df543d3e264d3f9ddb44e64424b (diff) |
Merge branch 'master' of git://git-annex.branchable.com
Diffstat (limited to 'Annex/Url.hs')
-rw-r--r-- | Annex/Url.hs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/Annex/Url.hs b/Annex/Url.hs index 0401ffe07..397a7910b 100644 --- a/Annex/Url.hs +++ b/Annex/Url.hs @@ -1,13 +1,15 @@ -{- Url downloading, with git-annex user agent. +{- Url downloading, with git-annex user agent and configured http + - headers and wget/curl options. - - - Copyright 2013 Joey Hess <joey@kitenet.net> + - Copyright 2013-2014 Joey Hess <joey@kitenet.net> - - Licensed under the GNU GPL version 3 or higher. -} module Annex.Url ( module U, - withUserAgent, + withUrlOptions, + getUrlOptions, getUserAgent, ) where @@ -23,5 +25,18 @@ getUserAgent :: Annex (Maybe U.UserAgent) getUserAgent = Annex.getState $ Just . fromMaybe defaultUserAgent . Annex.useragent -withUserAgent :: (Maybe U.UserAgent -> IO a) -> Annex a -withUserAgent a = liftIO . a =<< getUserAgent +getUrlOptions :: Annex U.UrlOptions +getUrlOptions = U.UrlOptions + <$> getUserAgent + <*> headers + <*> options + where + headers = do + v <- annexHttpHeadersCommand <$> Annex.getGitConfig + case v of + Just cmd -> lines <$> liftIO (readProcess "sh" ["-c", cmd]) + Nothing -> annexHttpHeaders <$> Annex.getGitConfig + options = map Param . annexWebOptions <$> Annex.getGitConfig + +withUrlOptions :: (U.UrlOptions -> IO a) -> Annex a +withUrlOptions a = liftIO . a =<< getUrlOptions |