diff --git a/elasticsearch/connection/http_urllib3.py b/elasticsearch/connection/http_urllib3.py index 14705dad..22f2795b 100644 --- a/elasticsearch/connection/http_urllib3.py +++ b/elasticsearch/connection/http_urllib3.py @@ -40,10 +40,7 @@ class Urllib3HttpConnection(Connection): kw = {} if timeout: kw['timeout'] = timeout - headers = self.headers.copy() - if body: - headers['content-length'] = str(len(body)) - response = self.pool.urlopen(method, url, body, retries=False, headers=headers, **kw) + response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw) duration = time.time() - start raw_data = response.data.decode('utf-8') except Exception as e: diff --git a/test_elasticsearch/test_connection.py b/test_elasticsearch/test_connection.py index d9866353..e1448a2a 100644 --- a/test_elasticsearch/test_connection.py +++ b/test_elasticsearch/test_connection.py @@ -53,14 +53,6 @@ class TestUrllib3Connection(TestCase): con = Urllib3HttpConnection() self.assertIsInstance(con.pool, urllib3.HTTPConnectionPool) - def test_content_length_gets_set(self): - con = Urllib3HttpConnection() - m = con.pool.urlopen = Mock() - m.return_value.status = 200 - - con.perform_request('PUT', '/', body='0123456789'.encode('utf-8')) - m.assert_called_once_with('PUT', '/', '0123456789'.encode('utf-8'), headers={'content-length': '10'}, retries=False) - class TestRequestsConnection(TestCase): def _get_mock_connection(self, connection_params={}, status_code=200, response_body='{}'): con = RequestsHttpConnection(**connection_params)