def parse_headers(client):
    """
    Parses the header portion of an HTTP request from the socket.
    Expects first line of HTTP request to have been read already.
    """
    headers = {}
    while True:
        line = str(client.readline(), "utf-8")
        if not line:
            break
        title, content = line.split(":", 1)
        headers[title.strip().lower()] = content.strip()
    return headers