X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FUtils.hs;h=7623c70e45d7d604beb019aa20f09bfe57987a28;hp=d36c81b2853cb7e01adf861bed59e344b4181f7c;hb=57b93dc50655857941cc176aed2fc085e6555ff7;hpb=b42b4ab2f78fa62dd023acd136085dae6dc9028a diff --git a/Network/HTTP/Lucu/Utils.hs b/Network/HTTP/Lucu/Utils.hs index d36c81b..7623c70 100644 --- a/Network/HTTP/Lucu/Utils.hs +++ b/Network/HTTP/Lucu/Utils.hs @@ -5,15 +5,13 @@ #-} -- |Utility functions used internally in this package. module Network.HTTP.Lucu.Utils - ( Scheme - , Host + ( Host , PathSegment - , PathSegments + , Path , splitBy , quoteStr , parseWWWFormURLEncoded - , uriCIScheme , uriHost , uriPathSegments , trim @@ -28,7 +26,7 @@ module Network.HTTP.Lucu.Utils where import Control.Applicative hiding (empty) import Control.Monad hiding (mapM) -import Data.Ascii (Ascii, AsciiBuilder, CIAscii) +import Data.Ascii (Ascii, AsciiBuilder) import qualified Data.Ascii as A import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BS @@ -50,9 +48,6 @@ import Prelude.Unicode import System.Directory import System.Time (ClockTime(..)) --- |'Scheme' represents an URI scheme. -type Scheme = CIAscii - -- |'Host' represents an IP address or a host name in an URI -- authority. type Host = CI Text @@ -61,8 +56,8 @@ type Host = CI Text -- percent-decoded. type PathSegment = ByteString --- |'PathSegments' is a list of URI path segments. -type PathSegments = [PathSegment] +-- |'Path' is a list of URI path segments. +type Path = [PathSegment] -- |>>> splitBy (== ':') "ab:c:def" -- ["ab", "c", "def"] @@ -118,12 +113,6 @@ parseWWWFormURLEncoded src plusToSpace '+' = ' ' plusToSpace c = c --- |>>> uriCIScheme "http://example.com/foo/bar" --- "http" -uriCIScheme ∷ URI → Scheme -{-# INLINE uriCIScheme #-} -uriCIScheme = A.toCIAscii ∘ A.unsafeFromString ∘ uriScheme - -- |>>> uriHost "http://example.com/foo/bar" -- "example.com" uriHost ∷ URI → Host @@ -132,7 +121,7 @@ uriHost = CI.mk ∘ T.pack ∘ uriRegName ∘ fromJust ∘ uriAuthority -- |>>> uriPathSegments "http://example.com/foo/bar" -- ["foo", "bar"] -uriPathSegments ∷ URI → PathSegments +uriPathSegments ∷ URI → Path uriPathSegments uri = let reqPathStr = uriPath uri reqPath = [ unEscapeString x