Fix handling of HTTP 4xx responses