#NEWLINE# def headers_raw_to_dict( headers_raw ) : #NEWLINE# #INDENT# '\n    Convert raw headers (single multi-line bytestring)\n    to a dictionary.\n\n    For example:\n\n    >>> import w3lib.http\n    >>> w3lib.http.headers_raw_to_dict(b"Content-type: text/html\\n\\rAccept: gzip\\n\\n")   # doctest: +SKIP\n    {\'Content-type\': [\'text/html\'], \'Accept\': [\'gzip\']}\n\n    Incorrect input:\n\n    >>> w3lib.http.headers_raw_to_dict(b"Content-typt gzip\\n\\n")\n    {}\n    >>>\n\n    Argument is ``None`` (return ``None``):\n\n    >>> w3lib.http.headers_raw_to_dict(None)\n    >>>\n\n    ' #NEWLINE# if ( headers_raw is None ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# headers = headers_raw . splitlines ( ) #NEWLINE# headers_tuples = [ header . split ( b':' , 1 ) for header in headers ] #NEWLINE# return dict ( [ ( header_item [ 0 ] . strip ( ) , [ header_item [ 1 ] . strip ( ) ] ) for header_item in headers_tuples if ( len ( header_item ) == 2 ) ] )