def read_headers(cls, fp):
        """Read HTTP headers from a file handle."""
        headers = httputil.HeaderMap()
        while True:
            line = fp.readline()
            if not line:
                # No more data--illegal end of headers
                raise EOFError('Illegal end of headers.')

            if line == b'\r\n':
                # Normal end of headers
                break
            if not line.endswith(b'\r\n'):
                raise ValueError('MIME requires CRLF terminators: %r' % line)

            if line[0] in b' \t':
                # It's a continuation line.
                v = line.strip().decode('ISO-8859-1')
            else:
                k, v = line.split(b':', 1)
                k = k.strip().decode('ISO-8859-1')
                v = v.strip().decode('ISO-8859-1')

            existing = headers.get(k)
            if existing:
                v = ', '.join((existing, v))
            headers[k] = v

        return headers
Read HTTP headers from a file handle.
cherrypy/_cpreqbody.py