aboutsummaryrefslogtreecommitdiff
path: root/CLPM/Repository.icl
diff options
context:
space:
mode:
authorCamil Staps2017-02-06 22:54:04 +0100
committerCamil Staps2017-02-06 22:54:04 +0100
commitbf30b006c94358707756b13ae452452e52769f8f (patch)
tree116b0684bf4b17cda26e3d25f14b1483e954ebd7 /CLPM/Repository.icl
parentAdded help text (diff)
Add very basic installation task
Diffstat (limited to 'CLPM/Repository.icl')
-rw-r--r--CLPM/Repository.icl28
1 files changed, 7 insertions, 21 deletions
diff --git a/CLPM/Repository.icl b/CLPM/Repository.icl
index 587715f..d0b089d 100644
--- a/CLPM/Repository.icl
+++ b/CLPM/Repository.icl
@@ -5,8 +5,6 @@ import StdClass
from StdFunc import flip, o
import StdOverloaded
-import TCPIP
-
import Control.Applicative
import Control.Monad
@@ -22,37 +20,25 @@ from Text import instance + String
import Text.JSON
import CLPM.Package
+import CLPM.Util
derive JSONDecode RepositoryItem, RepositoryItemVersion
getRepository :: Url *World -> *(MaybeErrorString Repository, *World)
getRepository repo w
-# (ip,w) = lookupIPAddress repo w
-| isNothing ip
- = (Error $ "DNS lookup for " + repo + " failed.", w)
-# (Just ip) = ip
-# (rpt,chan,w) = connectTCP_MT (Just TIMEOUT) (ip, PORT) w
-| rpt == TR_Expired
- = (Error $ "Connection to " + repo + " timed out.", w)
-| rpt == TR_NoSuccess
- = (Error $ "Could not connect to " + repo + ".", w)
-# (Just {sChannel,rChannel}) = chan
-# (rpt,i,sChannel,w) = send_MT (Just TIMEOUT) req sChannel w
-| rpt <> TR_Success
- = (Error $ "Could not request repository from " + repo + ".", w)
-# (resp,rChannel,w) = appFst3 (parseResponse o toString) $ receive rChannel w
-| isNothing resp
- = (Error $ "Server did not respond with HTTP.", w)
-# repo = fromJSON $ fromString (fromJust resp).rsp_data
+# (resp,w) = doRequest req w
+| isError resp
+ = (Error $ fromError resp, w)
+# repo = fromJSON $ fromString (fromOk resp).rsp_data
| isNothing repo
= (Error $ "Server did not return a repository.", w)
-# w = closeChannel sChannel (closeRChannel rChannel w)
= (Ok $ fromJust repo, w)
where
- req = toByteSeq
+ req =
{ newHTTPRequest
& req_path = "/list.php"
, server_name = REPOSITORY
+ , server_port = PORT
}
getVersions :: (PackageName Repository -> [RepositoryItemVersion])