Changeset 388 for python/vendor/current/Lib/cookielib.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Lib/cookielib.py
r2 r388 1 """HTTP cookie handling for web clients.1 r"""HTTP cookie handling for web clients. 2 2 3 3 This module has (now fairly distant) origins in Gisle Aas' Perl module … … 435 435 return ", ".join(headers) 436 436 437 def _strip_quotes(text): 438 if text.startswith('"'): 439 text = text[1:] 440 if text.endswith('"'): 441 text = text[:-1] 442 return text 443 437 444 def parse_ns_headers(ns_headers): 438 445 """Ad-hoc parser for Netscape protocol cookie-attributes. … … 452 459 known_attrs = ("expires", "domain", "path", "secure", 453 460 # RFC 2109 attrs (may turn up in Netscape cookies, too) 454 " port", "max-age")461 "version", "port", "max-age") 455 462 456 463 result = [] … … 472 479 if k == "version": 473 480 # This is an RFC 2109 cookie. 481 v = _strip_quotes(v) 474 482 version_set = True 475 483 if k == "expires": 476 484 # convert expires date to seconds since epoch 477 if v.startswith('"'): v = v[1:] 478 if v.endswith('"'): v = v[:-1] 479 v = http2time(v) # None if invalid 485 v = http2time(_strip_quotes(v)) # None if invalid 480 486 pairs.append((k, v)) 481 487 … … 602 608 603 609 def request_path(request): 604 """ request-URI, as defined by RFC 2965."""610 """Path component of request-URI, as defined by RFC 2965.""" 605 611 url = request.get_full_url() 606 #scheme, netloc, path, parameters, query, frag = urlparse.urlparse(url) 607 #req_path = escape_path("".join(urlparse.urlparse(url)[2:])) 608 path, parameters, query, frag = urlparse.urlparse(url)[2:] 609 if parameters: 610 path = "%s;%s" % (path, parameters) 611 path = escape_path(path) 612 req_path = urlparse.urlunparse(("", "", path, "", query, frag)) 613 if not req_path.startswith("/"): 612 parts = urlparse.urlsplit(url) 613 path = escape_path(parts.path) 614 if not path.startswith("/"): 614 615 # fix bad RFC 2396 absoluteURI 615 req_path = "/"+req_path616 return req_path616 path = "/" + path 617 return path 617 618 618 619 def request_port(request): … … 1014 1015 not ("."+erhn).endswith(domain))): 1015 1016 _debug(" effective request-host %s (even with added " 1016 "initial dot) does not end endwith %s",1017 "initial dot) does not end with %s", 1017 1018 erhn, domain) 1018 1019 return False … … 1451 1452 # set the easy defaults 1452 1453 version = standard.get("version", None) 1453 if version is not None: version = int(version) 1454 if version is not None: 1455 try: 1456 version = int(version) 1457 except ValueError: 1458 return None # invalid version, ignore cookie 1454 1459 secure = standard.get("secure", False) 1455 1460 # (discard is also set if expires is Absent)
Note:
See TracChangeset
for help on using the changeset viewer.