content.py (829B)
1 from wptserve.utils import isomorphic_encode 2 3 def main(request, response): 4 response_ctype = b'' 5 6 if b"response_charset_label" in request.GET: 7 response_ctype = b";charset=" + request.GET.first(b"response_charset_label") 8 9 headers = [(b"Content-type", b"text/plain" + response_ctype), 10 (b"X-Request-Method", isomorphic_encode(request.method)), 11 (b"X-Request-Query", isomorphic_encode(request.url_parts.query) if request.url_parts.query else b"NO"), 12 (b"X-Request-Content-Length", request.headers.get(b"Content-Length", b"NO")), 13 (b"X-Request-Content-Type", request.headers.get(b"Content-Type", b"NO"))] 14 15 if b"content" in request.GET: 16 content = request.GET.first(b"content") 17 else: 18 content = request.body 19 20 return headers, content