def parse_headers(str):
    """Parses a HTTP-style headers"""
    headers = {}
    for line in str.split('\n'):
        if len(line) == 0:
            continue
        key, value = line.split(': ', 1)
        headers[key] = value
    return headers
