diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-28 15:00:13 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-28 15:00:13 +0400 |
commit | 60d21cfefd82995265c00df9136b19fefa8910ac (patch) | |
tree | 4b6392f3dd30d9de981916dc5bd5e3ec5d20cbd0 /src/Network/BitTorrent/Core | |
parent | fc3b090ac8dceefd315e6ca16f12d32dca11f580 (diff) |
Get rid of the urlencoded package
* It uses slow String's instead of Text.
* It does not allow to encode infohash and peer ids properly.
* It does not provide API for query string parsing.
So it is better to use http-types package.
Diffstat (limited to 'src/Network/BitTorrent/Core')
-rw-r--r-- | src/Network/BitTorrent/Core/PeerId.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/Core/PeerId.hs b/src/Network/BitTorrent/Core/PeerId.hs index a2b03e92..f5a40f29 100644 --- a/src/Network/BitTorrent/Core/PeerId.hs +++ b/src/Network/BitTorrent/Core/PeerId.hs | |||
@@ -46,12 +46,14 @@ import Data.List as L | |||
46 | import Data.List.Split as L | 46 | import Data.List.Split as L |
47 | import Data.Maybe (fromMaybe, catMaybes) | 47 | import Data.Maybe (fromMaybe, catMaybes) |
48 | import Data.Monoid | 48 | import Data.Monoid |
49 | import Data.Hashable | ||
49 | import Data.Serialize as S | 50 | import Data.Serialize as S |
50 | import Data.String | 51 | import Data.String |
51 | import Data.Time.Clock (getCurrentTime) | 52 | import Data.Time.Clock (getCurrentTime) |
52 | import Data.Time.Format (formatTime) | 53 | import Data.Time.Format (formatTime) |
53 | import Data.URLEncoded | 54 | import Data.URLEncoded |
54 | import Data.Version (Version(Version), versionBranch) | 55 | import Data.Version (Version(Version), versionBranch) |
56 | import Network.HTTP.Types.QueryLike | ||
55 | import System.Entropy (getEntropy) | 57 | import System.Entropy (getEntropy) |
56 | import System.Locale (defaultTimeLocale) | 58 | import System.Locale (defaultTimeLocale) |
57 | import Text.PrettyPrint hiding ((<>)) | 59 | import Text.PrettyPrint hiding ((<>)) |
@@ -70,12 +72,17 @@ newtype PeerId = PeerId { getPeerId :: ByteString } | |||
70 | peerIdLen :: Int | 72 | peerIdLen :: Int |
71 | peerIdLen = 20 | 73 | peerIdLen = 20 |
72 | 74 | ||
75 | instance Hashable PeerId where | ||
76 | hash = hash . getPeerId | ||
77 | {-# INLINE hash #-} | ||
78 | |||
73 | instance Serialize PeerId where | 79 | instance Serialize PeerId where |
74 | put = putByteString . getPeerId | 80 | put = putByteString . getPeerId |
75 | get = PeerId <$> getBytes peerIdLen | 81 | get = PeerId <$> getBytes peerIdLen |
76 | 82 | ||
77 | instance URLShow PeerId where | 83 | instance QueryValueLike PeerId where |
78 | urlShow = BC.unpack . getPeerId | 84 | toQueryValue (PeerId pid) = Just pid |
85 | {-# INLINE toQueryValue #-} | ||
79 | 86 | ||
80 | instance IsString PeerId where | 87 | instance IsString PeerId where |
81 | fromString str | 88 | fromString str |