From 6f6b2fd1d5ca6b281a841e8a31e32eb6c34c429b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Braulio=20Valdivielso=20Mart=C3=ADnez?= Date: Mon, 23 Nov 2015 20:52:06 +0100 Subject: [PATCH] Set 'Transfer-Encoding: chunked' if data file length equals 0 --- requests/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requests/models.py b/requests/models.py index 639565cf..43a297e6 100644 --- a/requests/models.py +++ b/requests/models.py @@ -446,6 +446,8 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): if data: body = self._encode_params(data) if isinstance(data, basestring) or hasattr(data, 'read'): + if hasattr(data, 'fileno') and length == 0: + self.headers['Transfer-Encoding'] = 'chunked' content_type = None else: content_type = 'application/x-www-form-urlencoded'