close response body after error check to avoid nil pointer dereference