@classmethod
def parse(cls, headers):
    """Returns a dictionary from HTTP header text.

        >>> h = HTTPHeaders.parse(
            "Content-Type: text/html\\r\\nContent-Length: 42\\r\\n")
        >>> sorted(h.items())
        [('Content-Length', '42'), ('Content-Type', 'text/html')]
        """
    h = cls()
    for line in headers.splitlines():
        if line:
            h.parse_line(line)
    return h
