chromium/third_party/blink/web_tests/external/wpt/service-workers/service-worker/navigation-preload/resources/request-headers-scope.py

import json

from wptserve.utils import isomorphic_decode

def main(request, response):
    normalized = dict()

    for key, values in dict(request.headers).items():
        values = [isomorphic_decode(value) for value in values]
        normalized[isomorphic_decode(key.upper())] = values

    response.headers.append(b"Content-Type", b"text/html")

    return json.dumps(normalized)