@@ -5,7 +5,8 @@ import Data.List ( isPrefixOf )
55import Data.Version ( showVersion )
66import Distribution.Package ( PackageIdentifier(..), PackageName(..) )
77import Distribution.Text
8−import Network.HTTP ( simpleHTTP, getRequest, getResponseBody )
8+import Network.HTTP ( getRequest, rspBody )
9+import Network.Browser ( browse, request, setCheckForProxy, setDebugLog, setOutHandler )
910import System.Directory ( doesFileExist, getHomeDirectory, createDirectoryIfMissing )
1011import System.FilePath ( dropFileName, (</>), (<.>) )
1112import System.Process ( readProcess )
@@ -48,6 +49,15 @@ hashCachePath (PackageIdentifier (PackageName name) version') = do
4849readCabalFile :: FilePath -> IO String
4950readCabalFile path
5051 | "cabal://" `isPrefixOf` path = let Just pid = simpleParse (drop 8 path) in readCabalFile (hackagePath pid Cabal)
51− | "http://" `isPrefixOf` path = simpleHTTP (getRequest path) >>= getResponseBody
52+ | "http://" `isPrefixOf` path = fetchUrl path
5253 | "file://" `isPrefixOf` path = readCabalFile (drop 7 path)
5354 | otherwise = readFile path
55+
56+fetchUrl :: String -> IO String
57+fetchUrl url = do
58+ (_,rsp) <- Network.Browser.browse $ do
59+ setCheckForProxy True
60+ setDebugLog Nothing
61+ setOutHandler (\_ -> return ())
62+ request (getRequest url)
63+ return (rspBody rsp)