X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FUtils.hs;h=f8fd589b74bbd5c170f2a98aa0afd28aee91f33c;hp=7537eafcffacf7d8edf755e2bb8fea30cd636547;hb=7bb9f32;hpb=d0865cb266d25b6f3e07a34c10a3a04fc0405db8 diff --git a/Network/HTTP/Lucu/Utils.hs b/Network/HTTP/Lucu/Utils.hs index 7537eaf..f8fd589 100644 --- a/Network/HTTP/Lucu/Utils.hs +++ b/Network/HTTP/Lucu/Utils.hs @@ -5,13 +5,15 @@ #-} -- |Utility functions used internally in this package. module Network.HTTP.Lucu.Utils - ( Host + ( Scheme + , Host , PathSegment , Path , splitBy , quoteStr , parseWWWFormURLEncoded + , uriCIScheme , uriHost , uriPathSegments , trim @@ -26,7 +28,7 @@ module Network.HTTP.Lucu.Utils where import Control.Applicative hiding (empty) import Control.Monad hiding (mapM) -import Data.Ascii (Ascii, AsciiBuilder) +import Data.Ascii (Ascii, AsciiBuilder, CIAscii) import qualified Data.Ascii as A import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BS @@ -48,6 +50,9 @@ import Prelude hiding (last, mapM, null, reverse) import Prelude.Unicode import System.Directory +-- |'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 @@ -113,6 +118,12 @@ parseWWWFormURLEncoded src plusToSpace '+' = ' ' plusToSpace c = c +-- |>>> uriCIScheme "http://example.com/foo/bar" +-- "http" +uriCIScheme ∷ URI → CIAscii +{-# INLINE uriCIScheme #-} +uriCIScheme = convertUnsafe ∘ fst ∘ fromJust ∘ back ∘ uriScheme + -- |>>> uriHost "http://example.com/foo/bar" -- "example.com" uriHost ∷ URI → Host