diff --git a/elasticsearch/connection/base.py b/elasticsearch/connection/base.py index c0206b2e..21486679 100644 --- a/elasticsearch/connection/base.py +++ b/elasticsearch/connection/base.py @@ -61,7 +61,9 @@ class Connection(object): path = path.replace('?', '?pretty&', 1) if '?' in path else path + '?pretty' if self.url_prefix: path = path.replace(self.url_prefix, '', 1) - tracer.info("curl -X%s 'http://localhost:9200%s' -d '%s'", method, path, self._pretty_json(body) if body else '') + tracer.info("curl %s-X%s 'http://localhost:9200%s' -d '%s'", + "-H 'Content-Type: application/json' " if body else '', + method, path, self._pretty_json(body) if body else '') if tracer.isEnabledFor(logging.DEBUG): tracer.debug('#[%s] (%.3fs)\n#%s', status_code, duration, self._pretty_json(response).replace('\n', '\n#') if response else '') diff --git a/test_elasticsearch/test_connection.py b/test_elasticsearch/test_connection.py index 9282e1e1..b2d84996 100644 --- a/test_elasticsearch/test_connection.py +++ b/test_elasticsearch/test_connection.py @@ -164,7 +164,7 @@ class TestRequestsConnection(TestCase): # trace request self.assertEquals(1, tracer.info.call_count) self.assertEquals( - """curl -XGET 'http://localhost:9200/?pretty¶m=42' -d '{\n "question": "what\\u0027s that?"\n}'""", + """curl -H 'Content-Type: application/json' -XGET 'http://localhost:9200/?pretty¶m=42' -d '{\n "question": "what\\u0027s that?"\n}'""", tracer.info.call_args[0][0] % tracer.info.call_args[0][1:] ) # trace response @@ -234,6 +234,6 @@ class TestRequestsConnection(TestCase): # trace request self.assertEquals(1, tracer.info.call_count) self.assertEquals( - "curl -XGET 'http://localhost:9200/_search?pretty' -d '{\n \"answer\": 42\n}'", + "curl -H 'Content-Type: application/json' -XGET 'http://localhost:9200/_search?pretty' -d '{\n \"answer\": 42\n}'", tracer.info.call_args[0][0] % tracer.info.call_args[0][1:] )