echo-content.py (652B)
1 # This is a copy of fetch/api/resources/echo-content.py since it's more 2 # convenient in this directory due to service worker's path restriction. 3 from wptserve.utils import isomorphic_encode 4 5 def main(request, response): 6 7 headers = [(b"X-Request-Method", isomorphic_encode(request.method)), 8 (b"X-Request-Content-Length", request.headers.get(b"Content-Length", b"NO")), 9 (b"X-Request-Content-Type", request.headers.get(b"Content-Type", b"NO")), 10 11 # Avoid any kind of content sniffing on the response. 12 (b"Content-Type", b"text/plain")] 13 14 content = request.body 15 16 return headers, content