+ # Check length to reject broken request.
+ try:
+ expected_cl = int(request.META['CONTENT_LENGTH'])
+ except:
+ return HttpResponseLengthRequired(json.dumps(
+ {"__message": _("Content length required.")}
+ ))
+ # 411 if missing
+ cl = len(request.body)
+ if cl != expected_cl:
+ return HttpResponseBadRequest(json.dumps(
+ {"__message": _("Wrong content length, request probably interrupted.")}
+ ))
+