summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/form-submission-target/resources/form-target-request-header-helper.py
blob: 80770167a8fb53e6b7955f0f94a1dcdab37c8289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
body_template="""
<script>
const channel = new BroadcastChannel('{}');
channel.postMessage('{}', '*');
window.close();
</script>
"""
def main(request, response):
    has_content_type = bool(request.headers.get(b'Content-Type'))
    result = u"OK" if has_content_type else u"FAIL"
    channel_name = request.body.decode('utf-8').split("=")[1];
    body = body_template.format(channel_name, result);
    headers = [(b"Content-Type", b"text/html")]
    return headers, body