mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-03-25 08:55:53 +00:00
Document that HTTP::Cookie.parse takes an optional block.
This commit is contained in:
parent
905cd2bc26
commit
c23dafe8c3
1 changed files with 6 additions and 4 deletions
|
|
@ -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(/;+/)
|
||||
|
|
|
|||
Loading…
Reference in a new issue