Skip to content

Commit

Permalink
Fix calculation and test for Content-MD5
Browse files Browse the repository at this point in the history
  • Loading branch information
pneff committed Jan 17, 2012
1 parent dda8708 commit 3048984
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ def test_verify_content_md5_valid():
app = wsgiservice.get_app(globals())
req = Request.blank('/res1/theid', {
'HTTP_CONTENT_MD5': '89d5739baabbbe65be35cbe61c88e06d',
'wsgi.input': StringIO.StringIO('Foobar')})
})
req.body_file = StringIO.StringIO('Foobar')
res = app._handle_request(req)
print res
assert res.status == '200 OK'
Expand Down
2 changes: 1 addition & 1 deletion wsgiservice/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def assert_condition_md5(self):
the MD5 hash does not match the body.
"""
if 'Content-MD5' in self.request.headers:
body_md5 = hashlib.md5(self.request.body_file.read()).hexdigest()
body_md5 = hashlib.md5(self.request.body).hexdigest()
if body_md5 != self.request.headers['Content-MD5']:
raise_400(self, msg='Invalid Content-MD5 request header.')

Expand Down

0 comments on commit 3048984

Please sign in to comment.