Commits

Sergey Schetinin committed b530d7c

deprecate Response.request and Response.environ

Comments (0)

Files changed (1)

webob/response.py

         if isinstance(body, unicode):
             raise _error_unicode_in_app_iter(app_iter, body)
         self._app_iter = [body]
-        if (self._environ is not None and
-            self._environ['REQUEST_METHOD'] == 'HEAD'):
-            assert len(body) == 0, "HEAD responses must be empty"
-        elif len(body) == 0:
+        if len(body) == 0:
             # if body-length is zero, we assume it's a HEAD response and
             # leave content_length alone
             pass # pragma: no cover (no idea why necessary, it's hit)
         """
         Return the request associated with this response if any.
         """
+        _warn_req()
         if self._request is None and self._environ is not None:
             self._request = self.RequestClass(self._environ)
         return self._request
 
     def _request__set(self, value):
+        _warn_req()
         if value is None:
             del self.request
             return
             self._environ = value.environ
 
     def _request__del(self):
+        _warn_req()
         self._request = self._environ = None
 
     request = property(_request__get, _request__set, _request__del,
         Get/set the request environ associated with this response, if
         any.
         """
+        _warn_req()
         return self._environ
 
     def _environ__set(self, value):
+        _warn_req()
         if value is None:
             del self.environ
         self._environ = value
         self._request = None
 
     def _environ__del(self):
+        _warn_req()
         self._request = self._environ = None
 
     environ = property(_environ__get, _environ__set, _environ__del,
 def _warn_ubody():
     warn_deprecation(".unicode_body is deprecated in favour of Response.text", '1.3', 3)
 
+def _warn_req():
+    warn_deprecation("Response.request and Response.environ are deprecated", '1.2', 3)
+
 def _error_unicode_in_app_iter(app_iter, body):
     app_iter_repr = repr(app_iter)
     if len(app_iter_repr) > 50: