'Read and decode a PyPI HTTP response.'

def _read_pypi_response(self, response):

    import cgi
    content_type = response.getheader('content-type', 'text/plain')
    encoding = cgi.parse_header(content_type)[1].get('charset', 'ascii')
    return response.read().decode(encoding)
