From: Ramakrishnan Muthukrishnan Date: Fri, 2 Oct 2015 09:15:08 +0000 (+0530) Subject: Network.httpget -> Network.sendGetRequest X-Git-Url: https://git.rkrishnan.org/specifications/%5B/%5D%20/-?a=commitdiff_plain;h=1fee18c2a97de2e09a013e92d02778289590603b;p=functorrent.git Network.httpget -> Network.sendGetRequest --- diff --git a/src/FuncTorrent/Network.hs b/src/FuncTorrent/Network.hs index 1a569a5..210c443 100644 --- a/src/FuncTorrent/Network.hs +++ b/src/FuncTorrent/Network.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module FuncTorrent.Network ( - httpget, + sendGetRequest, mkParams ) where @@ -17,8 +17,8 @@ import Network.URI (parseURI) mkParams :: [(String, ByteString)] -> ByteString mkParams params = BC.intercalate "&" [concat [pack f, "=", s] | (f,s) <- params] -httpget :: String -> [(String, ByteString)] -> IO ByteString -httpget url args = simpleHTTP (defaultGETRequest_ url') >>= getResponseBody +sendGetRequest :: String -> [(String, ByteString)] -> IO ByteString +sendGetRequest url args = simpleHTTP (defaultGETRequest_ url') >>= getResponseBody where url' = case parseURI $ unpack $ concat [pack url, "?", qstr] of Just x -> x _ -> error "Bad tracker URL" diff --git a/src/FuncTorrent/Tracker.hs b/src/FuncTorrent/Tracker.hs index cf1648e..11cecd5 100644 --- a/src/FuncTorrent/Tracker.hs +++ b/src/FuncTorrent/Tracker.hs @@ -21,7 +21,7 @@ import qualified Data.ByteString.Base16 as B16 (encode) import FuncTorrent.Bencode (BVal(..), decode) import FuncTorrent.Metainfo (Info(..), Metainfo(..)) -import FuncTorrent.Network (httpget) +import FuncTorrent.Network (sendGetRequest) import FuncTorrent.Peer (Peer(..)) import FuncTorrent.Utils (splitN) @@ -125,7 +125,7 @@ trackerLoop :: PortNumber -> String -> Metainfo -> TState -> IO ByteString trackerLoop port peerId m st = do up <- liftIO $ readMVar $ uploaded st down <- liftIO $ readMVar $ downloaded st - resp <- liftIO $ httpget (head . announceList $ m) $ mkArgs port peerId up down m + resp <- liftIO $ sendGetRequest (head . announceList $ m) $ mkArgs port peerId up down m case decode resp of Left e -> return $ pack (show e) Right trackerInfo ->