Apply minor code improvements.

This commit is contained in:
Akinori MUSHA 2013-03-18 00:40:47 +09:00
parent 9768154e82
commit 1a7c38e9e0

View file

@ -180,14 +180,14 @@ class HTTP::Cookie
date ||= Time.now date ||= Time.now
[].tap { |cookies| [].tap { |cookies|
set_cookie.split(/,(?=[^;,]*=)|,$/).each { |c| # The expires attribute may include a comma in the value.
set_cookie.split(/,(?=[^;,]*=|\s*\z)/).each { |c|
if c.bytesize > MAX_LENGTH if c.bytesize > MAX_LENGTH
logger.warn("Cookie definition too long: #{c}") if logger logger.warn("Cookie definition too long: #{c}") if logger
next next
end end
cookie_elem = c.split(/;+/) first_elem, *cookie_elem = c.split(/;+/)
first_elem = cookie_elem.shift
first_elem.strip! first_elem.strip!
key, value = first_elem.split(/\=/, 2) key, value = first_elem.split(/\=/, 2)