From 75d55bf8a8b8c2751372b42b2e262f7f23e368fd Mon Sep 17 00:00:00 2001 From: Julien Bourdeau Date: Mon, 7 May 2018 16:27:16 +0200 Subject: [PATCH] fix(browse): Ensure cursor is passed in the body Cursor can get very long and exceed the max url size, for that reason we always pass it in the body of the request. --- algoliasearch/index.py | 6 +++++- tests/test_index.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/algoliasearch/index.py b/algoliasearch/index.py index b13063bbe..936f84f10 100644 --- a/algoliasearch/index.py +++ b/algoliasearch/index.py @@ -551,7 +551,11 @@ def browse_from(self, params=None, cursor=None, request_options=None): params = {} if cursor: params = {'cursor': cursor} - return self._req(True, '/browse', 'GET', request_options, params) + + if not params: + return self._req(True, '/browse', 'GET', request_options, params) + else: + return self._req(True, '/browse', 'POST', request_options, None, params) def browse_all(self, params=None, request_options=None): """ diff --git a/tests/test_index.py b/tests/test_index.py index 555c5775f..5caa909d1 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -391,6 +391,12 @@ def test_browse_all(ro_index): assert set(ro_index.ids) == set(res_ids) +def test_browse_from(ro_index): + tmp = ro_index.browse(0, 4) + it = ro_index.browse_from(cursor=tmp['cursor']) + assert len(it['hits']) == 1 + + def test_search(ro_index): res = ro_index.search('') assert res['nbHits'] == 5