@@ -15,17 +15,15 @@ def last_response(self):
1515 """
1616 Returns the most recent HTTP response received during pagination.
1717 """
18- return self ._http_call_context .response
18+ return self ._http_call_context .response if self . _last_request_builder is not None else None
1919
2020 @property
2121 def request_builder (self ):
2222 """
2323 Returns the appropriate request builder for the current pagination state.
2424 """
25- if self .last_response is None :
26- return self ._initial_request_builder
25+ return self ._initial_request_builder if self ._last_request_builder is None else self ._last_request_builder
2726
28- return self ._api_call .request_builder
2927
3028 @property
3129 def page_size (self ):
@@ -52,12 +50,14 @@ def __init__(self, api_call, paginated_items_converter):
5250 self ._api_call = copy .deepcopy (api_call )
5351 self ._paginated_items_converter = paginated_items_converter
5452 self ._initial_request_builder = api_call .request_builder
53+ self ._last_request_builder = None
5554 self ._pagination_strategies = self ._api_call .get_pagination_strategies
5655 self ._http_call_context = \
5756 self ._api_call .global_configuration .get_http_client_configuration ().http_callback or HttpCallContext ()
5857 _http_client_configuration = self ._api_call .global_configuration .get_http_client_configuration ().clone (
5958 http_callback = self ._http_call_context )
60- self ._global_configuration = self ._api_call .global_configuration .clone_with ()
59+ self ._global_configuration = self ._api_call .global_configuration .clone_with (
60+ http_client_configuration = _http_client_configuration )
6161 self ._paged_response = None
6262 self ._items = []
6363 self ._page_size = 0
@@ -128,6 +128,8 @@ def _fetch_next_page(self):
128128 if request_builder is None :
129129 continue
130130
131+ self ._last_request_builder = request_builder
132+
131133 response = self ._api_call .clone (
132134 global_configuration = self ._global_configuration , request_builder = request_builder
133135 ).execute ()
0 commit comments