projects
/
services
/
python-requests.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f003025
)
Handle files as well.
author
Ian Cordasco
<graffatcolmingov@gmail.com>
Sun, 25 Nov 2012 03:01:16 +0000
(22:01 -0500)
committer
Ian Cordasco
<graffatcolmingov@gmail.com>
Sun, 25 Nov 2012 03:02:14 +0000
(22:02 -0500)
requests/models.py
patch
|
blob
|
history
diff --git
a/requests/models.py
b/requests/models.py
index 84fae6e36843241a283e08e5c163ad16005e605e..4025dae73dc0389137f6b0917ce1f23aface6960 100644
(file)
--- a/
requests/models.py
+++ b/
requests/models.py
@@
-542,7
+542,11
@@
class Request(object):
content_type = 'application/x-www-form-urlencoded'
self.headers['Content-Length'] = '0'
- if body is not None:
+ if isinstance(body, file):
+ body.seek(0, 2)
+ self.headers['Content-Length'] = str(body.tell())
+ body.seek(0, 0)
+ elif body is not None:
self.headers['Content-Length'] = str(len(body))
# Add content-type if it wasn't explicitly provided.