(self, response, status_code, include_cache_info=True)
| 150 | return instance_class(json) |
| 151 | |
| 152 | def _json(self, response, status_code, include_cache_info=True): |
| 153 | ret = None |
| 154 | if self._boolean(response, status_code, 404) and response.content: |
| 155 | __logs__.info('Attempting to get JSON information from a Response ' |
| 156 | 'with status code %d expecting %d', |
| 157 | response.status_code, status_code) |
| 158 | ret = response.json() |
| 159 | headers = response.headers |
| 160 | if (include_cache_info and |
| 161 | (headers.get('Last-Modified') or headers.get('ETag')) and |
| 162 | isinstance(ret, dict)): |
| 163 | ret['Last-Modified'] = response.headers.get( |
| 164 | 'Last-Modified', '' |
| 165 | ) |
| 166 | ret['ETag'] = response.headers.get('ETag', '') |
| 167 | __logs__.info('JSON was %sreturned', 'not ' if ret is None else '') |
| 168 | return ret |
| 169 | |
| 170 | def _boolean(self, response, true_code, false_code): |
| 171 | if response is not None: |
no test coverage detected