Pyjo.UserAgent.CookieJar - Cookie jar for HTTP user agents¶
import Pyjo.UserAgent.CookieJar
# Add response cookies
jar = Pyjo.UserAgent.CookieJar.new()
jar.add(
Pyjo.UserAgent.CookieJar.new({
'name': 'foo',
'value': 'bar',
'domain': 'localhost',
'path': '/test'
})
)
# Find request cookies
for cookie in jar.find(Pyjo.URL.new('http://localhost/test')):
print(cookie.name)
print(cookie.value)
Pyjo.UserAgent.CookieJar
is the transaction building and manipulation
framework used by Pyjo.UserAgent
.
Classes¶
-
class
Pyjo.UserAgent.CookieJar.
Pyjo_UserAgent_CookieJar
(**kwargs)¶ Pyjo.UserAgent.CookieJar
inherits all attributes and methods fromPyjo.Base
and implements the following new ones.-
add
(*cookies)¶ jar = jar.add(cookie) jar = jar.add(cookie, cookie)
Add multiple
Pyjo.Cookie.Response
objects to the jar.
-
all
¶ cookies = jar.all
Return all L<Mojo::Cookie::Response> objects that are currently stored in the jar.
# Names of all cookies for c in jar.all: print(c.name)
-
collect
(tx)¶ jar.collect(Pyjo.Transaction.HTTP.new())
Collect response cookies from transaction.
-
collecting
= None¶ boolean = jar.collecting jar.collecting = boolean
Allow
collect()
toadd()
new cookies to the jar, defaults to aTrue
value.
-
empty
()¶ jar.empty()
Empty the jar.
-
find
(url)¶ cookies = jar.find(Pyjo.URL.new())
Find
Pyjo.Cookie.Request
objects in the jar forPyjo.URL
object.# Names of all cookies found for cookie in jar.find(Pyjo.URL.new('http://example.com/foo')): print(cookie.name)
size = jar.max_cookie_size jar.max_cookie_size = 4096
Maximum cookie size in bytes, defaults to
4096
(4KB).
-
prepare
(tx)¶ jar.prepare(Pyjo.Transaction.HTTP.new())
Prepare request cookies for transaction.
-
-
Pyjo.UserAgent.CookieJar.
object
¶ alias of
Pyjo_UserAgent_CookieJar