Added more robust response handling - return the inputStream for 2xx responses, errorStream for 4xx-5xx responses, and throw IOException for everything else