class Rack::MockResponse

def identify_cookie_attributes(cookie_filling)

def identify_cookie_attributes(cookie_filling)
  cookie_bits = cookie_filling.split(';')
  cookie_attributes = Hash.new
  cookie_attributes.store('value', cookie_bits[0].strip)
  cookie_bits.drop(1).each do |bit|
    if bit.include? '='
      cookie_attribute, attribute_value = bit.split('=', 2)
      cookie_attributes.store(cookie_attribute.strip.downcase, attribute_value.strip)
    end
    if bit.include? 'secure'
      cookie_attributes.store('secure', true)
    end
  end
  if cookie_attributes.key? 'max-age'
    cookie_attributes.store('expires', Time.now + cookie_attributes['max-age'].to_i)
  elsif cookie_attributes.key? 'expires'
    cookie_attributes.store('expires', Time.httpdate(cookie_attributes['expires']))
  end
  cookie_attributes
end