Attach Content-Length to everything.
authorIan Cordasco <graffatcolmingov@gmail.com>
Sun, 25 Nov 2012 02:47:47 +0000 (21:47 -0500)
committerIan Cordasco <graffatcolmingov@gmail.com>
Sun, 25 Nov 2012 02:47:47 +0000 (21:47 -0500)
Closes #223

requests/models.py

index 9c0666a6094e3c4f2d6b17d4fab75dd29c64b9ff..84fae6e36843241a283e08e5c163ad16005e605e 100644 (file)
@@ -541,6 +541,10 @@ class Request(object):
                 else:
                     content_type = 'application/x-www-form-urlencoded'
 
+        self.headers['Content-Length'] = '0'
+        if body is not None:
+            self.headers['Content-Length'] = str(len(body))
+
         # Add content-type if it wasn't explicitly provided.
         if (content_type) and (not 'content-type' in self.headers):
             self.headers['Content-Type'] = content_type