parse(str)
public
Cookie::parse()
It parses Cookie field sent from the user agent.
Show source
def self.parse(str)
if str
ret = []
cookie = nil
ver = 0
str.split(/[;,]\s+/).each{|x|
key, val = x.split(/=/,2)
val = val ? HTTPUtils::dequote(val) : ""
case key
when "$Version"; ver = val.to_i
when "$Path"; cookie.path = val
when "$Domain"; cookie.domain = val
when "$Port"; cookie.port = val
else
ret << cookie if cookie
cookie = self.new(key, val)
cookie.version = ver
end
}
ret << cookie if cookie
ret
end
end