Skip to content

Commit 75d55bf

Browse files
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.
1 parent 5519774 commit 75d55bf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

algoliasearch/index.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,11 @@ def browse_from(self, params=None, cursor=None, request_options=None):
551551
params = {}
552552
if cursor:
553553
params = {'cursor': cursor}
554-
return self._req(True, '/browse', 'GET', request_options, params)
554+
555+
if not params:
556+
return self._req(True, '/browse', 'GET', request_options, params)
557+
else:
558+
return self._req(True, '/browse', 'POST', request_options, None, params)
555559

556560
def browse_all(self, params=None, request_options=None):
557561
"""

tests/test_index.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ def test_browse_all(ro_index):
391391
assert set(ro_index.ids) == set(res_ids)
392392

393393

394+
def test_browse_from(ro_index):
395+
tmp = ro_index.browse(0, 4)
396+
it = ro_index.browse_from(cursor=tmp['cursor'])
397+
assert len(it['hits']) == 1
398+
399+
394400
def test_search(ro_index):
395401
res = ro_index.search('')
396402
assert res['nbHits'] == 5

0 commit comments

Comments
 (0)