Skip to content

Commit

Permalink
Documentation for CookieJar class (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Kutepov authored and asvetlov committed Jul 24, 2016
1 parent 8d9ee8b commit 072991f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,13 @@ Cookie safety
-------------

By default :class:`~aiohttp.ClientSession` uses strict version of
:class:`~aiohttp.CookieJar`. :rfc:`2109` explicitly forbids cookie
:class:`aiohttp.CookieJar`. :rfc:`2109` explicitly forbids cookie
accepting from URLs with IP address instead of DNS name
(e.g. `http://127.0.0.1:80/cookie`).

It's good but sometimes for testing we need to enable support for such
cookies. It should be done by passing `usafe=True` to
:class:`~aiohttp.CookieJar` constructor::
:class:`aiohttp.CookieJar` constructor::


jar = aiohttp.CookieJar(unsafe=True)
Expand Down
28 changes: 28 additions & 0 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1395,4 +1395,32 @@ BasicAuth
:return: encoded authentication data, :class:`str`.


CookieJar
^^^^^^^^^

.. class:: CookieJar(unsafe=False, loop=None)

Implements cookie storage adhering to RFC 6265.

:param bool unsafe: (optional) Whether to accept cookies from IPs.
:param bool loop: an :ref:`event loop<asyncio-event-loop>` instance.
See :class:`aiohttp.abc.AbstractCookieJar`

.. method:: update_cookies(cookies, response_url=None)

Update cookies.

:param cookies: cookies to update.
The parameter can be of :class:`str`, :class:`dict` or :class:`http.cookies.Morsel`
instance representing cookies to send.

:param str response_url: (optional) URL to store cookies for.

.. method:: filter_cookies(request_url)

Returns this jar's cookies filtered by their attributes.

:param str request_url: URL to fetch cookies for.


.. disqus::

0 comments on commit 072991f

Please sign in to comment.