From fb230709a8d35d8d2973eab3365cb8f9664cfa90 Mon Sep 17 00:00:00 2001 From: tzickel Date: Fri, 8 Apr 2016 22:23:35 +0300 Subject: [PATCH] Fix for the test ? --- requests/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/requests/models.py b/requests/models.py index 54428882..fe4bec1b 100644 --- a/requests/models.py +++ b/requests/models.py @@ -465,9 +465,11 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): def prepare_content_length(self, body): if hasattr(body, 'seek') and hasattr(body, 'tell'): + curr_pos = body.tell() body.seek(0, 2) - self.headers['Content-Length'] = builtin_str(body.tell()) - body.seek(0, 0) + end_pos = body.tell() + self.headers['Content-Length'] = builtin_str(max(0, end_pos - curr_pos)) + body.seek(curr_pos, 0) elif body is not None: l = super_len(body) if l: