summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/pywebsocket/src/example/cookie_wsh.py
blob: 8b327152e701f7d2031d7c9ce04624cfa84ac16d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright 2014 Google Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the COPYING file or at
# https://developers.google.com/open-source/licenses/bsd


import urlparse


def _add_set_cookie(request, value):
    request.extra_headers.append(('Set-Cookie', value))


def web_socket_do_extra_handshake(request):
    components = urlparse.urlparse(request.uri)
    command = components[4]

    ONE_DAY_LIFE = 'Max-Age=86400'

    if command == 'set':
        _add_set_cookie(request, '; '.join(['foo=bar', ONE_DAY_LIFE]))
    elif command == 'set_httponly':
        _add_set_cookie(request,
            '; '.join(['httpOnlyFoo=bar', ONE_DAY_LIFE, 'httpOnly']))
    elif command == 'clear':
        _add_set_cookie(request, 'foo=0; Max-Age=0')
        _add_set_cookie(request, 'httpOnlyFoo=0; Max-Age=0')


def web_socket_transfer_data(request):
    pass