diff options
author | Joey Hess <joey@kitenet.net> | 2013-09-28 14:35:21 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-09-28 14:35:21 -0400 |
commit | a05cefbd7cdfc75109d8f55c4cb699352745841c (patch) | |
tree | a3d10d759b00a2c00340d352827fe9d287bed07c /Remote | |
parent | 309750f7588d7c9a6eadbdd30b630250f766311f (diff) |
Send a git-annex user-agent when downloading urls.
Overridable with --user-agent option.
Not yet done for S3 or WebDAV due to limitations of libraries used --
nether allows a user-agent header to be specified.
This commit sponsored by Michael Zehrer.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/Git.hs | 7 | ||||
-rw-r--r-- | Remote/Web.hs | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs index 7083de667..0f3f35811 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -30,7 +30,7 @@ import Annex.Exception import qualified Annex.Content import qualified Annex.BranchState import qualified Annex.Branch -import qualified Utility.Url as Url +import qualified Annex.Url as Url import Utility.Tmp import Config import Config.Cost @@ -177,9 +177,10 @@ tryGitConfigRead r Left l -> return $ Left l geturlconfig headers = do + ua <- Url.getUserAgent v <- liftIO $ withTmpFile "git-annex.tmp" $ \tmpfile h -> do hClose h - ifM (Url.downloadQuiet (Git.repoLocation r ++ "/config") headers [] tmpfile) + ifM (Url.downloadQuiet (Git.repoLocation r ++ "/config") headers [] tmpfile ua) ( pipedconfig "git" [Param "config", Param "--null", Param "--list", Param "--file", File tmpfile] , return $ Left undefined ) @@ -240,7 +241,7 @@ inAnnex r key where checkhttp headers = do showChecking r - liftIO $ ifM (anyM (\u -> Url.check u headers (keySize key)) (keyUrls r key)) + ifM (anyM (\u -> Url.withUserAgent $ Url.check u headers (keySize key)) (keyUrls r key)) ( return $ Right True , return $ Left "not found" ) diff --git a/Remote/Web.hs b/Remote/Web.hs index 789aab698..af60beee0 100644 --- a/Remote/Web.hs +++ b/Remote/Web.hs @@ -19,7 +19,7 @@ import Config.Cost import Logs.Web import Types.Key import Utility.Metered -import qualified Utility.Url as Url +import qualified Annex.Url as Url #ifdef WITH_QUVI import Annex.Quvi import qualified Utility.Quvi as Quvi @@ -118,7 +118,7 @@ checkKey' key us = firsthit us (Right False) $ \u -> do #endif DefaultDownloader -> do headers <- getHttpHeaders - liftIO $ Right <$> Url.check u' headers (keySize key) + Right <$> Url.withUserAgent (Url.check u' headers $ keySize key) where firsthit [] miss _ = return miss firsthit (u:rest) _ a = do |