From 1fee18c2a97de2e09a013e92d02778289590603b Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org> Date: Fri, 2 Oct 2015 14:45:08 +0530 Subject: [PATCH] Network.httpget -> Network.sendGetRequest --- src/FuncTorrent/Network.hs | 6 +++--- src/FuncTorrent/Tracker.hs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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 -> -- 2.45.2