Commits

Matthew Schinckel committed bc531a2

Added ContentHashMiddleware.

  • Participants
  • Parent commits 6c1b05b

Comments (0)

Files changed (1)

rest_api/middleware.py

 import datetime
 import time
 import sys
+import hashlib
 
 from timezones.utils import adjust_datetime_to_timezone
 
     #     return response
 
 
+class ContentHashMiddleware(object):
+    def process_response(self, request, response):
+        response['Content-Hash'] = hashlib.md5(response.content).hexdigest()
+        response['Content-Length'] = len(response.content)
+        return response
+
 class HttpLoggingMiddleware(object):
     def process_response(self, request, response):
         if hasattr(request, '_start_time'):