(self)
| 275 | return self._get_response() |
| 276 | |
| 277 | def _get_response(self): |
| 278 | http_response = self.__conn.getresponse() |
| 279 | if http_response is None: |
| 280 | raise JSONRPCError({ |
| 281 | 'code': -342, 'message': 'missing HTTP response from server'}) |
| 282 | |
| 283 | rdata = http_response.read().decode('utf8') |
| 284 | try: |
| 285 | return json.loads(rdata, parse_float=decimal.Decimal) |
| 286 | except Exception: |
| 287 | raise JSONRPCError({ |
| 288 | 'code': -342, |
| 289 | 'message': ('non-JSON HTTP response with \'%i %s\' from server: \'%.20s%s\'' |
| 290 | % (http_response.status, http_response.reason, |
| 291 | rdata, '...' if len(rdata) > 20 else ''))}) |
| 292 | |
| 293 | def close(self): |
| 294 | if self.__conn is not None: |
no test coverage detected