@@ -25,14 +25,7 @@ module Distribution.Client
2525 , requestGET'
2626 , requestPUT
2727 , (<//>)
28- -- * TODO: Exported although they appear unused
29- , extractURICredentials
30- , removeURICredentials
3128 , getETag
32- , downloadFile'
33- , requestGET
34- , requestPUTFile
35- , requestPOST
3629 , checkStatus
3730 ) where
3831
@@ -226,20 +219,6 @@ infixr 5 <//>
226219uri <//> path = uri { uriPath = Posix. addTrailingPathSeparator (uriPath uri)
227220 Posix. </> path }
228221
229-
230- extractURICredentials :: URI -> Maybe (String , String )
231- extractURICredentials uri
232- | Just authority <- uriAuthority uri
233- , (username, ' :' : passwd0) <- break (== ' :' ) (uriUserInfo authority)
234- , let passwd = takeWhile (/= ' @' ) passwd0
235- , not (null username)
236- , not (null passwd)
237- = Just (username, passwd)
238- extractURICredentials _ = Nothing
239-
240- removeURICredentials :: URI -> URI
241- removeURICredentials uri = uri { uriAuthority = fmap (\ auth -> auth { uriUserInfo = " " }) (uriAuthority uri) }
242-
243222uriHostName :: URI -> Maybe String
244223uriHostName = fmap uriRegName . uriAuthority
245224
@@ -361,28 +340,6 @@ unquote ('"':s) = go s
361340 go (c: cs) = c : go cs
362341unquote s = s
363342
364- -- AAARG! total lack of exception handling in HTTP monad!
365- downloadFile' :: URI -> FilePath -> HttpSession Bool
366- downloadFile' uri file = do
367- liftIO $ putStrLn $ " downloading " ++ show uri ++ " to " ++ file
368- mcontent <- requestGET' uri
369- case mcontent of
370- Nothing -> do liftIO $ putStrLn $ " 404 " ++ show uri
371- return False
372-
373- Just content -> do liftIO $ BS. writeFile file content
374- return True
375-
376- requestGET :: URI -> HttpSession ByteString
377- requestGET uri = do
378- req <- mkRequest " GET" headers uri
379- runRequest req $ \ rsp -> do
380- rsp' <- responseReadBSL rsp
381- checkStatus uri rsp'
382- return (responseBody rsp')
383- where
384- headers = []
385-
386343-- | Like 'requestGET' but return @Nothing@ on 404 status.
387344requestGET' :: URI -> HttpSession (Maybe ByteString )
388345requestGET' uri = do
@@ -396,18 +353,9 @@ requestGET' uri = do
396353 where
397354 headers = []
398355
399- requestPUTFile :: URI -> String -> Maybe String -> FilePath -> HttpSession ()
400- requestPUTFile uri mime_type mEncoding file = do
401- content <- liftIO $ BS. readFile file
402- requestPUT uri mime_type mEncoding content
403-
404- requestPOST , requestPUT :: URI -> String -> Maybe String -> ByteString -> HttpSession ()
405- requestPOST = requestPOSTPUT " POST"
406- requestPUT = requestPOSTPUT " PUT"
407-
408- requestPOSTPUT :: Method -> URI -> String -> Maybe String -> ByteString -> HttpSession ()
409- requestPOSTPUT meth uri mimetype mEncoding body = do
410- req <- mkUploadRequest meth uri mimetype mEncoding [] body
356+ requestPUT :: URI -> String -> Maybe String -> ByteString -> HttpSession ()
357+ requestPUT uri mimetype mEncoding body = do
358+ req <- mkUploadRequest " PUT" uri mimetype mEncoding [] body
411359 runRequest req $ \ rsp -> do
412360 rsp' <- responseReadBSL rsp
413361 checkStatus uri rsp'
0 commit comments