packages feed

hsp-0.2: HTTP/Util.hs

module HTTP.Util where

import Data.Char(isSpace)


emptyline :: String -> Bool
emptyline "\r" = True
emptyline _    = False


killLWS :: String -> String
killLWS "" = ""
killLWS ('\r':c:xs)
    | isSpace c = killLWS (c:xs)
killLWS (c0:c1:xs)
    | isSpace c0 && isSpace c1 = killLWS (' ':xs)
killLWS (x:xs) = x : killLWS xs


crlines :: String -> [String]
crlines ""  = []
crlines str = l : (crlines $ dropWhile (=='\r') ls)
    where
     (l, ls) = break (=='\r') str

showsSpace :: ShowS
showsSpace = showString " "
 
showsCRLF :: ShowS
showsCRLF = showString "\r\n"