Skip to content

Commit

Permalink
adapter.http: change the limit and cursor check
Browse files Browse the repository at this point in the history
  • Loading branch information
Frosty2500 committed May 9, 2024
1 parent 458e401 commit d4cf4b2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions basyx/aas/adapter/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,13 @@ def _get_submodel_reference(cls, aas: model.AssetAdministrationShell, submodel_i

@classmethod
def _get_slice(cls, request: Request, iterator: Iterator[T]) -> Tuple[Iterator[T], int]:
limit = request.args.get('limit', type=int, default=10)
cursor = request.args.get('cursor', type=int, default=0)
limit_str= request.args.get('limit', type=str, default="10")
cursor_str= request.args.get('cursor', type=str, default="0")
if not limit_str.isdigit() or not cursor_str.isdigit():
limit = request.args.get('limit', default="10")
cursor = request.args.get('cursor', default="0")
try:
limit, cursor = int(limit), int(cursor)
if limit < 0 or cursor < 0:
raise ValueError
except ValueError:
raise BadRequest("Cursor and limit must be positive integers!")
start_index = cursor
end_index = cursor + limit
Expand Down

0 comments on commit d4cf4b2

Please sign in to comment.