MCPcopy
hub / github.com/psf/requests / create_cookie

Function create_cookie

src/requests/cookies.py:494–528  ·  view source on GitHub ↗

Make a cookie from underspecified parameters. By default, the pair of `name` and `value` will be set for the domain '' and sent on every request (this is sometimes called a "supercookie").

(name: str, value: str, **kwargs: Any)

Source from the content-addressed store, hash-verified

492
493
494def create_cookie(name: str, value: str, **kwargs: Any) -> Cookie:
495 """Make a cookie from underspecified parameters.
496
497 By default, the pair of `name` and `value` will be set for the domain ''
498 and sent on every request (this is sometimes called a "supercookie").
499 """
500 result: dict[str, Any] = {
501 "version": 0,
502 "name": name,
503 "value": value,
504 "port": None,
505 "domain": "",
506 "path": "/",
507 "secure": False,
508 "expires": None,
509 "discard": True,
510 "comment": None,
511 "comment_url": None,
512 "rest": {"HttpOnly": None},
513 "rfc2109": False,
514 }
515
516 badargs = set(kwargs) - set(result)
517 if badargs:
518 raise TypeError(
519 f"create_cookie() got unexpected keyword arguments: {list(badargs)}"
520 )
521
522 result.update(kwargs)
523 result["port_specified"] = bool(result["port"])
524 result["domain_specified"] = bool(result["domain"])
525 result["domain_initial_dot"] = result["domain"].startswith(".")
526 result["path_specified"] = bool(result["path"])
527
528 return cookielib.Cookie(**result)
529
530
531def morsel_to_cookie(morsel: Morsel[Any]) -> Cookie:

Callers 3

setMethod · 0.85
morsel_to_cookieFunction · 0.85
cookiejar_from_dictFunction · 0.85

Calls 1

updateMethod · 0.80

Tested by

no test coverage detected