@@ -25,14 +25,7 @@ module Distribution.Client
25
25
, requestGET'
26
26
, requestPUT
27
27
, (<//>)
28
- -- * TODO: Exported although they appear unused
29
- , extractURICredentials
30
- , removeURICredentials
31
28
, getETag
32
- , downloadFile'
33
- , requestGET
34
- , requestPUTFile
35
- , requestPOST
36
29
, checkStatus
37
30
) where
38
31
@@ -226,20 +219,6 @@ infixr 5 <//>
226
219
uri <//> path = uri { uriPath = Posix. addTrailingPathSeparator (uriPath uri)
227
220
Posix. </> path }
228
221
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
-
243
222
uriHostName :: URI -> Maybe String
244
223
uriHostName = fmap uriRegName . uriAuthority
245
224
@@ -361,28 +340,6 @@ unquote ('"':s) = go s
361
340
go (c: cs) = c : go cs
362
341
unquote s = s
363
342
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
-
386
343
-- | Like 'requestGET' but return @Nothing@ on 404 status.
387
344
requestGET' :: URI -> HttpSession (Maybe ByteString )
388
345
requestGET' uri = do
@@ -396,18 +353,9 @@ requestGET' uri = do
396
353
where
397
354
headers = []
398
355
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
411
359
runRequest req $ \ rsp -> do
412
360
rsp' <- responseReadBSL rsp
413
361
checkStatus uri rsp'
0 commit comments