summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/resources/echo-content.py
blob: 5e137e15d7d3b0f684b7a1a2aa0b27a719730eb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
from wptserve.utils import isomorphic_encode

def main(request, response):

    headers = [(b"X-Request-Method", isomorphic_encode(request.method)),
               (b"X-Request-Content-Length", request.headers.get(b"Content-Length", b"NO")),
               (b"X-Request-Content-Type", request.headers.get(b"Content-Type", b"NO")),
               # Avoid any kind of content sniffing on the response.
               (b"Content-Type", b"text/plain")]
    content = request.body

    return headers, content