@@ -29,7 +29,7 @@ introduced with RFC 2965.
2929.. note ::
3030
3131 The various named parameters found in :mailheader: `Set-Cookie ` and
32- :mailheader: `Set-Cookie2 ` headers (eg. ``domain `` and ``expires ``) are
32+ :mailheader: `Set-Cookie2 ` headers (for example, ``domain `` and ``expires ``) are
3333 conventionally referred to as :dfn: `attributes `. To distinguish them from
3434 Python attributes, the documentation for this module uses the term
3535 :dfn: `cookie-attribute ` instead.
@@ -88,20 +88,20 @@ The following classes are provided:
8888
8989 Constructor arguments should be passed as keyword arguments only.
9090 *blocked_domains * is a sequence of domain names that we never accept cookies
91- from, nor return cookies to. *allowed_domains * if not :const: ` None `, this is a
91+ from, nor return cookies to. *allowed_domains * if not `` None ` `, this is a
9292 sequence of the only domains for which we accept and return cookies.
9393 *secure_protocols * is a sequence of protocols for which secure cookies can be
9494 added to. By default *https * and *wss * (secure websocket) are considered
9595 secure protocols. For all other arguments, see the documentation for
9696 :class: `CookiePolicy ` and :class: `DefaultCookiePolicy ` objects.
9797
9898 :class: `DefaultCookiePolicy ` implements the standard accept / reject rules for
99- Netscape and :rfc: `2965 ` cookies. By default, :rfc: `2109 ` cookies (ie. cookies
99+ Netscape and :rfc: `2965 ` cookies. By default, :rfc: `2109 ` cookies (that is, cookies
100100 received in a :mailheader: `Set-Cookie ` header with a version cookie-attribute of
101101 1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling
102102 is turned off or :attr: `rfc2109_as_netscape ` is ``True ``, RFC 2109 cookies are
103103 'downgraded' by the :class: `CookieJar ` instance to Netscape cookies, by
104- setting the :attr: `version ` attribute of the :class: `Cookie ` instance to 0.
104+ setting the :attr: `~Cookie. version ` attribute of the :class: `Cookie ` instance to 0.
105105 :class: `DefaultCookiePolicy ` also provides some parameters to allow some
106106 fine-tuning of policy.
107107
@@ -110,7 +110,7 @@ The following classes are provided:
110110
111111 This class represents Netscape, :rfc: `2109 ` and :rfc: `2965 ` cookies. It is not
112112 expected that users of :mod: `http.cookiejar ` construct their own :class: `Cookie `
113- instances. Instead, if necessary, call :meth: `make_cookies ` on a
113+ instances. Instead, if necessary, call :meth: `~CookieJar. make_cookies ` on a
114114 :class: `CookieJar ` instance.
115115
116116
@@ -144,7 +144,7 @@ The following classes are provided:
144144
145145.. _cookie-jar-objects :
146146
147- CookieJar and FileCookieJar Objects
147+ CookieJar and FileCookieJar objects
148148-----------------------------------
149149
150150:class: `CookieJar ` objects support the :term: `iterator ` protocol for iterating over
@@ -157,20 +157,27 @@ contained :class:`Cookie` objects.
157157
158158 Add correct :mailheader: `Cookie ` header to *request *.
159159
160- If policy allows (ie. the :attr: `rfc2965 ` and :attr: `hide_cookie2 ` attributes of
160+ If policy allows (that is, the :attr: `~CookiePolicy.rfc2965 ` and
161+ :attr: `~CookiePolicy.hide_cookie2 ` attributes of
161162 the :class: `CookieJar `'s :class: `CookiePolicy ` instance are true and false
162163 respectively), the :mailheader: `Cookie2 ` header is also added when appropriate.
163164
164165 The *request * object (usually a :class: `urllib.request.Request ` instance)
165- must support the methods :meth: `get_full_url `, :meth: `has_header `,
166- :meth: `get_header `, :meth: `header_items `, :meth: `add_unredirected_header `
167- and the attributes :attr: `host `, :attr: `!type `, :attr: `unverifiable `
168- and :attr: `origin_req_host ` as documented by :mod: `urllib.request `.
166+ must support the methods :meth: `~urllib.request.Request.get_full_url `,
167+ :meth: `~urllib.request.Request.has_header `,
168+ :meth: `~urllib.request.Request.get_header `,
169+ :meth: `~urllib.request.Request.header_items `,
170+ :meth: `~urllib.request.Request.add_unredirected_header `
171+ and the attributes :attr: `~urllib.request.Request.host `,
172+ :attr: `~urllib.request.Request.type `, :attr: `~urllib.request.Request.unverifiable `
173+ and :attr: `~urllib.request.Request.origin_req_host ` as documented by
174+ :mod: `urllib.request `.
169175
170176 .. versionchanged :: 3.3
171177
172- *request * object needs :attr: `origin_req_host ` attribute. Dependency on a
173- deprecated method :meth: `get_origin_req_host ` has been removed.
178+ *request * object needs :attr: `~urllib.request.Request.origin_req_host `
179+ attribute. Dependency on a deprecated method
180+ :meth: `!get_origin_req_host ` has been removed.
174181
175182
176183.. method :: CookieJar.extract_cookies(response, request)
@@ -183,20 +190,24 @@ contained :class:`Cookie` objects.
183190 as appropriate (subject to the :meth: `CookiePolicy.set_ok ` method's approval).
184191
185192 The *response * object (usually the result of a call to
186- :meth: `urllib.request.urlopen `, or similar) should support an :meth: `info `
187- method, which returns an :class: `email.message.Message ` instance.
193+ :meth: `urllib.request.urlopen `, or similar) should support an
194+ :meth: `~http.client.HTTPResponse.info ` method, which returns an
195+ :class: `email.message.Message ` instance.
188196
189197 The *request * object (usually a :class: `urllib.request.Request ` instance)
190- must support the method :meth: `get_full_url ` and the attributes
191- :attr: `host `, :attr: `unverifiable ` and :attr: `origin_req_host `,
198+ must support the method :meth: `~urllib.request.Request.get_full_url ` and
199+ the attributes :attr: `~urllib.request.Request.host `,
200+ :attr: `~urllib.request.Request.unverifiable `
201+ and :attr: `~urllib.request.Request.origin_req_host `,
192202 as documented by :mod: `urllib.request `. The request is used to set
193203 default values for cookie-attributes as well as for checking that the
194204 cookie is allowed to be set.
195205
196206 .. versionchanged :: 3.3
197207
198- *request * object needs :attr: `origin_req_host ` attribute. Dependency on a
199- deprecated method :meth: `get_origin_req_host ` has been removed.
208+ *request * object needs :attr: `~urllib.request.Request.origin_req_host `
209+ attribute. Dependency on a deprecated method
210+ :meth: `!get_origin_req_host ` has been removed.
200211
201212.. method :: CookieJar.set_policy(policy)
202213
@@ -239,13 +250,13 @@ contained :class:`Cookie` objects.
239250
240251 Discard all session cookies.
241252
242- Discards all contained cookies that have a true :attr: `discard ` attribute
253+ Discards all contained cookies that have a true :attr: `~Cookie. discard ` attribute
243254 (usually because they had either no ``max-age `` or ``expires `` cookie-attribute,
244255 or an explicit ``discard `` cookie-attribute). For interactive browsers, the end
245256 of a session usually corresponds to closing the browser window.
246257
247- Note that the :meth: `save ` method won't save session cookies anyway, unless you
248- ask otherwise by passing a true *ignore_discard * argument.
258+ Note that the :meth: `~FileCookieJar. save ` method won't save session cookies
259+ anyway, unless you ask otherwise by passing a true *ignore_discard * argument.
249260
250261:class: `FileCookieJar ` implements the following additional methods:
251262
@@ -258,8 +269,9 @@ contained :class:`Cookie` objects.
258269 method unimplemented.
259270
260271 *filename * is the name of file in which to save cookies. If *filename * is not
261- specified, :attr: `self.filename ` is used (whose default is the value passed to
262- the constructor, if any); if :attr: `self.filename ` is :const: `None `,
272+ specified, :attr: `self.filename <FileCookieJar.filename> ` is used (whose
273+ default is the value passed to the constructor, if any); if
274+ :attr: `self.filename <FileCookieJar.filename> ` is ``None ``,
263275 :exc: `ValueError ` is raised.
264276
265277 *ignore_discard *: save even cookies set to be discarded. *ignore_expires *: save
@@ -352,7 +364,7 @@ writing.
352364
353365.. _cookie-policy-objects :
354366
355- CookiePolicy Objects
367+ CookiePolicy objects
356368--------------------
357369
358370Objects implementing the :class: `CookiePolicy ` interface have the following
@@ -436,7 +448,7 @@ setting and receiving any and all cookies (this is unlikely to be useful).
436448
437449.. _default-cookie-policy-objects :
438450
439- DefaultCookiePolicy Objects
451+ DefaultCookiePolicy objects
440452---------------------------
441453
442454Implements the standard rules for accepting and returning cookies.
@@ -466,10 +478,10 @@ blocking some benign cookies).
466478A domain blocklist and allowlist is provided (both off by default). Only domains
467479not in the blocklist and present in the allowlist (if the allowlist is active)
468480participate in cookie setting and returning. Use the *blocked_domains *
469- constructor argument, and :meth: `blocked_domains ` and
470- :meth: `set_blocked_domains ` methods (and the corresponding argument and methods
471- for *allowed_domains *). If you set an allowlist, you can turn it off again by
472- setting it to :const: ` None `.
481+ constructor argument, and :meth: `~DefaultCookiePolicy. blocked_domains ` and
482+ :meth: `~DefaultCookiePolicy. set_blocked_domains ` methods (and the corresponding
483+ argument and methods for *allowed_domains *). If you set an allowlist, you can
484+ turn it off again by setting it to `` None ` `.
473485
474486Domains in block or allow lists that do not start with a dot must equal the
475487cookie domain to be matched. For example, ``"example.com" `` matches a blocklist
@@ -501,12 +513,12 @@ and ``".168.1.2"``, 192.168.1.2 is blocked, but 193.168.1.2 is not.
501513
502514.. method :: DefaultCookiePolicy.allowed_domains()
503515
504- Return :const: ` None `, or the sequence of allowed domains (as a tuple).
516+ Return `` None ` `, or the sequence of allowed domains (as a tuple).
505517
506518
507519.. method :: DefaultCookiePolicy.set_allowed_domains(allowed_domains)
508520
509- Set the sequence of allowed domains, or :const: ` None `.
521+ Set the sequence of allowed domains, or `` None ` `.
510522
511523
512524.. method :: DefaultCookiePolicy.is_not_allowed(domain)
@@ -522,9 +534,9 @@ all be assigned to.
522534.. attribute :: DefaultCookiePolicy.rfc2109_as_netscape
523535
524536 If true, request that the :class: `CookieJar ` instance downgrade :rfc: `2109 ` cookies
525- (ie. cookies received in a :mailheader: `Set-Cookie ` header with a version
537+ (that is, cookies received in a :mailheader: `Set-Cookie ` header with a version
526538 cookie-attribute of 1) to Netscape cookies by setting the version attribute of
527- the :class: `Cookie ` instance to 0. The default value is :const: ` None `, in which
539+ the :class: `Cookie ` instance to 0. The default value is `` None ` `, in which
528540 case RFC 2109 cookies are downgraded if and only if :rfc: `2965 ` handling is turned
529541 off. Therefore, RFC 2109 cookies are downgraded by default.
530542
@@ -577,15 +589,15 @@ both flags are set).
577589
578590.. attribute :: DefaultCookiePolicy.DomainStrictNoDots
579591
580- When setting cookies, the 'host prefix' must not contain a dot (eg.
592+ When setting cookies, the 'host prefix' must not contain a dot (for example,
581593 ``www.foo.bar.com `` can't set a cookie for ``.bar.com ``, because ``www.foo ``
582594 contains a dot).
583595
584596
585597.. attribute :: DefaultCookiePolicy.DomainStrictNonDomain
586598
587599 Cookies that did not explicitly specify a ``domain `` cookie-attribute can only
588- be returned to a domain equal to the domain that set the cookie (eg.
600+ be returned to a domain equal to the domain that set the cookie (for example,
589601 ``spam.example.com `` won't be returned cookies from ``example.com `` that had no
590602 ``domain `` cookie-attribute).
591603
@@ -600,7 +612,7 @@ combinations of the above flags:
600612
601613.. attribute :: DefaultCookiePolicy.DomainLiberal
602614
603- Equivalent to 0 (ie. all of the above Netscape domain strictness flags switched
615+ Equivalent to 0 (that is, all of the above Netscape domain strictness flags switched
604616 off).
605617
606618
@@ -609,7 +621,7 @@ combinations of the above flags:
609621 Equivalent to ``DomainStrictNoDots|DomainStrictNonDomain ``.
610622
611623
612- Cookie Objects
624+ Cookie objects
613625--------------
614626
615627:class: `Cookie ` instances have Python attributes roughly corresponding to the
@@ -627,7 +639,7 @@ internal consistency, so you should know what you're doing if you do that.
627639
628640.. attribute :: Cookie.version
629641
630- Integer or :const: ` None `. Netscape cookies have :attr: `version ` 0. :rfc: `2965 ` and
642+ Integer or `` None ` `. Netscape cookies have :attr: `version ` 0. :rfc: `2965 ` and
631643 :rfc: `2109 ` cookies have a ``version `` cookie-attribute of 1. However, note that
632644 :mod: `http.cookiejar ` may 'downgrade' RFC 2109 cookies to Netscape cookies, in which
633645 case :attr: `version ` is 0.
@@ -640,13 +652,13 @@ internal consistency, so you should know what you're doing if you do that.
640652
641653.. attribute :: Cookie.value
642654
643- Cookie value (a string), or :const: ` None `.
655+ Cookie value (a string), or `` None ` `.
644656
645657
646658.. attribute :: Cookie.port
647659
648- String representing a port or a set of ports (eg. '80', or '80,8080'), or
649- :const: ` None `.
660+ String representing a port or a set of ports (for example, '80', or '80,8080'), or
661+ `` None ` `.
650662
651663
652664.. attribute :: Cookie.domain
@@ -656,7 +668,7 @@ internal consistency, so you should know what you're doing if you do that.
656668
657669.. attribute :: Cookie.path
658670
659- Cookie path (a string, eg. ``'/acme/rocket_launchers' ``).
671+ Cookie path (a string, for example, ``'/acme/rocket_launchers' ``).
660672
661673
662674.. attribute :: Cookie.secure
@@ -666,7 +678,7 @@ internal consistency, so you should know what you're doing if you do that.
666678
667679.. attribute :: Cookie.expires
668680
669- Integer expiry date in seconds since epoch, or :const: ` None `. See also the
681+ Integer expiry date in seconds since epoch, or `` None ` `. See also the
670682 :meth: `is_expired ` method.
671683
672684
@@ -678,18 +690,18 @@ internal consistency, so you should know what you're doing if you do that.
678690.. attribute :: Cookie.comment
679691
680692 String comment from the server explaining the function of this cookie, or
681- :const: ` None `.
693+ `` None ` `.
682694
683695
684696.. attribute :: Cookie.comment_url
685697
686698 URL linking to a comment from the server explaining the function of this cookie,
687- or :const: ` None `.
699+ or `` None ` `.
688700
689701
690702.. attribute :: Cookie.rfc2109
691703
692- ``True `` if this cookie was received as an :rfc: `2109 ` cookie (ie. the cookie
704+ ``True `` if this cookie was received as an :rfc: `2109 ` cookie (that is, the cookie
693705 arrived in a :mailheader: `Set-Cookie ` header, and the value of the Version
694706 cookie-attribute in that header was 1). This attribute is provided because
695707 :mod: `http.cookiejar ` may 'downgrade' RFC 2109 cookies to Netscape cookies, in
0 commit comments