(fp, _class=HTTPMessage)
return email.parser.Parser(_class=_class).parsestr(hstring)
Parses only RFC2822 headers from a file pointer.

    email Parser wants to see strings rather than bytes.
    But a TextIOWrapper around self.rfile would buffer too many bytes
    from the stream, bytes which we later need to read as bytes.
    So we read the correct bytes here, as bytes, for email Parser
    to parse.
Parses only RFC2822 headers from a file pointer.
Parses only RFC2822 headers from a file pointer .
def parse_headers(fp, _class=HTTPMessage):
    """Parses only RFC2822 headers from a file pointer.

    email Parser wants to see strings rather than bytes.
    But a TextIOWrapper around self.rfile would buffer too many bytes
    from the stream, bytes which we later need to read as bytes.
    So we read the correct bytes here, as bytes, for email Parser
    to parse.

    """
    headers = _read_headers(fp)
    hstring = b''.join(headers).decode('iso-8859-1')
    return email.parser.Parser(_class=_class).parsestr(hstring)
def parse_headers ( fp , _class = HTTPMessage ) : headers = _read_headers ( fp ) hstring = b'' . join ( headers ) . decode ( 'iso-8859-1' ) return email . parser . Parser ( _class = _class ) . parsestr ( hstring )