Only switch to chunked if we don't know the length of a file like object. This fixes...
authorJeff Mancuso <jmancuso@gmail.com>
Thu, 23 May 2013 15:21:29 +0000 (11:21 -0400)
committerJeff Mancuso <jmancuso@gmail.com>
Thu, 23 May 2013 15:21:29 +0000 (11:21 -0400)
requests/models.py

index 6cf2aaa..d894d9f 100644 (file)
@@ -364,7 +364,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
         try:
             length = super_len(data)
         except (TypeError, AttributeError):
-            length = False
+            length = None
 
         if is_stream:
             body = data
@@ -372,7 +372,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
             if files:
                 raise NotImplementedError('Streamed bodies and files are mutually exclusive.')
 
-            if length:
+            if length is not None:
                 self.headers['Content-Length'] = str(length)
             else:
                 self.headers['Transfer-Encoding'] = 'chunked'