MCPcopy Index your code
hub / github.com/python/cpython / Cookie

Class Cookie

Lib/http/cookiejar.py:744–839  ·  view source on GitHub ↗

HTTP Cookie. This class represents both Netscape and RFC 2965 cookies. This is deliberately a very simple class. It just holds attributes. It's possible to construct Cookie instances that don't comply with the cookie standards. CookieJar.make_cookies is the factory function for

Source from the content-addressed store, hash-verified

742
743
744class Cookie:
745 """HTTP Cookie.
746
747 This class represents both Netscape and RFC 2965 cookies.
748
749 This is deliberately a very simple class. It just holds attributes. It's
750 possible to construct Cookie instances that don't comply with the cookie
751 standards. CookieJar.make_cookies is the factory function for Cookie
752 objects -- it deals with cookie parsing, supplying defaults, and
753 normalising to the representation used in this class. CookiePolicy is
754 responsible for checking them to see whether they should be accepted from
755 and returned to the server.
756
757 Note that the port may be present in the headers, but unspecified ("Port"
758 rather than"Port=80", for example); if this is the case, port is None.
759
760 """
761
762 def __init__(self, version, name, value,
763 port, port_specified,
764 domain, domain_specified, domain_initial_dot,
765 path, path_specified,
766 secure,
767 expires,
768 discard,
769 comment,
770 comment_url,
771 rest,
772 rfc2109=False,
773 ):
774
775 if version is not None: version = int(version)
776 if expires is not None: expires = int(float(expires))
777 if port is None and port_specified is True:
778 raise ValueError("if port is None, port_specified must be false")
779
780 self.version = version
781 self.name = name
782 self.value = value
783 self.port = port
784 self.port_specified = port_specified
785 # normalise case, as per RFC 2965 section 3.3.3
786 self.domain = domain.lower()
787 self.domain_specified = domain_specified
788 # Sigh. We need to know whether the domain given in the
789 # cookie-attribute had an initial dot, in order to follow RFC 2965
790 # (as clarified in draft errata). Needed for the returned $Domain
791 # value.
792 self.domain_initial_dot = domain_initial_dot
793 self.path = path
794 self.path_specified = path_specified
795 self.secure = secure
796 self.expires = expires
797 self.discard = discard
798 self.comment = comment
799 self.comment_url = comment_url
800 self.rfc2109 = rfc2109
801

Callers 4

test_expiresMethod · 0.90
_really_loadMethod · 0.85
_really_loadMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_expiresMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…