@@ -26,7 +26,7 @@ introduced with RFC 2965.
2626.. note ::
2727
2828 The various named parameters found in :mailheader: `Set-Cookie ` and
29- :mailheader: `Set-Cookie2 ` headers (eg. ``domain `` and ``expires ``) are
29+ :mailheader: `Set-Cookie2 ` headers (for example, ``domain `` and ``expires ``) are
3030 conventionally referred to as :dfn: `attributes `. To distinguish them from
3131 Python attributes, the documentation for this module uses the term
3232 :dfn: `cookie-attribute ` instead.
@@ -85,20 +85,20 @@ The following classes are provided:
8585
8686 Constructor arguments should be passed as keyword arguments only.
8787 *blocked_domains * is a sequence of domain names that we never accept cookies
88- from, nor return cookies to. *allowed_domains * if not :const: ` None `, this is a
88+ from, nor return cookies to. *allowed_domains * if not `` None ` `, this is a
8989 sequence of the only domains for which we accept and return cookies.
9090 *secure_protocols * is a sequence of protocols for which secure cookies can be
9191 added to. By default *https * and *wss * (secure websocket) are considered
9292 secure protocols. For all other arguments, see the documentation for
9393 :class: `CookiePolicy ` and :class: `DefaultCookiePolicy ` objects.
9494
9595 :class: `DefaultCookiePolicy ` implements the standard accept / reject rules for
96- Netscape and :rfc: `2965 ` cookies. By default, :rfc: `2109 ` cookies (ie. cookies
96+ Netscape and :rfc: `2965 ` cookies. By default, :rfc: `2109 ` cookies (that is, cookies
9797 received in a :mailheader: `Set-Cookie ` header with a version cookie-attribute of
9898 1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling
9999 is turned off or :attr: `rfc2109_as_netscape ` is ``True ``, RFC 2109 cookies are
100100 'downgraded' by the :class: `CookieJar ` instance to Netscape cookies, by
101- setting the :attr: `version ` attribute of the :class: `Cookie ` instance to 0.
101+ setting the :attr: `~Cookie. version ` attribute of the :class: `Cookie ` instance to 0.
102102 :class: `DefaultCookiePolicy ` also provides some parameters to allow some
103103 fine-tuning of policy.
104104
@@ -107,7 +107,7 @@ The following classes are provided:
107107
108108 This class represents Netscape, :rfc: `2109 ` and :rfc: `2965 ` cookies. It is not
109109 expected that users of :mod: `!http.cookiejar ` construct their own :class: `Cookie `
110- instances. Instead, if necessary, call :meth: `make_cookies ` on a
110+ instances. Instead, if necessary, call :meth: `~CookieJar. make_cookies ` on a
111111 :class: `CookieJar ` instance.
112112
113113
@@ -141,7 +141,7 @@ The following classes are provided:
141141
142142.. _cookie-jar-objects :
143143
144- CookieJar and FileCookieJar Objects
144+ CookieJar and FileCookieJar objects
145145-----------------------------------
146146
147147:class: `CookieJar ` objects support the :term: `iterator ` protocol for iterating over
@@ -154,20 +154,27 @@ contained :class:`Cookie` objects.
154154
155155 Add correct :mailheader: `Cookie ` header to *request *.
156156
157- If policy allows (ie. the :attr: `rfc2965 ` and :attr: `hide_cookie2 ` attributes of
157+ If policy allows (that is, the :attr: `~CookiePolicy.rfc2965 ` and
158+ :attr: `~CookiePolicy.hide_cookie2 ` attributes of
158159 the :class: `CookieJar `'s :class: `CookiePolicy ` instance are true and false
159160 respectively), the :mailheader: `Cookie2 ` header is also added when appropriate.
160161
161162 The *request * object (usually a :class: `urllib.request.Request ` instance)
162- must support the methods :meth: `get_full_url `, :meth: `has_header `,
163- :meth: `get_header `, :meth: `header_items `, :meth: `add_unredirected_header `
164- and the attributes :attr: `host `, :attr: `!type `, :attr: `unverifiable `
165- and :attr: `origin_req_host ` as documented by :mod: `urllib.request `.
163+ must support the methods :meth: `~urllib.request.Request.get_full_url `,
164+ :meth: `~urllib.request.Request.has_header `,
165+ :meth: `~urllib.request.Request.get_header `,
166+ :meth: `~urllib.request.Request.header_items `,
167+ :meth: `~urllib.request.Request.add_unredirected_header `
168+ and the attributes :attr: `~urllib.request.Request.host `,
169+ :attr: `~urllib.request.Request.type `, :attr: `~urllib.request.Request.unverifiable `
170+ and :attr: `~urllib.request.Request.origin_req_host ` as documented by
171+ :mod: `urllib.request `.
166172
167173 .. versionchanged :: 3.3
168174
169- *request * object needs :attr: `origin_req_host ` attribute. Dependency on a
170- deprecated method :meth: `get_origin_req_host ` has been removed.
175+ *request * object needs :attr: `~urllib.request.Request.origin_req_host `
176+ attribute. Dependency on a deprecated method
177+ :meth: `!get_origin_req_host ` has been removed.
171178
172179
173180.. method :: CookieJar.extract_cookies(response, request)
@@ -180,20 +187,24 @@ contained :class:`Cookie` objects.
180187 as appropriate (subject to the :meth: `CookiePolicy.set_ok ` method's approval).
181188
182189 The *response * object (usually the result of a call to
183- :meth: `urllib.request.urlopen `, or similar) should support an :meth: `info `
184- method, which returns an :class: `email.message.Message ` instance.
190+ :meth: `urllib.request.urlopen `, or similar) should support an
191+ :meth: `~http.client.HTTPResponse.info ` method, which returns an
192+ :class: `email.message.Message ` instance.
185193
186194 The *request * object (usually a :class: `urllib.request.Request ` instance)
187- must support the method :meth: `get_full_url ` and the attributes
188- :attr: `host `, :attr: `unverifiable ` and :attr: `origin_req_host `,
195+ must support the method :meth: `~urllib.request.Request.get_full_url ` and
196+ the attributes :attr: `~urllib.request.Request.host `,
197+ :attr: `~urllib.request.Request.unverifiable `
198+ and :attr: `~urllib.request.Request.origin_req_host `,
189199 as documented by :mod: `urllib.request `. The request is used to set
190200 default values for cookie-attributes as well as for checking that the
191201 cookie is allowed to be set.
192202
193203 .. versionchanged :: 3.3
194204
195- *request * object needs :attr: `origin_req_host ` attribute. Dependency on a
196- deprecated method :meth: `get_origin_req_host ` has been removed.
205+ *request * object needs :attr: `~urllib.request.Request.origin_req_host `
206+ attribute. Dependency on a deprecated method
207+ :meth: `!get_origin_req_host ` has been removed.
197208
198209.. method :: CookieJar.set_policy(policy)
199210
@@ -236,13 +247,13 @@ contained :class:`Cookie` objects.
236247
237248 Discard all session cookies.
238249
239- Discards all contained cookies that have a true :attr: `discard ` attribute
250+ Discards all contained cookies that have a true :attr: `~Cookie. discard ` attribute
240251 (usually because they had either no ``max-age `` or ``expires `` cookie-attribute,
241252 or an explicit ``discard `` cookie-attribute). For interactive browsers, the end
242253 of a session usually corresponds to closing the browser window.
243254
244- Note that the :meth: `save ` method won't save session cookies anyway, unless you
245- ask otherwise by passing a true *ignore_discard * argument.
255+ Note that the :meth: `~FileCookieJar. save ` method won't save session cookies
256+ anyway, unless you ask otherwise by passing a true *ignore_discard * argument.
246257
247258:class: `FileCookieJar ` implements the following additional methods:
248259
@@ -255,8 +266,9 @@ contained :class:`Cookie` objects.
255266 method unimplemented.
256267
257268 *filename * is the name of file in which to save cookies. If *filename * is not
258- specified, :attr: `self.filename ` is used (whose default is the value passed to
259- the constructor, if any); if :attr: `self.filename ` is :const: `None `,
269+ specified, :attr: `self.filename <FileCookieJar.filename> ` is used (whose
270+ default is the value passed to the constructor, if any); if
271+ :attr: `self.filename <FileCookieJar.filename> ` is ``None ``,
260272 :exc: `ValueError ` is raised.
261273
262274 *ignore_discard *: save even cookies set to be discarded. *ignore_expires *: save
@@ -349,7 +361,7 @@ writing.
349361
350362.. _cookie-policy-objects :
351363
352- CookiePolicy Objects
364+ CookiePolicy objects
353365--------------------
354366
355367Objects implementing the :class: `CookiePolicy ` interface have the following
@@ -433,7 +445,7 @@ setting and receiving any and all cookies (this is unlikely to be useful).
433445
434446.. _default-cookie-policy-objects :
435447
436- DefaultCookiePolicy Objects
448+ DefaultCookiePolicy objects
437449---------------------------
438450
439451Implements the standard rules for accepting and returning cookies.
@@ -463,10 +475,10 @@ blocking some benign cookies).
463475A domain blocklist and allowlist is provided (both off by default). Only domains
464476not in the blocklist and present in the allowlist (if the allowlist is active)
465477participate in cookie setting and returning. Use the *blocked_domains *
466- constructor argument, and :meth: `blocked_domains ` and
467- :meth: `set_blocked_domains ` methods (and the corresponding argument and methods
468- for *allowed_domains *). If you set an allowlist, you can turn it off again by
469- setting it to :const: ` None `.
478+ constructor argument, and :meth: `~DefaultCookiePolicy. blocked_domains ` and
479+ :meth: `~DefaultCookiePolicy. set_blocked_domains ` methods (and the corresponding
480+ argument and methods for *allowed_domains *). If you set an allowlist, you can
481+ turn it off again by setting it to `` None ` `.
470482
471483Domains in block or allow lists that do not start with a dot must equal the
472484cookie domain to be matched. For example, ``"example.com" `` matches a blocklist
@@ -498,12 +510,12 @@ and ``".168.1.2"``, 192.168.1.2 is blocked, but 193.168.1.2 is not.
498510
499511.. method :: DefaultCookiePolicy.allowed_domains()
500512
501- Return :const: ` None `, or the sequence of allowed domains (as a tuple).
513+ Return `` None ` `, or the sequence of allowed domains (as a tuple).
502514
503515
504516.. method :: DefaultCookiePolicy.set_allowed_domains(allowed_domains)
505517
506- Set the sequence of allowed domains, or :const: ` None `.
518+ Set the sequence of allowed domains, or `` None ` `.
507519
508520
509521.. method :: DefaultCookiePolicy.is_not_allowed(domain)
@@ -519,9 +531,9 @@ all be assigned to.
519531.. attribute :: DefaultCookiePolicy.rfc2109_as_netscape
520532
521533 If true, request that the :class: `CookieJar ` instance downgrade :rfc: `2109 ` cookies
522- (ie. cookies received in a :mailheader: `Set-Cookie ` header with a version
534+ (that is, cookies received in a :mailheader: `Set-Cookie ` header with a version
523535 cookie-attribute of 1) to Netscape cookies by setting the version attribute of
524- the :class: `Cookie ` instance to 0. The default value is :const: ` None `, in which
536+ the :class: `Cookie ` instance to 0. The default value is `` None ` `, in which
525537 case RFC 2109 cookies are downgraded if and only if :rfc: `2965 ` handling is turned
526538 off. Therefore, RFC 2109 cookies are downgraded by default.
527539
@@ -574,15 +586,15 @@ both flags are set).
574586
575587.. attribute :: DefaultCookiePolicy.DomainStrictNoDots
576588
577- When setting cookies, the 'host prefix' must not contain a dot (eg.
589+ When setting cookies, the 'host prefix' must not contain a dot (for example,
578590 ``www.foo.bar.com `` can't set a cookie for ``.bar.com ``, because ``www.foo ``
579591 contains a dot).
580592
581593
582594.. attribute :: DefaultCookiePolicy.DomainStrictNonDomain
583595
584596 Cookies that did not explicitly specify a ``domain `` cookie-attribute can only
585- be returned to a domain equal to the domain that set the cookie (eg.
597+ be returned to a domain equal to the domain that set the cookie (for example,
586598 ``spam.example.com `` won't be returned cookies from ``example.com `` that had no
587599 ``domain `` cookie-attribute).
588600
@@ -597,7 +609,7 @@ combinations of the above flags:
597609
598610.. attribute :: DefaultCookiePolicy.DomainLiberal
599611
600- Equivalent to 0 (ie. all of the above Netscape domain strictness flags switched
612+ Equivalent to 0 (that is, all of the above Netscape domain strictness flags switched
601613 off).
602614
603615
@@ -606,7 +618,7 @@ combinations of the above flags:
606618 Equivalent to ``DomainStrictNoDots|DomainStrictNonDomain ``.
607619
608620
609- Cookie Objects
621+ Cookie objects
610622--------------
611623
612624:class: `Cookie ` instances have Python attributes roughly corresponding to the
@@ -624,7 +636,7 @@ internal consistency, so you should know what you're doing if you do that.
624636
625637.. attribute :: Cookie.version
626638
627- Integer or :const: ` None `. Netscape cookies have :attr: `version ` 0. :rfc: `2965 ` and
639+ Integer or `` None ` `. Netscape cookies have :attr: `version ` 0. :rfc: `2965 ` and
628640 :rfc: `2109 ` cookies have a ``version `` cookie-attribute of 1. However, note that
629641 :mod: `!http.cookiejar ` may 'downgrade' RFC 2109 cookies to Netscape cookies, in which
630642 case :attr: `version ` is 0.
@@ -637,13 +649,13 @@ internal consistency, so you should know what you're doing if you do that.
637649
638650.. attribute :: Cookie.value
639651
640- Cookie value (a string), or :const: ` None `.
652+ Cookie value (a string), or `` None ` `.
641653
642654
643655.. attribute :: Cookie.port
644656
645- String representing a port or a set of ports (eg. '80', or '80,8080'), or
646- :const: ` None `.
657+ String representing a port or a set of ports (for example, '80', or '80,8080'), or
658+ `` None ` `.
647659
648660
649661.. attribute :: Cookie.domain
@@ -653,7 +665,7 @@ internal consistency, so you should know what you're doing if you do that.
653665
654666.. attribute :: Cookie.path
655667
656- Cookie path (a string, eg. ``'/acme/rocket_launchers' ``).
668+ Cookie path (a string, for example, ``'/acme/rocket_launchers' ``).
657669
658670
659671.. attribute :: Cookie.secure
@@ -663,7 +675,7 @@ internal consistency, so you should know what you're doing if you do that.
663675
664676.. attribute :: Cookie.expires
665677
666- Integer expiry date in seconds since epoch, or :const: ` None `. See also the
678+ Integer expiry date in seconds since epoch, or `` None ` `. See also the
667679 :meth: `is_expired ` method.
668680
669681
@@ -675,18 +687,18 @@ internal consistency, so you should know what you're doing if you do that.
675687.. attribute :: Cookie.comment
676688
677689 String comment from the server explaining the function of this cookie, or
678- :const: ` None `.
690+ `` None ` `.
679691
680692
681693.. attribute :: Cookie.comment_url
682694
683695 URL linking to a comment from the server explaining the function of this cookie,
684- or :const: ` None `.
696+ or `` None ` `.
685697
686698
687699.. attribute :: Cookie.rfc2109
688700
689- ``True `` if this cookie was received as an :rfc: `2109 ` cookie (ie. the cookie
701+ ``True `` if this cookie was received as an :rfc: `2109 ` cookie (that is, the cookie
690702 arrived in a :mailheader: `Set-Cookie ` header, and the value of the Version
691703 cookie-attribute in that header was 1). This attribute is provided because
692704 :mod: `!http.cookiejar ` may 'downgrade' RFC 2109 cookies to Netscape cookies, in
0 commit comments