1. Mariano Mara
  2. webob-screwup-backup


Sergey Schetinin  committed f19b918

fix del req.body, del rel.cache_control

  • Participants
  • Parent commits 683a6b1
  • Branches default

Comments (0)

Files changed (2)

File tests/test_request.py

View file
-from webob import Request
+from webob import Request, BaseRequest
 from webtest import TestApp
 from nose.tools import eq_, ok_, assert_raises
 from cStringIO import StringIO
     assert req.body_file is old_body_file
+def test_set_body():
+    req = BaseRequest.blank('/', body='foo')
+    eq_(req.body, 'foo')
+    eq_(req.content_length, 3)
+    del req.body
+    eq_(req.body, '')
+    eq_(req.content_length, 0)
 def test_broken_clen_header():
     # if the UA sends "content_length: ..' header (the name is wrong)

File webob/request.py

View file
         self.body_file = body_file
         self.environ['CONTENT_LENGTH'] = str(len(value))
-    def _body__del(self, value):
+    def _body__del(self):
         del self.body_file
     body = property(_body__get, _body__set, _body__del, doc=_body__get.__doc__)
         input = self.body_file
         if hasattr(input, 'seek'):
             # Just in case someone has read parts of the body already
-            ## FIXME: Should we use .tell() to try to put the body
-            ## back to its previous position?
         if length in (-1, None):
             body = self.body
             env['HTTP_CACHE_CONTROL'] = str(value)
             env['webob._cache_control'] = (None, None)
-    def _cache_control__del(self, value):
+    def _cache_control__del(self):
         env = self.environ
         if 'HTTP_CACHE_CONTROL' in env:
             del env['HTTP_CACHE_CONTROL']