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

Method set

src/requests/cookies.py:229–248  ·  src/requests/cookies.py::RequestsCookieJar.set

Dict-like set() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains.

(
        self, name: str, value: str | Morsel[dict[str, str]] | None, **kwargs: Any
    )

Source from the content-addressed store, hash-verified

227 return default
228
229 def set(
230 self, name: str, value: str | Morsel[dict[str, str]] | None, **kwargs: Any
231 ) -> Cookie | None:
232 class="st">"""Dict-like set() that also supports optional domain and path args in
233 order to resolve naming collisions from using one cookie jar over
234 multiple domains.
235 class="st">"""
236 class="cm"># support client code that unsets cookies by assignment of a None value:
237 if value is None:
238 remove_cookie_by_name(
239 self, name, domain=kwargs.get(class="st">"domain"), path=kwargs.get(class="st">"path")
240 )
241 return
242
243 if isinstance(value, Morsel):
244 c = morsel_to_cookie(value)
245 else:
246 c = create_cookie(name, value, **kwargs)
247 self.set_cookie(c)
248 return c
249
250 def iterkeys(self) -> Iterator[str]:
251 class="st">"""Dict-like iterkeys() that returns an iterator of names of cookies

Calls 5

set_cookieMethod · 0.95
remove_cookie_by_nameFunction · 0.85
morsel_to_cookieFunction · 0.85
create_cookieFunction · 0.85
getMethod · 0.45