MCPcopy Create free account
hub / github.com/pallets/quart / set_cookie

Method set_cookie

src/quart/testing/client.py:280–312  ·  view source on GitHub ↗

Set a cookie in the cookie jar. The arguments are the standard cookie morsels and this is a wrapper around the stdlib SimpleCookie code.

(
        self,
        server_name: str,
        key: str,
        value: str = "",
        max_age: int | timedelta | None = None,
        expires: int | float | datetime | None = None,
        path: str = "/",
        domain: str | None = None,
        secure: bool = False,
        httponly: bool = False,
        samesite: str = None,
    )

Source from the content-addressed store, hash-verified

278 return await self.open(*args, method="TRACE", **kwargs)
279
280 def set_cookie(
281 self,
282 server_name: str,
283 key: str,
284 value: str = "",
285 max_age: int | timedelta | None = None,
286 expires: int | float | datetime | None = None,
287 path: str = "/",
288 domain: str | None = None,
289 secure: bool = False,
290 httponly: bool = False,
291 samesite: str = None,
292 ) -> None:
293 """Set a cookie in the cookie jar.
294
295 The arguments are the standard cookie morsels and this is a
296 wrapper around the stdlib SimpleCookie code.
297 """
298 cookie = dump_cookie(
299 key,
300 value=value,
301 max_age=max_age,
302 expires=expires,
303 path=path,
304 domain=domain,
305 secure=secure,
306 httponly=httponly,
307 samesite=samesite,
308 )
309 self.cookie_jar.extract_cookies(
310 _TestCookieJarResponse(Headers([("set-cookie", cookie)])), # type: ignore
311 U2Request(f"http://{server_name}{path}"),
312 )
313
314 def delete_cookie(
315 self, server_name: str, key: str, path: str = "/", domain: str | None = None

Callers 1

delete_cookieMethod · 0.95

Calls 1

Tested by

no test coverage detected