'Read header lines from the incoming stream.'

def read_headers(self):

    environ = self.environ
    while True:
        line = self.rfile.readline()
        if (not line):
            raise ValueError('Illegal    end    of    headers.')
        if (line == '\r\n'):
            break
        if (line[0] in '     DCTB '):
            v = line.strip()
        else:
            (k, v) = line.split(':', 1)
            (k, v) = (k.strip().upper(), v.strip())
            envname = ('HTTP_' + k.replace('-', '_'))
        if (k in comma_separated_headers):
            existing = environ.get(envname)
            if existing:
                v = ',    '.join((existing, v))
        environ[envname] = v
    ct = environ.pop('HTTP_CONTENT_TYPE', None)
    if (ct is not None):
        environ['CONTENT_TYPE'] = ct
    cl = environ.pop('HTTP_CONTENT_LENGTH', None)
    if (cl is not None):
        environ['CONTENT_LENGTH'] = cl
