def _urlopen(http_client, method, url, body=None, headers=None):
    """Wrapper of urlopen() handles HTTP status code."""
    res = http_client.urlopen(method, url, body=body, headers=headers)
    if res.status not in [200, 204, 206]:
        raise ValueError(
            "{0} failed with HTTP status code {1}".format(url, res.status),
        )
    return res