summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/resources/get-set-cookie.py
blob: 234280d35300a80ba4511784ded79c4cc048a6eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import datetime

def main(request, response):
    response.headers.set(b"Content-type", b"text/plain")

    # By default use a session cookie.
    expiration = None
    if request.GET.get(b"clear"):
        # If deleting, expire yesterday.
        expiration = -datetime.timedelta(days=1)

    response.set_cookie(b"WK-test", b"1", expires=expiration)
    response.set_cookie(b"WK-test-secure", b"1", secure=True,
                        expires=expiration)
    content = b""
    for cookie in request.cookies:
        content = content + b" " + cookie + b"=" + request.cookies.get(cookie).value
    response.content = content