From 58ea9495514fa90cdd0c53a5628372d370a6bd0c Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sat, 30 Nov 2013 16:40:34 +0400 Subject: Add tests for http tracker protocol --- src/Network/BitTorrent/Tracker/RPC/HTTP.hs | 11 +++++++++-- src/Network/BitTorrent/Tracker/RPC/Message.hs | 3 --- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/Network/BitTorrent/Tracker/RPC') diff --git a/src/Network/BitTorrent/Tracker/RPC/HTTP.hs b/src/Network/BitTorrent/Tracker/RPC/HTTP.hs index 81208590..2006ae70 100644 --- a/src/Network/BitTorrent/Tracker/RPC/HTTP.hs +++ b/src/Network/BitTorrent/Tracker/RPC/HTTP.hs @@ -51,8 +51,15 @@ data Connection = Connection putConnection :: Connection -> IO () putConnection = undefined -connect :: URI -> IO Connection -connect = undefined +-- TODO share manager between several threads +connect :: URI -> ResourceT IO Connection +connect uri = do + (_, m) <- allocate (newManager def) closeManager + return Connection + { announceURI = uri + , manager = m + , connProxy = Nothing + } setSimpleQuery :: SimpleQuery -> Request m -> Request m setSimpleQuery q r = r diff --git a/src/Network/BitTorrent/Tracker/RPC/Message.hs b/src/Network/BitTorrent/Tracker/RPC/Message.hs index e91d223e..26868ead 100644 --- a/src/Network/BitTorrent/Tracker/RPC/Message.hs +++ b/src/Network/BitTorrent/Tracker/RPC/Message.hs @@ -475,9 +475,6 @@ parseFailureMessage e = BS.concat $ case e of parseFailureStatus :: ParamParseFailure -> Status parseFailureStatus = mkStatus <$> parseFailureCode <*> parseFailureMessage ---type AnnounceResponse = Either Status AnnounceInfo -- TODO ---type TrackerResponse = () -- TODO - {----------------------------------------------------------------------- Scrape message -----------------------------------------------------------------------} -- cgit v1.2.3