- | Encoding is supposed to be in ascii format. But this accepts UTF8 aswell.
-- If there's any encoding errors we let them through and replace them with the UTF8 replacement character (�)
-- Note that the field names are all converted to lowercase 
parse :: BL.ByteString -> Maybe (Text, Text)
parse inStr = if value == ""
              then Nothing
              else Just (TL.toLower $ decode $ BL.dropWhile (==' ') name,
                         decode (BL.dropWhile (==' ') $ BL.drop 1 value)) 
  where
    (name, value) = BL.break (==':') inStr
    decode = TEnc.decodeUtf8With $ TEnc.replace '�'




parse :: BL.ByteString -> Maybe (Text, Text)
parse inStr = if value == ""
              then Nothing
              else Just (TL.toLower $ decode $ BL.dropWhile (==' ') name,
                         decode (BL.dropWhile (==' ') $ BL.drop 1 value)) 
  where
    (name, value) = BL.break (==':') inStr
    decode = TEnc.decodeUtf8With $ TEnc.replace '�'
parse inStr = if value == ""
              then Nothing
              else Just (TL.toLower $ decode $ BL.dropWhile (==' ') name,
                         decode (BL.dropWhile (==' ') $ BL.drop 1 value)) 
  where
    (name, value) = BL.break (==':') inStr
    decode = TEnc.decodeUtf8With $ TEnc.replace '�'