Sergey Schetinin avatar Sergey Schetinin committed f19b918

fix del req.body, del rel.cache_control

Comments (0)

Files changed (2)

tests/test_request.py

-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
     req.make_body_seekable()
     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)
         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?
             input.seek(0)
         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']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.