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 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()