From 38661ec508e8181b80e2fd8c6d1161d6cf3b1537 Mon Sep 17 00:00:00 2001 From: Honza Kral Date: Sat, 8 Jun 2013 01:26:13 +0200 Subject: [PATCH] HEAD requests return no body --- elasticsearch/client.py | 7 +++++-- elasticsearch/transport.py | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/elasticsearch/client.py b/elasticsearch/client.py index cd0d966c..b1633058 100644 --- a/elasticsearch/client.py +++ b/elasticsearch/client.py @@ -107,8 +107,11 @@ class InidicesClient(NamespacedClient): :arg index: A comma-separated list of indices to check """ - status, data = self.transport.perform_request('HEAD', '/' + _normalize_list(index), params=params) - return data + try: + self.transport.perform_request('HEAD', '/' + _normalize_list(index), params=params) + except NotFoundError: + return False + return True class Elasticsearch(object): diff --git a/elasticsearch/transport.py b/elasticsearch/transport.py index 339b0c96..14d4f25e 100644 --- a/elasticsearch/transport.py +++ b/elasticsearch/transport.py @@ -226,5 +226,8 @@ class Transport(object): # resurrected connection didn't fail, confirm it's live status if dead_count: self.connection_pool.mark_live(connection) - return status, self.serializer.loads(raw_data) + data = None + if raw_data: + data = self.serializer.loads(raw_data) + return status, data