summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/infrastructure/urls/resolving-urls/query-encoding/resources/stash.py
blob: d6e3dd5ea50b3a5e493f50f048fe377a76293bb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import time
import re

def main(request, response):
    key = request.GET['id']
    action = request.GET['action']
    if action == 'put':
        # We want the raw input for 'q'
        q = re.search(r'q=([^&]+)', request.url_parts.query).groups()[0]
        request.server.stash.put(key, q)
        return [("Content-Type", "text/html")], 'Put %s' % q
    else:
        q = request.server.stash.take(key)
        if q != None:
            return [("Content-Type", "text/html")], q
        return [], ""