- req = get(self._ressource, params=payload,
- timeout=SOCKET_TIMEOUT)
- self.__class__.ratelimit = req.headers.get('x-ratelimit-remaining', None)
- if req.status_code is not 200:
- raise WSHTTPError(req.status_code)
- self.current_element = req.json()
- self._controls_answer()
- if self.caching:
- SimaEch.cache.update({req.url:
- Cache(self.current_element)})
-
- def _controls_answer(self):
+ sess = Session()
+ resp = sess.send(prepreq, timeout=SOCKET_TIMEOUT)
+ if resp.status_code == 304:
+ SimaEch.stats.update(etag=SimaEch.stats.get('etag')+1)
+ resp = self.controller.update_cached_response(prepreq, resp)
+ elif resp.status_code != 200:
+ raise WSHTTPError('{0.status_code}: {0.reason}'.format(resp))
+ ans = resp.json()
+ self._controls_answer(ans)
+ SimaEch.ratelimit = resp.headers.get('x-ratelimit-remaining', None)
+ minrl = min(int(SimaEch.ratelimit), SimaEch.stats.get('minrl'))
+ SimaEch.stats.update(minrl=minrl)
+ if self.cache:
+ self.controller.cache_response(resp.request, resp)
+ return ans
+
+ def _controls_answer(self, ans):