1. Mariano Mara
  2. WebObTestCoverage

Commits

maluke  committed cd3c4e8

Response.md5_etag(set_content_md5=True) will set Content-MD5 header of the response

  • Participants
  • Parent commits cdc7ce2
  • Branches default

Comments (0)

Files changed (1)

File webob/__init__.py

View file
 
     etag = header_getter('ETag', rfc_section='14.19')
 
-    def md5_etag(self, body=None):
+    def md5_etag(self, body=None, set_content_md5=False):
         """
         Generate an etag for the response object using an MD5 hash of
         the body (the body parameter, or ``self.body`` if not given)
 
         Sets ``self.etag``
+        If set_content_md5 is True sets self.content_md5 as well
         """
         if body is None:
             body = self.body
         import md5
         h = md5.new(body)
-        self.etag = h.digest().encode('base64').replace('\n', '').strip('=')
+        md5_digest = h.digest().encode('base64').replace('\n', '').strip('=')
+        self.etag = md5_digest
+        if set_content_md5:
+            self.content_md5 = md5_digest
 
     expires = converter(
         header_getter('Expires', rfc_section='14.21'),