From 49e5213c4e0e3d21dcb3bb6af430650b1969ad4e Mon Sep 17 00:00:00 2001 From: MIkhail Gulyaev Date: Sat, 12 Dec 2015 10:33:59 +0500 Subject: [PATCH 1/2] rewind file body for retry send request --- python2/httplib2/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python2/httplib2/__init__.py b/python2/httplib2/__init__.py index 6fa3cc6..84ee727 100644 --- a/python2/httplib2/__init__.py +++ b/python2/httplib2/__init__.py @@ -1270,6 +1270,8 @@ def _conn_request(self, conn, request_uri, method, body, headers): try: if hasattr(conn, 'sock') and conn.sock is None: conn.connect() + if hasattr(body, 'tell') and body.tell() > 0: + body.seek(0) # rewind for retry send file conn.request(method, request_uri, body, headers) except socket.timeout: raise From a0ae521eb05d37316ea291e1e9297e6c848cc190 Mon Sep 17 00:00:00 2001 From: MIkhail Gulyaev Date: Tue, 15 Dec 2015 10:39:54 +0500 Subject: [PATCH 2/2] rewind file body for retry send request python3 --- python3/httplib2/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python3/httplib2/__init__.py b/python3/httplib2/__init__.py index 3ce019e..c21a8a8 100644 --- a/python3/httplib2/__init__.py +++ b/python3/httplib2/__init__.py @@ -985,6 +985,8 @@ def _conn_request(self, conn, request_uri, method, body, headers): try: if conn.sock is None: conn.connect() + if hasattr(body, 'tell') and body.tell() > 0: + body.seek(0) # rewind for retry send file conn.request(method, request_uri, body, headers) except socket.timeout: conn.close()