def _get_charset(message):
    """Return charset, given a http.client.HTTPMessage"""
    if not message["content-type"] or not "charset=" in message["content-type"]:
        # utter guesswork
        return "utf-8"
    charset = message["content-type"].split("charset=")[1]
    return charset.split(";")[0]