diff --git a/coreapi/transports/http.py b/coreapi/transports/http.py index 7338e61..9ab7b9d 100644 --- a/coreapi/transports/http.py +++ b/coreapi/transports/http.py @@ -296,12 +296,6 @@ def _decode_result(response, decoders, force_codec=False): # No content returned in response. result = None - # Coerce 4xx and 5xx codes into errors. - is_error = response.status_code >= 400 and response.status_code <= 599 - if is_error and not isinstance(result, Error): - default_title = '%d %s' % (response.status_code, response.reason) - result = _coerce_to_error(result, default_title=default_title) - return result @@ -378,6 +372,7 @@ def transition(self, link, decoders, params=None, link_ancestors=None, force_cod request = _build_http_request(session, url, method, headers, encoding, params) settings = session.merge_environment_settings(request.url, None, None, None, None) response = session.send(request, **settings) + response.raise_for_status() result = _decode_result(response, decoders, force_codec) if isinstance(result, Document) and link_ancestors: diff --git a/tests/test_integration.py b/tests/test_integration.py index 0a2e602..31661f5 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -23,6 +23,9 @@ def __init__(self, content): self.url = 'http://example.org' self.status_code = 200 + def raise_for_status(self): + pass + # Basic integration tests. diff --git a/tests/test_transport.py b/tests/test_transport.py index eeeb17a..8038edb 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -26,6 +26,9 @@ def __init__(self, content): self.url = 'http://example.org' self.status_code = 200 + def raise_for_status(self): + pass + # Test transport errors.