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.
This commit is contained in:
parent
55362462ae
commit
12f6b9693a
14 changed files with 90 additions and 36 deletions
|
@ -17,7 +17,7 @@ import Data.Time.Clock
|
|||
import Common.Annex
|
||||
import qualified Annex
|
||||
import Command
|
||||
import qualified Utility.Url as Url
|
||||
import qualified Annex.Url as Url
|
||||
import Logs.Web
|
||||
import qualified Option
|
||||
import qualified Utility.Format
|
||||
|
@ -102,9 +102,10 @@ findEnclosures url = extract <$> downloadFeed url
|
|||
downloadFeed :: URLString -> Annex (Maybe Feed)
|
||||
downloadFeed url = do
|
||||
showOutput
|
||||
ua <- Url.getUserAgent
|
||||
liftIO $ withTmpFile "feed" $ \f h -> do
|
||||
fileEncoding h
|
||||
ifM (Url.download url [] [] f)
|
||||
ifM (Url.download url [] [] f ua)
|
||||
( liftIO $ parseFeedString <$> hGetContentsStrict h
|
||||
, return Nothing
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue