From 937ffe2f497b07d8db2033c95d346d963ea9cc57 Mon Sep 17 00:00:00 2001 From: Sam T Date: Thu, 4 Apr 2013 17:44:09 +0400 Subject: remove unneccessary dependencies --- network-bittorrent.cabal | 3 +-- src/Data/Torrent.hs | 16 ++++++++-------- tests/client.hs | 1 + 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/network-bittorrent.cabal b/network-bittorrent.cabal index 2a4b28b0..a926d82e 100644 --- a/network-bittorrent.cabal +++ b/network-bittorrent.cabal @@ -28,12 +28,11 @@ library , bencoding >= 0.1.0.0 , network >= 2.4.1.2 , HTTP >= 4000.2.8 - , url >= 2.1.3 , urlencoded >= 0.4.0 , cereal >= 0.3.5.2 , cryptohash , text >= 0.11.2.3 - , directory-tree >= 0.11.0 + extensions: PatternGuards hs-source-dirs: src diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs index 53ec4ff8..128c1c7c 100644 --- a/src/Data/Torrent.hs +++ b/src/Data/Torrent.hs @@ -15,7 +15,7 @@ import qualified Data.ByteString.Char8 as BC (pack, unpack) import Data.Text (Text) import Crypto.Hash.SHA1 import Data.BEncode -import Network.URL +import Network.URI type Time = Text @@ -23,15 +23,15 @@ type Time = Text -- TODO more convenient form of torrent info. data Torrent = Torrent { tInfoHash :: ByteString - , tAnnounce :: URL - , tAnnounceList :: Maybe [[URL]] + , tAnnounce :: URI + , tAnnounceList :: Maybe [[URI]] , tComment :: Maybe Text , tCreatedBy :: Maybe ByteString , tCreationDate :: Maybe Time , tEncoding :: Maybe ByteString , tInfo :: TorrentInfo - , tPublisher :: Maybe URL - , tPublisherURL :: Maybe URL + , tPublisher :: Maybe URI + , tPublisherURL :: Maybe URI } deriving Show data TorrentInfo = @@ -59,11 +59,11 @@ data TorrentFile = TorrentFile { , tfPath :: [ByteString] } deriving (Show, Read, Eq) -instance BEncodable URL where - toBEncode = toBEncode . BC.pack . exportURL -- TODO utf8 encoding +instance BEncodable URI where + toBEncode uri = toBEncode (BC.pack (uriToString id uri "")) {-# INLINE toBEncode #-} - fromBEncode (BString s) | Just url <- importURL (BC.unpack s) = return url + fromBEncode (BString s) | Just url <- parseURI (BC.unpack s) = return url fromBEncode b = decodingError $ "url <" ++ show b ++ ">" {-# INLINE fromBEncode #-} diff --git a/tests/client.hs b/tests/client.hs index 5697d18a..2b626241 100644 --- a/tests/client.hs +++ b/tests/client.hs @@ -22,6 +22,7 @@ main = do let Right b = decode contents let Right t = fromBEncode b + let req = defaultRequest (tAnnounce t) (tInfoHash t) resp <- sendRequest req print resp -- cgit v1.2.3