Skip to content

Commit 2f90ecd

Browse files
authored
Update cookiejar.py
1 parent 720c80f commit 2f90ecd

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Lib/http/cookiejar.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,15 @@ def parse_ns_headers(ns_headers):
536536
IPV4_RE = re.compile(r"\.\d+$", re.ASCII)
537537

538538
def is_ip_like_hostname(text):
539-
"""Return True if text is a valid hostname in the form of IP address."""
539+
"""Return True if text is a valid hostname in the form of IP address.
540+
541+
If text is a valid IPv4 address, retrun True;
542+
543+
If text is a valid IPv6 address wrapped in [], return True;
544+
545+
Else, return False
546+
547+
"""
540548
from ipaddress import IPv4Address, IPv6Address
541549
# check for IPv4 address
542550
try:
@@ -667,6 +675,8 @@ def eff_request_host(request):
667675
is_ipV6 = False
668676
if "." not in req_host and not is_ipV6:
669677
# avoid adding .local at the end of a IPV6 address
678+
# for the additional ".local", see RFC 2965 section 1
679+
# https://www.rfc-editor.org/rfc/rfc2965
670680
erhn = req_host + ".local"
671681
return req_host, erhn
672682

0 commit comments

Comments
 (0)