morsel_to_cookie() — requests Function Reference
Architecture documentation for the morsel_to_cookie() function in cookies.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD bdabf6b4_0fa2_b7d3_d69f_a30b72ada980["morsel_to_cookie()"] 270696ff_2a4f_ef5b_92e8_33a79e68a2d8["cookies.py"] bdabf6b4_0fa2_b7d3_d69f_a30b72ada980 -->|defined in| 270696ff_2a4f_ef5b_92e8_33a79e68a2d8 fd64c32d_aaa4_5925_c2a7_12f040eb3704["set()"] fd64c32d_aaa4_5925_c2a7_12f040eb3704 -->|calls| bdabf6b4_0fa2_b7d3_d69f_a30b72ada980 293b1fa1_bdd4_a38c_982e_5c92a646576d["create_cookie()"] bdabf6b4_0fa2_b7d3_d69f_a30b72ada980 -->|calls| 293b1fa1_bdd4_a38c_982e_5c92a646576d style bdabf6b4_0fa2_b7d3_d69f_a30b72ada980 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/requests/cookies.py lines 492–518
def morsel_to_cookie(morsel):
"""Convert a Morsel object into a Cookie containing the one k/v pair."""
expires = None
if morsel["max-age"]:
try:
expires = int(time.time() + int(morsel["max-age"]))
except ValueError:
raise TypeError(f"max-age: {morsel['max-age']} must be integer")
elif morsel["expires"]:
time_template = "%a, %d-%b-%Y %H:%M:%S GMT"
expires = calendar.timegm(time.strptime(morsel["expires"], time_template))
return create_cookie(
comment=morsel["comment"],
comment_url=bool(morsel["comment"]),
discard=False,
domain=morsel["domain"],
expires=expires,
name=morsel.key,
path=morsel["path"],
port=None,
rest={"HttpOnly": morsel["httponly"]},
rfc2109=False,
secure=bool(morsel["secure"]),
value=morsel.value,
version=morsel["version"] or 0,
)
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does morsel_to_cookie() do?
morsel_to_cookie() is a function in the requests codebase, defined in src/requests/cookies.py.
Where is morsel_to_cookie() defined?
morsel_to_cookie() is defined in src/requests/cookies.py at line 492.
What does morsel_to_cookie() call?
morsel_to_cookie() calls 1 function(s): create_cookie.
What calls morsel_to_cookie()?
morsel_to_cookie() is called by 1 function(s): set.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free