Method: HTTP::CookieJar#parse
- Defined in:
- lib/http/cookie_jar.rb
#parse(set_cookie, origin, options = nil) ⇒ Object
Parses a Set-Cookie field value ‘set_cookie` assuming that it is sent from a source URL/URI `origin`, and adds the cookies parsed as valid and considered acceptable to the jar. Returns an array of cookies that have been added.
If a block is given, it is called for each cookie and the cookie is added only if the block returns a true value.
‘jar.parse(set_cookie, origin)` is a shorthand for this:
HTTP::Cookie.parse(, origin) { ||
jar.add()
}
See HTTP::Cookie.parse for available options.
183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/http/cookie_jar.rb', line 183 def parse(, origin, = nil) # :yield: cookie if block_given? HTTP::Cookie.parse(, origin, ).tap { || .select! { || yield() && add() } } else HTTP::Cookie.parse(, origin, ) { || add() } end end |