Fix the tests and unseparate comments from code
authorIan Cordasco <graffatcolmingov@gmail.com>
Thu, 28 Mar 2013 12:33:34 +0000 (08:33 -0400)
committerIan Cordasco <graffatcolmingov@gmail.com>
Thu, 28 Mar 2013 12:33:34 +0000 (08:33 -0400)
See the comments on the previous few commits on GitHub.

requests/models.py
requests/sessions.py

index 1451800645573da99b7cbe5313b0cc2e059bd50d..6ed2b599467f4f87e8977716ab6659073c2df47a 100644 (file)
@@ -394,7 +394,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
         elif body is not None:
             l = super_len(body)
             if l:
-                self.headers['Content-Length'] = super_len(l)
+                self.headers['Content-Length'] = str(l)
         elif self.method not in ('GET', 'HEAD'):
             self.headers['Content-Length'] = '0'
 
index 26131fc594bf04dc190adf885ec4620fde6fdb08..961fc3bc022d2c8fc884affef47fc4bc4bca3462 100644 (file)
@@ -429,12 +429,14 @@ class Session(SessionRedirectMixin):
 
     def send(self, request, **kwargs):
         """Send a given PreparedRequest."""
-        # It's possible that users might accidentally send a Request object.
-        # Guard against that specific failure case.
+        # Set defaults that the hooks can utilize to ensure they always have
+        # the correct parameters to reproduce the previous request.
         kwargs.setdefault('stream', False)
         kwargs.setdefault('verify', True)
         kwargs.setdefault('proxies', {})
 
+        # It's possible that users might accidentally send a Request object.
+        # Guard against that specific failure case.
         if getattr(request, 'prepare', None):
             raise ValueError('You can only send PreparedRequests.')