summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/Document-contentType/support/contenttype_setter.py
blob: c4b1f8df27c1ef03ecbe7b6e8d4e238d8997248b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def main(request, response):
    type = request.GET.first(b"type", None)
    subtype = request.GET.first(b"subtype", None)
    if type and subtype:
        response.headers[b"Content-Type"] = type + b"/" + subtype

    removeContentType = request.GET.first(b"removeContentType", None)
    if removeContentType:
        try:
            del response.headers[b"Content-Type"]
        except KeyError:
            pass

    content = b'<head>'
    mimeHead = request.GET.first(b"mime", None);
    if mimeHead:
        content += b'<meta http-equiv="Content-Type" content="%s; charset=utf-8"/>' % mimeHead
    content += b"</head>"

    return content