From c23dafe8c3b7b063e427c0be998cf59904a09fff Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Wed, 17 Oct 2012 22:11:44 +0900 Subject: [PATCH] Document that HTTP::Cookie.parse takes an optional block. --- lib/http/cookie.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/http/cookie.rb b/lib/http/cookie.rb index 0bf4a87..1f5aa4c 100644 --- a/lib/http/cookie.rb +++ b/lib/http/cookie.rb @@ -81,10 +81,12 @@ class HTTP::Cookie alias for_domain? for_domain class << self - # Parses a Set-Cookie header line +str+ sent from +uri+ into an - # array of Cookie objects. Parts (separated by commas) that are - # malformed are ignored. - def parse(uri, str, log = nil) + # Parses a Set-Cookie header value +set_cookie+ sent from +origin+ + # into an array of Cookie objects. Parts (separated by commas) + # that are malformed are ignored. + # + # If a block is given, each cookie object is passed to the block. + def parse(origin, set_cookie, logger = nil) [].tap { |cookies| set_cookie.split(/,(?=[^;,]*=)|,$/).each { |c| cookie_elem = c.split(/;+/)