Set a content-length for JSON responses

This commit is contained in:
Mark Haines 2015-01-06 13:05:07 +00:00
parent 78edb47cc5
commit 773de09774

View File

@ -233,6 +233,7 @@ def respond_with_json_bytes(request, code, json_bytes, send_cors=False,
request.setResponseCode(code, message=response_code_message) request.setResponseCode(code, message=response_code_message)
request.setHeader(b"Content-Type", b"application/json") request.setHeader(b"Content-Type", b"application/json")
request.setHeader(b"Server", AGENT_NAME) request.setHeader(b"Server", AGENT_NAME)
request.setHeader(b"Content-Length", b"%d" % len(json_bytes))
if send_cors: if send_cors:
request.setHeader("Access-Control-Allow-Origin", "*") request.setHeader("Access-Control-Allow-Origin", "*")