Raise exception for error status before attempting to parse content
Change-Id: I52041f3795f7ee8962aa1a69e9a2fd7e100ccc8a
David Pursehouse
5 years ago
56 | 56 | content_type = response.headers.get('content-type', '') |
57 | 57 | logger.debug("status[%s] content_type[%s] encoding[%s]" % |
58 | 58 | (response.status_code, content_type, response.encoding)) |
59 | response.raise_for_status() | |
59 | 60 | content = response.content.strip() |
60 | 61 | if response.encoding: |
61 | 62 | content = content.decode(response.encoding) |
62 | response.raise_for_status() | |
63 | 63 | if content_type.split(';')[0] != 'application/json': |
64 | 64 | return content |
65 | 65 | if content.startswith(GERRIT_MAGIC_JSON_PREFIX): |