Skip to content

Commit f73205c

Browse files
committed
Do not escape the global request_timeout param
Thanks EyePulp for the report!
1 parent 6e3de80 commit f73205c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

elasticsearch/client/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _make_path(*parts):
4646
quote_plus(_escape(p), b',*') for p in parts if p not in SKIP_IN_PATH)
4747

4848
# parameters that apply to all methods
49-
GLOBAL_PARAMS = ('pretty', 'format', 'request_timeout')
49+
GLOBAL_PARAMS = ('pretty', 'format')
5050

5151
def query_params(*es_query_params):
5252
"""
@@ -61,9 +61,10 @@ def _wrapped(*args, **kwargs):
6161
if p in kwargs:
6262
params[p] = _escape(kwargs.pop(p))
6363

64-
# don't treat ignore as other params to avoid escaping
65-
if 'ignore' in kwargs:
66-
params['ignore'] = kwargs.pop('ignore')
64+
# don't treat ignore and request_timeout as other params to avoid escaping
65+
for p in ('ignore', 'request_timeout'):
66+
if p in kwargs:
67+
params[p] = kwargs.pop(p)
6768
return func(*args, params=params, **kwargs)
6869
return _wrapped
6970
return _wrapper

test_elasticsearch/test_client/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def test_single_string_is_wrapped_in_list(self):
3939

4040

4141
class TestClient(ElasticsearchTestCase):
42+
def test_request_timeout_is_passed_through_unescaped(self):
43+
self.client.ping(request_timeout=.1)
44+
calls = self.assert_url_called('HEAD', '/')
45+
self.assertEquals([({'request_timeout': .1}, None)], calls)
46+
4247
def test_from_in_search(self):
4348
self.client.search(index='i', doc_type='t', from_=10)
4449
calls = self.assert_url_called('GET', '/i/t/_search')

0 commit comments

Comments
 (0)