
    a
                     $    d dl mZ d Zd ZddZy)    )urlsafe_b64encodec                 .   | y| j                         }|D cg c]  }|j                  dd       }}i }|D ]V  }t        |      dk(  s|d   j                         }|d   j                         }||v r||   j	                  |       Q|g||<   X |S c c}w )a  
    Convert raw headers (single multi-line bytestring)
    to a dictionary.

    For example:

    >>> import w3lib.http
    >>> w3lib.http.headers_raw_to_dict(b"Content-type: text/html\n\rAccept: gzip\n\n")   # doctest: +SKIP
    {'Content-type': ['text/html'], 'Accept': ['gzip']}

    Incorrect input:

    >>> w3lib.http.headers_raw_to_dict(b"Content-typt gzip\n\n")
    {}
    >>>

    Argument is ``None`` (return ``None``):

    >>> w3lib.http.headers_raw_to_dict(None)
    >>>

    N   :      r   )
splitlinessplitlenstripappend)headers_rawheadersheaderheaders_tuplesresult_dictheader_itemitem_key
item_values           *lib/python3.12/site-packages/w3lib/http.pyheaders_raw_to_dictr      s    0 $$&G:AB'fll4+'NBK%;1$q>'') ^))+
{"!((4%/LK! &  Cs   Bc                 D   | yg }| j                         D ]x  \  }}t        |t              r#|j                  dj	                  ||g             9t        |t
        t        f      sP|D ]$  }|j                  dj	                  ||g             & z dj	                  |      S )a  
    Returns a raw HTTP headers representation of headers

    For example:

    >>> import w3lib.http
    >>> w3lib.http.headers_dict_to_raw({b'Content-type': b'text/html', b'Accept': b'gzip'}) # doctest: +SKIP
    'Content-type: text/html\\r\\nAccept: gzip'
    >>>

    Note that keys and values must be bytes.

    Argument is ``None`` (returns ``None``):

    >>> w3lib.http.headers_dict_to_raw(None)
    >>>

    Ns   : s   
)items
isinstancebytesr   joinlisttuple)headers_dict	raw_lineskeyvaluevs        r   headers_dict_to_rawr#   1   s    ( I"((*
UeU#UZZe56e}-  S!H!56 	 + <<	""    c                 n    | d|}t        |t              s|j                  |      }dt        |      z   S )aA  
    Return an `Authorization` header field value for `HTTP Basic Access Authentication (RFC 2617)`_

    >>> import w3lib.http
    >>> w3lib.http.basic_auth_header('someuser', 'somepass')
    'Basic c29tZXVzZXI6c29tZXBhc3M='

    .. _HTTP Basic Access Authentication (RFC 2617): http://www.ietf.org/rfc/rfc2617.txt

    :s   Basic )r   r   encoder   )usernamepasswordencodingauths       r   basic_auth_headerr,   Q   s9     )DdE" {{8$(...r$   N)z
ISO-8859-1)base64r   r   r#   r,    r$   r   <module>r/      s    $*Z#@/r$   