
    Wh                    8   d dl Z d dlZd dlZd dlZd dlZd dlZd dl	m
Z
 d dlmZmZ d dlmZmZmZmZ d dlZd dlZd dlZd dlZddlmZmZmZmZ ddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- dd	l.m/Z/ dd
l0m1Z1m2Z2 ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZE  G d d          ZF G d dejG        eHeHf                   ZI G d dej
        eHeHf                   ZJ G d d          ZK G d d          ZL G d de
          ZMdS )    N)MutableMapping)Cookie	CookieJar)parse_qsquoteunquote	urlencode   )
ByteStreamUnattachedStreamencode_requestencode_response)SUPPORTED_DECODERSByteChunkerContentDecoderIdentityDecoderLineDecoderMultiDecoderTextChunkerTextDecoder)CookieConflictHTTPStatusError
InvalidURLRequestNotReadResponseNotReadStreamClosedStreamConsumedrequest_context)codes)AsyncByteStreamSyncByteStream)
CookieTypesHeaderTypesPrimitiveDataQueryParamTypesRawURLRequestContentRequestDataRequestFilesResponseContentURLTypes)guess_json_utfis_known_encodingnormalize_header_keynormalize_header_valueobfuscate_sensitive_headersparse_header_linksprimitive_value_to_strc                      e Zd ZdZ	 d(dej        d eef         dej        ddfdZ	e
defd            Ze
defd	            Ze
defd
            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Ze
dej        e         fd            Ze
defd            Ze
defd            Ze
defd            Ze
d)d            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Ze
defd            Zdej        dd fdZ d*dedej        dd fdZ!d*dedej        dd fdZ"dedd fdZ#d e$dd fd!Z%de&dd fd"Z'defd#Z(d$ej        defd%Z)defd&Z*defd'Z+dS )+URLu
  
    url = httpx.URL("HTTPS://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink")

    assert url.scheme == "https"
    assert url.username == "jo@email.com"
    assert url.password == "a secret"
    assert url.userinfo == b"jo%40email.com:a%20secret"
    assert url.host == "müller.de"
    assert url.raw_host == b"xn--mller-kva.de"
    assert url.port == 1234
    assert url.netloc == b"xn--mller-kva.de:1234"
    assert url.path == "/pa th"
    assert url.query == b"?search=ab"
    assert url.raw_path == b"/pa%20th?search=ab"
    assert url.fragment == "anchorlink"

    The components of a URL are broken down like this:

       https://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink
    [scheme]   [  username  ] [password] [ host ][port][ path ] [ query ] [fragment]
               [       userinfo        ] [   netloc   ][    raw_path    ]

    Note that:

    * `url.scheme` is normalized to always be lowercased.

    * `url.host` is normalized to always be lowercased. Internationalized domain
      names are represented in unicode, without IDNA encoding applied. For instance:

      url = httpx.URL("http://中国.icom.museum")
      assert url.host == "中国.icom.museum"
      url = httpx.URL("http://xn--fiqs8s.icom.museum")
      assert url.host == "中国.icom.museum"

    * `url.raw_host` is normalized to always be lowercased, and is IDNA encoded.

      url = httpx.URL("http://中国.icom.museum")
      assert url.raw_host == b"xn--fiqs8s.icom.museum"
      url = httpx.URL("http://xn--fiqs8s.icom.museum")
      assert url.raw_host == b"xn--fiqs8s.icom.museum"

    * `url.port` is either None or an integer. URLs that include the default port for
      "http", "https", "ws", "wss", and "ftp" schemes have their port normalized to `None`.

      assert httpx.URL("http://example.com") == httpx.URL("http://example.com:80")
      assert httpx.URL("http://example.com").port is None
      assert httpx.URL("http://example.com:80").port is None

    * `url.userinfo` is raw bytes, without URL escaping. Usually you'll want to work with
      `url.username` and `url.password` instead, which handle the URL escaping.

    * `url.raw_path` is raw bytes of both the path and query, without URL escaping.
      This portion is used as the target when constructing HTTP requests. Usually you'll
      want to work with `url.path` instead.

    * `url.query` is raw bytes, without URL escaping. A URL query string portion can only
      be properly URL escaped when decoding the parameter names and values themselves.
     urlkwargsreturnNc                 ,   t          |t          t          f          rt          |t                    rr|\  }}}}|                    d          }|                    d          }|rd|v r|d         dk    rd| d}|dnd| }	|                    d          }
| d| |	 |
 }	 t	          j        |                                          | _        n:# t          j        j	        $ r#}t          t          |                    d d }~ww xY w| j        r| j                                        | _        nDt          |t                    r|j        | _        n"t          d	t          |           d
|          dddddd                    | j        j        d          }| j        j        pd}|rM|                    |          r8|d t)          |                    }| j                            |          | _        |r | j        di |j        | _        d S d S )Nascii:r   []r5   z://)messagez6Invalid type for url.  Expected str or httpx.URL, got z: z:21z:80z:443)ftphttphttpswswss)	authority )
isinstancestrtupledecoderfc3986iri_referenceencode_uri_reference
exceptionsInvalidAuthorityr   is_absolute_url	normalizer4   	TypeErrortypegetschemerD   endswithlen	copy_with)selfr6   r7   
raw_schemeraw_hostportraw_pathrU   hostport_strpathexcdefault_portrD   s                 S/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/httpx/_models.py__init__zURL.__init__z   sz    cC<(( 	#u%% ;7:4
HdH#**733w// 'C4KKDGsNN 't;;;D!%22:t::w//::D:(:D::=&-&;C&@&@&G&G&I&I##%6 = = = S222<= # F '+&9&C&C&E&E#S!! 	"%"4D]c]]VY]]   
 
 #d!("
-
- 	 '17R	 	UI..|<< 	U!"6S%6%6$6"67I"&"5"?"?)"?"T"TD 	J"0$.":":6":":"ID	J 	Js   &+C D	&DD	c                     | j         j        pdS )zb
        The URL scheme, such as "http", "https".
        Always normalised to lowercase.
        r5   )rM   rU   rY   s    rc   rU   z
URL.scheme   s     ")/R/    c                 6    | j                             d          S )z
        The raw bytes representation of the URL scheme, such as b"http", b"https".
        Always normalised to lowercase.
        r:   )rU   rL   rf   s    rc   rZ   zURL.raw_scheme   s     {!!'***rg   c                 H    | j         j        pd}|                    d          S )zj
        The URL userinfo as a raw bytestring.
        For example: b"jo%40email.com:a%20secret".
        r5   r:   )rM   userinforL   rY   rj   s     rc   rj   zURL.userinfo   s&     &/52w'''rg   c                 n    | j         j        pd}t          |                    d          d                   S )zn
        The URL username as a string, with URL decoding applied.
        For example: "jo@email.com"
        r5   r;   r   rM   rj   r   	partitionrk   s     rc   usernamezURL.username   5     &/52x))#..q1222rg   c                 n    | j         j        pd}t          |                    d          d                   S )zj
        The URL password as a string, with URL decoding applied.
        For example: "a secret"
        r5   r;      rm   rk   s     rc   passwordzURL.password   rp   rg   c                     | j         j        pd}|r8d|v r4|d         dk    r(|                    d                              d          }|                    d          rt          j        |          }|S )u%  
        The URL host as a string.
        Always normalized to lowercase, with IDNA hosts decoded into unicode.

        Examples:

        url = httpx.URL("http://www.EXAMPLE.org")
        assert url.host == "www.example.org"

        url = httpx.URL("http://中国.icom.museum")
        assert url.host == "中国.icom.museum"

        url = httpx.URL("http://xn--fiqs8s.icom.museum")
        assert url.host == "中国.icom.museum"

        url = httpx.URL("https://[::ffff:192.168.0.1]")
        assert url.host == "::ffff:192.168.0.1"
        r5   r;   r   r<   r=   zxn--)rM   r^   lstriprstrip
startswithidnarI   rY   r^   s     rc   r^   zURL.host   sw    ( ',2 	0C4KKDGsNN;;s##**3//D??6"" 	%;t$$Drg   c                     | j         j        pd}|r8d|v r4|d         dk    r(|                    d                              d          }|                    d          S )uA  
        The raw bytes representation of the URL host.
        Always normalized to lowercase, and IDNA encoded.

        Examples:

        url = httpx.URL("http://www.EXAMPLE.org")
        assert url.raw_host == b"www.example.org"

        url = httpx.URL("http://中国.icom.museum")
        assert url.raw_host == b"xn--fiqs8s.icom.museum"

        url = httpx.URL("http://xn--fiqs8s.icom.museum")
        assert url.raw_host == b"xn--fiqs8s.icom.museum"

        url = httpx.URL("https://[::ffff:192.168.0.1]")
        assert url.raw_host == b"::ffff:192.168.0.1"
        r5   r;   r   r<   r=   r:   )rM   r^   ru   rv   rL   ry   s     rc   r[   zURL.raw_host   sa    ( ',2 	0C4KKDGsNN;;s##**3//D{{7###rg   c                 @    | j         j        }|rt          |          ndS )a  
        The URL port as an integer.

        Note that the URL class performs port normalization as per the WHATWG spec.
        Default ports for "http", "https", "ws", "wss", and "ftp" schemes are always
        treated as `None`.

        For example:

        assert httpx.URL("http://www.example.com") == httpx.URL("http://www.example.com:80")
        assert httpx.URL("http://www.example.com:80").port is None
        N)rM   r\   int)rY   r\   s     rc   r\   zURL.port  s$     "' *s4yyyd*rg   c                     | j         j        pd}| j         j        }|                    d          }|r|dz   |                    d          z   }|S )z
        Either `<host>` or `<host>:<port>` as bytes.
        Always normalized to lowercase, and IDNA encoded.

        This property may be used for generating the value of a request
        "Host" header.
        r5   r:      :)rM   r^   r\   rL   )rY   r^   r\   netlocs       rc   r   z
URL.netloc'  sW     "'-2"'W%% 	:d]T[[%9%99Frg   c                 <    | j         j        pd}t          |          S )z
        The URL path as a string. Excluding the query string, and URL decoded.

        For example:

        url = httpx.URL("https://example.com/pa%20th")
        assert url.path == "/pa th"
        /)rM   r`   r   rY   r`   s     rc   r`   zURL.path7  s      "'.3t}}rg   c                 H    | j         j        pd}|                    d          S )a  
        The URL query string, as raw bytes, excluding the leading b"?".

        This is neccessarily a bytewise interface, because we cannot
        perform URL decoding of this representation until we've parsed
        the keys and values into a QueryParams instance.

        For example:

        url = httpx.URL("https://example.com/?filter=some%20search%20terms")
        assert url.query == b"filter=some%20search%20terms"
        r5   r:   )rM   queryrL   )rY   r   s     rc   r   z	URL.queryD  s&     #)/R||G$$$rg   QueryParamsc                 4    t          | j        j                  S )zz
        The URL query parameters, neatly parsed and packaged into an immutable
        multidict representation.
        )r   rM   r   rf   s    rc   paramsz
URL.paramsU  s     4.4555rg   c                     | j         j        pd}| j         j        |d| j         j        z   z  }|                    d          S )a   
        The complete URL path and query string as raw bytes.
        Used as the target when constructing HTTP requests.

        For example:

        GET /users?search=some%20text HTTP/1.1
        Host: www.example.org
        Connection: close
        r   N?r:   )rM   r`   r   rL   r   s     rc   r]   zURL.raw_path]  sG     "'.3$0C$-333D{{7###rg   c                 8    t          | j        j        pd          S )zk
        The URL fragments, as used in HTML anchors.
        As a string, without the leading '#'.
        r5   )r   rM   fragmentrf   s    rc   r   zURL.fragmentn  s     t*39r:::rg   c                 6    | j         | j        | j        | j        fS )z
        The URL in the raw representation used by the low level
        transport API. See `BaseTransport.handle_request`.

        Provides the (scheme, host, port, target) for the outgoing request.
        )rZ   r[   r\   r]   rf   s    rc   rawzURL.rawv  s"     OMIM	
 	
rg   c                 L    t          | j        j        o| j        j                  S )z
        Return `True` for absolute URLs such as 'http://example.com/path',
        and `False` for relative URLs such as '/path'.
        )boolrM   rU   r^   rf   s    rc   rP   zURL.is_absolute_url  s#     D'.K43F3KLLLrg   c                     | j          S )z
        Return `False` for absolute URLs such as 'http://example.com/path',
        and `True` for relative URLs such as '/path'.
        )rP   rf   s    rc   is_relative_urlzURL.is_relative_url  s     '''rg   c                 H   t           t           t           t          t           t          t          t           t          t          t           t          d}|                                D ]p\  }}||vr|d}t          |          |Qt          |||                   s;||         j        }t          |          j        }d|d| d| }t          |          qd|v sd|v rwt          |
                    d| j                  pd	          }t          |
                    d| j                  pd	          }	|	r| d
|	 n|}
|
                    d          |d<   d|v sd|v r|
                    d| j                  pd	}|
                    d| j                  }|rd
|v r|d         dk    rd| d}|| d
|                     d          n|                    d          |d<   d|v sd|v rp|
                    d| j                  pd                    d          }
|
                    d| j                  pd                    d          }|
r|
 d| n|}||d<   d|v rR|
                    d          pd}|                    d                              d          \  }}}||d<   |r|nd|d<   n|                    d          t          |d                   |d<   |                    d          |d                             d          |d<   d|v r8|
                    d          }|sdnt          t+          |                    |d<   |                    d          t          |d                   |d<   t-           | j        j        di |                                          S )a  
        Copy this URL, returning a new URL with some components altered.
        Accepts the same set of parameters as the components that are made
        available via properties on the `URL` class.

        For example:

        url = httpx.URL("https://www.example.com").copy_with(username="jo@gmail.com", password="a secret")
        assert url == "https://jo%40email.com:a%20secret@www.example.com"
        )rU   ro   rs   rj   r^   r\   r   r`   r   r]   r   r   z/ is an invalid keyword argument for copy_with()Nz	Argument z	 must be z	 but got ro   rs   r5   r;   r:   rj   r^   r\   r   r<   r=   r   rg   @rD   r]   r   r`   r   r   r   rE   )rG   bytesr|   objectitemsrR   rF   __name__rS   r   popro   rs   rL   r^   r\   rj   rI   r   rn   rT   r   r4   rM   rX   unsplit)rY   r7   allowedkeyvaluer>   expectedseenro   rs   rj   r^   r\   r   rD   r]   r`   	has_queryr   r   s                       rc   rX   zURL.copy_with  s    
 
& !,,.. 	) 	)JC'!! SSS((( E73<)H)H "3<0E{{+OcOOhOOOO((( :#7#7VZZ
DMBBHbIIHVZZ
DMBBHbIIH3;I(//X///H!)!9!9F:Vv//::fdi006BD::fdi00D #tQ3"4{{{ #   $  ''000[[)) 8 8v#5#5

:t}==DLLWUUHjj4;77>3FFwOOF2:F8..f...I"+F; zz*--4H%-__W%=%=%G%G%L%L"D)U!F6N'0:eedF7OO zz&!!-!&vf~!6!6vzz'"". #)/"8"8"A"Aw6!!  H--.4"R$$#k&>Q>Q:R:Rw ::j!!-!&vj'9!:!:F: 04&0::6::BBDDEEErg   r   r   c                 `    |                      | j                            ||                    S Nr   )rX   r   setrY   r   r   s      rc   copy_set_paramzURL.copy_set_param  &    ~~T[__S%%@%@~AAArg   c                 `    |                      | j                            ||                    S r   )rX   r   addr   s      rc   copy_add_paramzURL.copy_add_param  r   rg   c                 ^    |                      | j                            |                    S r   )rX   r   removerY   r   s     rc   copy_remove_paramzURL.copy_remove_param   s&    ~~T[%7%7%<%<~===rg   r   c                 ^    |                      | j                            |                    S r   )rX   r   mergerY   r   s     rc   copy_merge_paramszURL.copy_merge_params#  s&    ~~T[%6%6v%>%>~???rg   c                 T   | j         r?|                     dd                              |                              dd          S | j                            d          }t	          |          }t	          |j                            |                                                    S )z
        Return an absolute URL, using this URL as the base.

        Eg.

        url = httpx.URL("https://www.example.com/test")
        url = url.join("/new/path")
        assert url == "https://www.example.com/new/path"
        r@   zexample.com)rU   r^   N)r   )r   rX   joinrM   r4   resolve_withr   )rY   r6   base_urirelative_urls       rc   r   zURL.join&  s      	
 f=AAc$T22 &00$0??3xx<.;;HEEMMOOPPPrg   c                 :    t          t          |                     S NhashrG   rf   s    rc   __hash__zURL.__hash__@      CIIrg   otherc                     t          |t          t          f          o,t          |           t          t          |                    k    S r   )rF   r4   rG   rY   r   s     rc   __eq__z
URL.__eq__C  s2    %#s,,MTc#e**oo1MMrg   c                 4    | j                                         S r   )rM   r   rf   s    rc   __str__zURL.__str__F  s    "**,,,rg   c                    | j         j        }t          |           }| j        j        rQt          | j                  }t          j        |          	                    | d          
                                }| d|dS )Nz	:[secure])rj   ())	__class__r   rG   rM   rj   r   ro   rJ   urlparserX   r   )rY   
class_nameurl_strro   s       rc   __repr__zURL.__repr__I  s    ^,
d))' 	 T]++H ))x$:$:$:;; 
 ++w++++rg   )r5   )r8   r   r   ),r   
__module____qualname____doc__typingUnionrG   r&   Anyrd   propertyrU   r   rZ   rj   ro   rs   r^   r[   Optionalr|   r\   r   r`   r   r   r]   r   r   r   rP   r   rX   r   r   r   r%   r   r+   r   r   r   r   r   rE   rg   rc   r4   r4   >   s       9 9x 794J 4J<sF 234JDJJ4J	4J 4J 4J 4Jl 0 0 0 0 X0 +E + + + X+ (% ( ( ( X( 3# 3 3 3 X3 3# 3 3 3 X3 c    X< $% $ $ $ X$6 +foc* + + + X+      X 
c 
 
 
 X
 %u % % % X%  6 6 6 X6 $% $ $ $ X$  ;# ; ; ; X; 
V 
 
 
 X
 	M 	M 	M 	M X	M ( ( ( ( X(F&* F F F F FBB B# Bfj BE B B B BB B# Bfj BE B B B B>S >U > > > >@ @E @ @ @ @Q QU Q Q Q Q4#    NFJ N4 N N N N- - - - -,# , , , , , ,rg   r4   c                   F   e Zd ZdZdedej        ddfdZdej        fdZ	dej
        fdZdej        fd	Zdej        ej        eef                  fd
Zd!dej        dej        dej        fdZdedej        e         fdZd!dedej        dd fdZd!dedej        dd fdZdedd fdZd!dedd fdZdej        defdZdej        defdZdej        ej                 fdZdefdZdefdZdefdZ dej        defdZ!defdZ"defdZ#d!deddfdZ$dededdfd Z%dS )"r   z0
    URL query parameters, as a multi-dict.
    argsr7   r8   Nc                    t          |          dk     s
J d            |r|r
J d            |r|d         n|}|t          |t          t          f          rBt          |t                    r|                    d          n|}t          |          | _        d S t          |t                    r*d |j                                        D             | _        d S i }t          |t          t          f          r;|D ]7}|                    |d         g                               |d                    8nd |                                D             }d	 |                                D             | _        d S )
Nrr   zToo many arguments.z'Cannot mix named and unnamed arguments.r   r:   c                 4    i | ]\  }}|t          |          S rE   )list.0kvs      rc   
<dictcomp>z(QueryParams.__init__.<locals>.<dictcomp>h  s$    EEEA!T!WWEEErg   r
   c                 r    i | ]4\  }}|t          |t          t          f          rt          |          n|g5S rE   )rF   r   rH   r   s      rc   r   z(QueryParams.__init__.<locals>.<dictcomp>w  sM       1 *Qu">">GtAwwwQC  rg   c                 H    i | ]\  }}t          |          d  |D              S )c                 ,    g | ]}t          |          S rE   )r2   r   items     rc   
<listcomp>z3QueryParams.__init__.<locals>.<dictcomp>.<listcomp>  s!    DDD$/55DDDrg   )rG   r   s      rc   r   z(QueryParams.__init__.<locals>.<dictcomp>  sC       Aq ADD!DDD  rg   )rW   rF   rG   r   rI   r   _dictr   r   r   rH   
setdefaultappend)rY   r   r7   r   
dict_valuer   s         rc   rd   zQueryParams.__init__]  s   4yy1}}}3}}}OVOO&OOO$+QV =JusEl;;=-7u-E-EPELL)))5E!%DJJJ{++ 	EE1B1B1D1DEEEDJJJKMJ%$// 
 " G GD))$q'266==d1gFFFFG  %  
 &,,..  DJJJrg   c                 4    | j                                         S )z
        Return all the keys in the query params.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert list(q.keys()) == ["a", "b"]
        )r   keysrf   s    rc   r   zQueryParams.keys  s     z   rg   c                 l    d | j                                         D                                             S )a  
        Return all the values in the query params. If a key occurs more than once
        only the first item for that key is returned.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert list(q.values()) == ["123", "789"]
        c                 &    i | ]\  }}||d          S r   rE   r   s      rc   r   z&QueryParams.values.<locals>.<dictcomp>  "    777DAq1Q4777rg   )r   r   valuesrf   s    rc   r   zQueryParams.values  s2     87DJ$4$4$6$6777>>@@@rg   c                 l    d | j                                         D                                             S )a  
        Return all items in the query params. If a key occurs more than once
        only the first item for that key is returned.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert list(q.items()) == [("a", "123"), ("b", "789")]
        c                 &    i | ]\  }}||d          S r   rE   r   s      rc   r   z%QueryParams.items.<locals>.<dictcomp>  r   rg   )r   r   rf   s    rc   r   zQueryParams.items  s2     87DJ$4$4$6$6777==???rg   c                     g }| j                                         D ]&\  }|                    fd|D                        '|S )z
        Return all items in the query params. Allow duplicate keys to occur.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert list(q.multi_items()) == [("a", "123"), ("a", "456"), ("b", "789")]
        c                     g | ]}|fS rE   rE   )r   ir   s     rc   r   z+QueryParams.multi_items.<locals>.<listcomp>  s    2221A222rg   )r   r   extend)rY   multi_itemsr   r   s      @rc   r   zQueryParams.multi_items  s]     <>J$$&& 	4 	4DAq22222223333rg   r   defaultc                 X    || j         v r | j         t          |                   d         S |S )z
        Get a value from the query param for a given key. If the key occurs
        more than once, then only the first value is returned.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert q.get("a") == "123"
        r   )r   rG   rY   r   r   s      rc   rT   zQueryParams.get  s.     $*:c#hh'**rg   c                 l    t          | j                            t          |          g                     S )z
        Get all values from the query param for a given key.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert q.get_list("a") == ["123", "456"]
        )r   r   rT   rG   r   s     rc   get_listzQueryParams.get_list  s(     DJNN3s88R00111rg   r   c                     t                      }t          | j                  |_        t          |          g|j        t	          |          <   |S )z
        Return a new QueryParams instance, setting the value of a key.

        Usage:

        q = httpx.QueryParams("a=123")
        q = q.set("a", "456")
        assert q == httpx.QueryParams("a=456")
        )r   dictr   r2   rG   rY   r   r   qs       rc   r   zQueryParams.set  s@     MMtz""3E::;Crg   c                     t                      }t          | j                  |_        |                    |          t	          |          gz   |j        t          |          <   |S )z
        Return a new QueryParams instance, setting or appending the value of a key.

        Usage:

        q = httpx.QueryParams("a=123")
        q = q.add("a", "456")
        assert q == httpx.QueryParams("a=123&a=456")
        )r   r   r   r   r2   rG   r   s       rc   r   zQueryParams.add  sP     MMtz""JJsOO/Ee/L/L.MMCrg   c                     t                      }t          | j                  |_        |j                            t	          |          d           |S )z
        Return a new QueryParams instance, removing the value of a key.

        Usage:

        q = httpx.QueryParams("a=123")
        q = q.remove("a")
        assert q == httpx.QueryParams("")
        N)r   r   r   r   rG   )rY   r   r   s      rc   r   zQueryParams.remove  s?     MMtz""	CHHd###rg   r   c                 N    t          |          }i | j        |j        |_        |S )a\  
        Return a new QueryParams instance, updated with.

        Usage:

        q = httpx.QueryParams("a=123")
        q = q.merge({"b": "456"})
        assert q == httpx.QueryParams("a=123&b=456")

        q = httpx.QueryParams("a=123")
        q = q.merge({"a": "456", "b": "789"})
        assert q == httpx.QueryParams("a=456&b=789")
        )r   r   )rY   r   r   s      rc   r   zQueryParams.merge  s+     +TZ+17+rg   c                 (    | j         |         d         S )Nr   r   r   s     rc   __getitem__zQueryParams.__getitem__  s    z#q!!rg   c                     || j         v S r   r  r   s     rc   __contains__zQueryParams.__contains__  s    dj  rg   c                 D    t          |                                           S r   iterr   rf   s    rc   __iter__zQueryParams.__iter__      DIIKK   rg   c                 *    t          | j                  S r   )rW   r   rf   s    rc   __len__zQueryParams.__len__      4:rg   c                 *    t          | j                  S r   )r   r   rf   s    rc   __bool__zQueryParams.__bool__  s    DJrg   c                 :    t          t          |                     S r   r   rf   s    rc   r   zQueryParams.__hash__  r   rg   r   c                     t          || j                  sdS t          |                                           t          |                                          k    S )NF)rF   r   sortedr   r   s     rc   r   zQueryParams.__eq__  sN    %00 	5d&&(())VE4E4E4G4G-H-HHHrg   c                 D    t          |                                           S r   )r	   r   rf   s    rc   r   zQueryParams.__str__$  s    ))++,,,rg   c                 H    | j         j        }t          |           }| d|dS )Nr   r   )r   r   rG   )rY   r   query_strings      rc   r   zQueryParams.__repr__'  s.    ^,
4yy00|0000rg   c                      t          d          )NzYQueryParams are immutable since 0.18.0. Use `q = q.merge(...)` to create an updated copy.RuntimeErrorr   s     rc   updatezQueryParams.update,  s    @
 
 	
rg   c                      t          d          )Nz^QueryParams are immutable since 0.18.0. Use `q = q.set(key, value)` to create an updated copy.r  r   s      rc   __setitem__zQueryParams.__setitem__2  s    E
 
 	
rg   r   )&r   r   r   r   r%   r   r   rd   KeysViewr   
ValuesViewr   	ItemsViewr   ListTuplerG   r   rT   r   r   r   r   r   r  r   r  Iteratorr	  r|   r  r  r   r   r   r   r  r  rE   rg   rc   r   r   X  sM        %o % % % % % %N	!fo 	! 	! 	! 	!
A) 
A 
A 
A 
A
@v' 
@ 
@ 
@ 
@V[c3h)?@     vz FJ &*    	2C 	2FK$4 	2 	2 	2 	2 s 6:      s 6:     # -     O }    $"vz "c " " " "!
 !t ! ! ! !!&/&*5 ! ! ! !     $        #    IFJ I4 I I I I
- - - - -1# 1 1 1 1

 
_ 
 
 
 
 

s 
3 
4 
 
 
 
 
 
rg   r   c                   |   e Zd ZdZd dededdfdZedefd            Zej	        deddfd	            Zede
j        e
j        eef                  fd
            Zde
j        e         fdZde
j        e         fdZde
j        eef         fdZde
j        e
j        eef                  fdZd!dede
j        de
j        fdZd"dedede
j        e         fdZd!deddfdZd#dZdedefdZdededdfdZdeddfdZde
j        defdZde
j         e
j                 fdZ!de"fdZ#de
j        defdZ$defdZ%dS )$Headersz9
    HTTP headers, as a case-insensitive multi-dict.
    Nheadersencodingr8   c                 $   |g | _         n}t          |t                    rt          |j                   | _         nNt          |t                    r&fd|                                D             | _         nfd|D             | _         | _        d S )Nc                 |    g | ]8\  }}t          |d           t          |d          t          |          f9S F)lowerr%  Tr.   r/   r   r   r   r%  s      rc   r   z$Headers.__init__.<locals>.<listcomp>D  b        Aq	 )%(KKK($JJJ*1h77  rg   c                 |    g | ]8\  }}t          |d           t          |d          t          |          f9S r(  r*  r+  s      rc   r   z$Headers.__init__.<locals>.<listcomp>M  r,  rg   )_listrF   r#  r   r   r   	_encoding)rY   r$  r%  s     `rc   rd   zHeaders.__init__>  s    ?DJJ)) 	gm,,DJJ&& 	    $MMOO  DJJ    $  DJ "rg   c                     | j         ^dD ]T}| j        D ]A\  }}	 |                    |           |                    |           1# t          $ r Y  nw xY w|| _          nUd| _         | j         S )zn
        Header encoding is mandated as ascii, but we allow fallbacks to utf-8
        or iso-8859-1.
        N)r:   utf-8z
iso-8859-1)r/  r   rI   UnicodeDecodeError)rY   r%  r   r   s       rc   r%  zHeaders.encodingX  s     >!. . ."&( 
 
JC

8,,,X....-   
 &.DNE  ".~s   *A
AAr   c                     || _         d S r   r/  rY   r   s     rc   r%  zHeaders.encodingq      rg   c                 $    d | j         D             S )zH
        Returns a list of the raw header items, as byte pairs.
        c                     g | ]
\  }}}||fS rE   rE   )r   raw_key_r   s       rc   r   zHeaders.raw.<locals>.<listcomp>z  s$    EEE%6Wa% EEErg   r.  rf   s    rc   r   zHeaders.rawu  s    
 FE$*EEEErg   c                 N      fd j         D                                             S )Nc                 N    i | ]!\  }}}|                     j                  d "S r   rI   r%  r   r:  r   r   rY   s       rc   r   z Headers.keys.<locals>.<dictcomp>}  s/    PPPMAsE

4=))4PPPrg   )r.  r   rf   s   `rc   r   zHeaders.keys|  s+    PPPPTZPPPUUWWWrg   c                     i }| j         D ]W\  }}}|                    | j                  }|                    | j                  }||v r||xx         d| z  cc<   R|||<   X|                                S )N, )r.  rI   r%  r   rY   values_dictr:  r   r   str_key	str_values          rc   r   zHeaders.values  s    -/!Z 	1 	1MAsEjj//GT]33I+%%G$$$(8Y(8(88$$$$'0G$$!!###rg   c                     i }| j         D ]W\  }}}|                    | j                  }|                    | j                  }||v r||xx         d| z  cc<   R|||<   X|                                S )z
        Return `(key, value)` items of headers. Concatenate headers
        into a single comma seperated value when a key occurs multiple times.
        rA  )r.  rI   r%  r   rB  s          rc   r   zHeaders.items  s    
 .0!Z 	1 	1MAsEjj//GT]33I+%%G$$$(8Y(8(88$$$$'0G$$  """rg   c                 *      fd j         D             S )z
        Return a list of `(key, value)` pairs of headers. Allow multiple
        occurences of the same key without concatenating into a single
        comma seperated value.
        c                     g | ]:\  }}}|                     j                  |                     j                  f;S rE   r>  r?  s       rc   r   z'Headers.multi_items.<locals>.<listcomp>  sP     
 
 
3 ZZ&&T](C(CD
 
 
rg   r;  rf   s   `rc   r   zHeaders.multi_items  s0    
 
 
 
!%
 
 
 	
rg   r   r   c                 8    	 | |         S # t           $ r |cY S w xY w)z
        Return a header value. If multiple occurences of the header occur
        then concatenate them together with commas.
        )KeyErrorr   s      rc   rT   zHeaders.get  s5    
	9 	 	 	NNN	s   
 Fsplit_commasc                     |                                                      j                   fd j        D             }|s|S g }|D ]4}|                    d |                    d          D                        5|S )z
        Return a list of all header values for a given key.
        If `split_commas=True` is passed, then any comma seperated header
        values are split into multiple return strings.
        c                 |    g | ]8\  }}}|                                 k    |                    j                  9S rE   )r)  rI   r%  )r   r:  item_key
item_valueget_header_keyrY   s       rc   r   z$Headers.get_list.<locals>.<listcomp>  sN     
 
 
'8Z~~>11 dm,,111rg   c                 6    g | ]}|                                 S rE   )stripr   s     rc   r   z$Headers.get_list.<locals>.<listcomp>  s      K K K$ K K Krg   ,)r)  rL   r%  r.  r   split)rY   r   rK  r   split_valuesr   rP  s   `     @rc   r   zHeaders.get_list  s     ++DM::
 
 
 
 
+/:
 
 
  	M 	M 	ME K K%++c:J:J K K KLLLLrg   c                     t          |          }|j        D ]:\  }}|                    |j                  | |                    |j                  <   ;d S r   )r#  r   rI   r%  )rY   r$  r   r   s       rc   r  zHeaders.update  s]    '""!+ 	P 	PJC16g>N1O1ODG,--..	P 	Prg   c                 .    t          | | j                  S )Nr%  )r#  r%  rf   s    rc   copyzHeaders.copy  s    tdm4444rg   c                      |                                                      j                   fd j        D             }|rd                    |          S t          |          )z
        Return a single header value.

        If there are multiple headers with the same key, then we concatenate
        them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2
        c                 X    g | ]&\  }}}|k    |                     j                  'S rE   r>  )r   r:  
header_keyheader_valuenormalized_keyrY   s       rc   r   z'Headers.__getitem__.<locals>.<listcomp>  sD     
 
 
+:|^++ ..+++rg   rA  )r)  rL   r%  r.  r   rJ  )rY   r   r   r^  s   `  @rc   r  zHeaders.__getitem__  sz     ++DM::
 
 
 
 
/3z
 
 
  	$99U###smmrg   c                    |                     | j        pd          }|                     | j        pd          }|                                fdt          | j                  D             }t          |dd                   D ]
}| j        |= |r|d         }||f| j        |<   dS | j                            ||f           dS )zs
        Set the header `key` to `value`, removing any duplicate entries.
        Retains insertion order.
        r1  c                 .    g | ]\  }\  }}}|k    |S rE   rE   )r   idxr:  rN  
lookup_keys       rc   r   z'Headers.__setitem__.<locals>.<listcomp>  s9     
 
 
%%a1:%% %%%rg   r
   Nr   )rL   r/  r)  	enumerater.  reversedr   )rY   r   r   set_key	set_valuefound_indexesra  rb  s          @rc   r  zHeaders.__setitem__  s    
 **T^6w77LL!:7;;	]]__

 
 
 
)24:)>)>
 
 
 M!""-.. 	  	 C
3 	@"C&
I>DJsOOOJw
I>?????rg   c                     |                                                     | j                  fdt          | j                  D             }|st          |          t          |          D ]
}| j        |= dS )z*
        Remove the header `key`.
        c                 R    g | ]#\  }\  }}}|                                 k    !|$S rE   )r)  )r   ra  r:  rN  del_keys       rc   r   z'Headers.__delitem__.<locals>.<listcomp>  sC     
 
 
%%a1~~7** ***rg   N)r)  rL   r%  rc  r.  rJ  rd  )rY   r   pop_indexesra  rj  s       @rc   __delitem__zHeaders.__delitem__  s     ))++$$T]33
 
 
 
)24:)>)>
 
 
  	 3--K(( 	  	 C
3	  	 rg   c                     |                                                     | j                  }|d | j        D             v S )Nc                     g | ]\  }}}|	S rE   rE   )r   r:  r   s      rc   r   z(Headers.__contains__.<locals>.<listcomp>  s    >>>iaac>>>rg   )r)  rL   r%  r.  )rY   r   r\  s      rc   r  zHeaders.__contains__
  s;    YY[[''66
>>4:>>>>>rg   c                 D    t          |                                           S r   r  rf   s    rc   r	  zHeaders.__iter__  r
  rg   c                 *    t          | j                  S r   )rW   r.  rf   s    rc   r  zHeaders.__len__  r  rg   r   c                     	 t          |          }n# t          $ r Y dS w xY wd | j        D             }d |j        D             }t          |          t          |          k    S )NFc                     g | ]
\  }}}||fS rE   rE   r   r:  r   r   s       rc   r   z"Headers.__eq__.<locals>.<listcomp>  s"    BBBmaec5\BBBrg   c                     g | ]
\  }}}||fS rE   rE   rs  s       rc   r   z"Headers.__eq__.<locals>.<listcomp>  s"    LLL}q#usElLLLrg   )r#  
ValueErrorr.  r  )rY   r   other_headers	self_list
other_lists        rc   r   zHeaders.__eq__  s    	#ENNMM 	 	 	55	 CBtzBBB	LL8KLLL
i  F:$6$666s    
  c                 .   | j         j        }d}| j        dk    r
d| j        }t          t	          |                                                     }t          |          }t          |          t          |          k    }|r
| d|| dS | d|| dS )Nr5   r:   z, encoding=r   r   )r   r   r%  r   r0   r   r   rW   )rY   r   encoding_stras_listas_dictno_duplicate_keyss         rc   r   zHeaders.__repr__  s    ^,
=G##:::L243C3C3E3EFFGGw--LLCLL8 	> ==7=l====99w9,9999rg   NNr   )F)r8   r#  )&r   r   r   r   r#   rG   rd   r   r%  setterr   r  r   r   r   r  r   r  r   r  r   r   r   rT   r   r   r  rY  r  r  rl  r  r!  r	  r|   r  r   r   rE   rg   rc   r#  r#  9  s>        " " "c "T " " " "4 #    X0 _c d    _ FV[eUl!;< F F F XFXfoc* X X X X	$)#. 	$ 	$ 	$ 	$#v'S1 # # # #	
V[c3h)?@ 	
 	
 	
 	
 s VZ 6:     C t C@P    ,P Pk PT P P P P
5 5 5 5s s    (@s @3 @4 @ @ @ @0 s  t        $?
 ?t ? ? ? ?!&/&*5 ! ! ! !    7FJ 74 7 7 7 7:# : : : : : :rg   r#  c                   z   e Zd Zddddddddddej        eef         dej        deef         dede	de
d	ed
ededej        dej        eef         fdZdej        eef         ddfdZedefd            ZdefdZdefdZdefdZdej        eej        f         fdZdej        eej        f         ddfdZdS )RequestN)r   r$  cookiescontentdatafilesjsonstreammethodr6   r4   r   r$  r  r  r  r  r  r  c                f   t          |t                    r-|                    d                                          | _        n|                                | _        t          |          | _        | | j                            |          | _        t          |          | _	        |r"t          |                              |            |
^t          ||||	          \  }}
|                     |           |
| _        t          |
t                    r|                                  d S d S |
| _        d S )Nr:   r   )rF   r   rI   upperr  r4   r6   r   r#  r$  Cookiesset_cookie_headerr   _preparer  r   read)rY   r  r6   r   r$  r  r  r  r  r  r  s              rc   rd   zRequest.__init__/  s    fe$$ 	) --006688DKK ,,..DKs88x111@@DHw'' 	5G..t444>,WdE4HHOGVMM'""" DK&*-- 		   !DKKKrg   default_headersr8   c                    |                                 D ]B\  }}|                                dk    r
d| j        v r'| j                            ||           Cg }d| j        v }d| j        v pd| j        v }|s-| j        j        r!|                    d| j        j        f           |s| j        dv r|                    d           t          || j        j
        z             | _        d S )Ntransfer-encodingzContent-LengthHostzTransfer-Encodings   Host)POSTPUTPATCH)s   Content-Length   0)r   r)  r$  r   r6   r^   r   r   r  r#  r   )rY   r  r   r   auto_headershas_hosthas_content_lengths          rc   r  zRequest._prepare_  s   )//11 	0 	0JCyy{{1116F$,6V6VL##C////@BT\),S0Ct|0S 	  	<DHM 	<$(/ :;;;! 	;dk5M&M&M 9:::|dl.>>??rg   c                 L    t          | d          st                      | j        S N_content)hasattrr   r  rf   s    rc   r  zRequest.contentt  s(    tZ(( 	# """}rg   c                    t          | d          sst          | j        t          j                  sJ d                    | j                  | _        t          | j        t                    st          | j                  | _        | j        S )6
        Read and return the request content.
        r  rg   )r  rF   r  r   Iterabler   r  r   rf   s    rc   r  zRequest.readz  st     tZ(( 	8dk6?;;;;;HHT[11DMdk:66 8 )77}rg   c                 :  K   t          | d          st          | j        t          j                  sJ d                    d | j        2              d{V           | _        t          | j        t                    st          | j                  | _        | j        S )r  r  rg   c                 "   K   g | 3 d {V }|
6 S r   rE   r   parts     rc   r   z!Request.aread.<locals>.<listcomp>  s.      %I%I%I%I%I%I%I%ITd%I%I%I%I   N)r  rF   r  r   AsyncIterabler   r  r   rf   s    rc   areadzRequest.aread  s       tZ(( 	8dk6+?@@@@@HH%I%IT[%I%I%I%I%I%I%I%I%IJJDMdk:66 8 )77}rg   c                 d    | j         j        }t          | j                  }d| d| j        d|dS )N<r   rA  z)>)r   r   rG   r6   r  )rY   r   r6   s      rc   r   zRequest.__repr__  s<    ^,
$(mm::::::::::rg   c                 H    d | j                                         D             S )Nc                 "    i | ]\  }}|d v	||S ))r  rE   r   namer   s      rc   r   z(Request.__getstate__.<locals>.<dictcomp>  s3     
 
 
e:%% %%%%rg   __dict__r   rf   s    rc   __getstate__zRequest.__getstate__  1    
 
#}2244
 
 
 	
rg   statec                     |                                 D ]\  }}t          | ||           t                      | _        d S r   )r   setattrr   r  rY   r  r  r   s       rc   __setstate__zRequest.__setstate__  sC     ;;== 	' 	'KD%D$&&&&&((rg   )r   r   r   r   r   rG   r   r&   r%   r#   r"   r'   r(   r)   r   r!   r    rd   Dictr  r   r  r  r  r   r  r  rE   rg   rc   r  r  .  s        #'##"& "@D.! .! .!S%Z(.! \%f,-.!
  .! .! .!  .! .! .! j.! ^_<=.! .! .! .!`@CH(= @$ @ @ @ @*     X
e    U    ;# ; ; ; ;

fk#vz/: 
 
 
 
)&+c6:o"> )4 ) ) ) ) ) )rg   r  c                      e Zd Zdddddddddd	dedededededej        d	ej	        e
ef         d
ededej        d          fdZdej        eef         ddfdZedej        fd            Zej        dej        ddfd            Zedefd            Zej        deddfd            Zedefd            Zedefd            Zedej        e         fd            Zedefd            Zedefd            Zedej        e         fd            Z e j        deddfd            Z edej        e         fd            Z!edej        e         fd            Z"de#fd Z$ede%fd!            Z&ede%fd"            Z'd;d#Z(d$ej        dej        fd%Z)ed<d'            Z*edej        ej        e         ej        eef         f         fd(            Z+edefd)            Z,defd*Z-dej        eej        f         fd+Z.d,ej        eej        f         ddfd-Z/defd.Z0d=d/edej1        e         fd0Z2d=d/edej1        e         fd1Z3dej1        e         fd2Z4d=d/edej1        e         fd3Z5d;d4Z6defd5Z7d=d/edej8        e         fd6Z9d=d/edej8        e         fd7Z:dej8        e         fd8Z;d=d/edej8        e         fd9Z<d;d:Z=dS )>ResponseN)	r$  r  texthtmlr  r  request
extensionshistorystatus_coder$  r  r  r  r  r  r  r  r  c       	            || _         t          |          | _        || _        d | _        |	i n|	| _        |
g nt          |
          | _        d| _        d| _	        |[t          ||||          \  }}|                     |           || _        t          |t                    r|                                  n|| _        d| _        d S )NFr   )r  r#  r$  _requestnext_requestr  r   r  	is_closedis_stream_consumedr   r  r  rF   r   r  _num_bytes_downloaded)rY   r  r$  r  r  r  r  r  r  r  r  s              rc   rd   zResponse.__init__  s     'w''29 7; * 2""
$_rr$w--"'>-gtT4HHOGVMM'""" DK&*-- 		 !DK%&"""rg   r  r8   c                     |                                 D ]B\  }}|                                dk    r
d| j        v r'| j                            ||           Cd S )Nr  zcontent-length)r   r)  r$  r   )rY   r  r   r   s       rc   r  zResponse._prepare  sj    )//11 	0 	0JCyy{{1116F$,6V6VL##C////		0 	0rg   c                 N    t          | d          st          d          | j        S )ze
        Returns the time taken for the complete request/response
        cycle to complete.
        _elapsedzK'.elapsed' may only be accessed after the response has been read or closed.)r  r  r  rf   s    rc   elapsedzResponse.elapsed  s7     tZ(( 	+   }rg   r  c                     || _         d S r   )r  )rY   r  s     rc   r  zResponse.elapsed  s    rg   c                 <    | j         t          d          | j         S )zR
        Returns the request instance associated to the current response.
        Nz7The request instance has not been set on this response.)r  r  rf   s    rc   r  zResponse.request  s+    
 = I   }rg   r   c                     || _         d S r   )r  r5  s     rc   r  zResponse.request   s    rg   c                 j    	 | j         d                             dd          S # t          $ r Y dS w xY w)Nhttp_versionr:   ignoreerrorszHTTP/1.1)r  rI   rJ  rf   s    rc   r  zResponse.http_version  sI    	?>299'(9SSS 	 	 	::	s   !$ 
22c                     	 | j         d                             dd          S # t          $ r t          j        | j                  cY S w xY w)Nreason_phraser:   r  r  )r  rI   rJ  r   get_reason_phraser  rf   s    rc   r  zResponse.reason_phrase  s\    	=??3::78:TTT 	= 	= 	=*4+;<<<<<	=s   !$ #A
	A
c                     | j         j        S )zA
        Returns the URL for which the request was made.
        )r  r6   rf   s    rc   r6   zResponse.url  s    
 |rg   c                 L    t          | d          st                      | j        S r  )r  r   r  rf   s    rc   r  zResponse.content  s(    tZ(( 	$!###}rg   c                    t          | d          sn| j        }|sd| _        n]t          | j        pd          }d                    |                    | j                  |                                g          | _        | j        S )N_textr5   r1  rX  )r  r  r  r   r%  r   rI   flush)rY   r  decoders      rc   r  zResponse.text  s{    tW%% 	VlG V

%t}/GHHHWWgnnT\&B&BGMMOO%TUU
zrg   c                 |    t          | d          s&| j        }|t          |          s| j        }|| _        | j        S )aj  
        Return an encoding to use for decoding the byte content into text.
        The priority for determining this is given by...

        * `.encoding = <>` has been set explicitly.
        * The encoding as specified by the charset parameter in the Content-Type header.
        * The encoding as determined by `charset_normalizer`.
        * UTF-8.
        r/  )r  charset_encodingr-   apparent_encodingr/  )rY   r%  s     rc   r%  zResponse.encoding*  sI     t[)) 	&,H'8'B'B1%DN~rg   c                     || _         d S r   r4  r5  s     rc   r%  zResponse.encoding<  r6  rg   c                     | j                             d          }|dS t          j        |          \  }}d|vrdS |d                             d          S )zO
        Return the encoding, as specified by the Content-Type header.
        zContent-TypeNcharsetz'")r$  rT   cgiparse_headerrR  )rY   content_typer:  r   s       rc   r  zResponse.charset_encoding@  sa    
 |''774$\22	6F""4i &&u---rg   c                     t          | dd          }t          |          dk     rdS t          j        | j                                                  }|dn|j        S )zL
        Return the encoding, as detemined by `charset_normalizer`.
        r  rg       N)getattrrW   charset_normalizer
from_bytesr  bestr%  )rY   r  matchs      rc   r  zResponse.apparent_encodingO  s[    
 $
C00w<<" 4"-dl;;@@BB}tt%.8rg   c                    t          | d          sg }| j                            dd          }|D ]c}|                                                                }	 t
          |         }|                     |                       T# t          $ r Y `w xY wt          |          dk    r|d         | _	        n<t          |          dk    rt          |          | _	        nt                      | _	        | j	        S )z
        Returns a decoder instance which can be used to decode the raw byte
        content, depending on the Content-Encoding used in the response.
        _decoderzcontent-encodingT)rK  r
   r   )children)r  r$  r   rR  r)  r   r   rJ  rW   r  r   r   )rY   decodersr   r   decoder_clss        rc   _get_content_decoderzResponse._get_content_decoder\  s   
 tZ(( 	246H\**+=D*QQF  ++--"4U";KOOKKMM2222   H 8}}!! (X"" ,h ? ? ? / 1 1}s   *B
BBc                 4    t          j        | j                  S r   )r   is_errorr  rf   s    rc   r  zResponse.is_erroru  s    ~d.///rg   c                 F    t          j        | j                  od| j        v S )Nlocation)r   is_redirectr  r$  rf   s    rc   r  zResponse.is_redirecty  s"     !122QzT\7QQrg   c                 B   d}| j         }|t          d          t          j        | j                  r)|                    | d          }t          |||           t          j        | j                  r)|                    | d          }t          |||           dS )z>
        Raise the `HTTPStatusError` if one occurred.
        z{0.status_code} {error_type}: {0.reason_phrase} for url: {0.url}
For more information check: https://httpstatuses.com/{0.status_code}NzYCannot call `raise_for_status` as the request instance has not been set on this response.zClient Error)
error_type)r  responsezServer Error)r  r  r   is_client_errorr  formatr   is_server_error)rY   r>   r  s      rc   raise_for_statuszResponse.raise_for_status}  s    
S 	
 -?>  
  !122 	KnnTnnEEG!'7TJJJJ"4#344 	KnnTnnEEG!'7TJJJJ	K 	Krg   r7   c                     | j         _| j        rXt          | j                  dk    r@t          | j                  }|*t	          j        | j                            |          fi |S t	          j        | j        fi |S )N   )r  r  rW   r,   jsonlibloadsrI   r  )rY   r7   r%  s      rc   r  zResponse.json  s~     (T\(c$,>O>ORS>S>S%dl33H#}T\%8%8%B%BMMfMMM}TY11&111rg   r  c                     t          | d          s-t                      | _        | j                            |            | j        S )N_cookies)r  r  r  extract_cookiesrf   s    rc   r  zResponse.cookies  s=    tZ(( 	0#IIDMM))$///}rg   c                     | j                             d          }i }|rCt          |          }|D ]1}|                    d          p|                    d          }|||<   2|S )zI
        Returns the parsed header links of the response, if any
        linkrelr6   )r$  rT   r1   )rY   headerldictlinksr  r   s         rc   r	  zResponse.links  sp    
 !!&)) 	"&v..E " "hhuoo8%!c

rg   c                     | j         S r   )r  rf   s    rc   num_bytes_downloadedzResponse.num_bytes_downloaded  s    ))rg   c                 (    d| j          d| j         dS )Nz<Response [ ]>)r  r  rf   s    rc   r   zResponse.__repr__  s!    FT-FF0BFFFFrg   c                 H    d | j                                         D             S )Nc                 "    i | ]\  }}|d v	||S ))r  r  r  rE   r  s      rc   r   z)Response.__getstate__.<locals>.<dictcomp>  s4     
 
 
e>>> %>>>rg   r  rf   s    rc   r  zResponse.__getstate__  r  rg   r  c                     |                                 D ]\  }}t          | ||           d| _        t                      | _        d S )NT)r   r  r  r   r  r  s       rc   r  zResponse.__setstate__  sJ     ;;== 	' 	'KD%D$&&&&&((rg   c                     t          | d          s,d                    |                                           | _        | j        S )7
        Read and return the response content.
        r  rg   )r  r   
iter_bytesr  rf   s    rc   r  zResponse.read  s;     tZ(( 	8HHT__%6%677DM}rg   
chunk_sizec              #     K   t          | d          rT|t          | j                  n|}t          dt          | j                  |          D ]}| j        |||z            V  dS |                                 }t          |          }t          | j                  5  |                                 D ]3}|	                    |          }|	                    |          D ]}|V  4|
                                }|	                    |          D ]}|V  |
                                D ]}|V  	 ddd           dS # 1 swxY w Y   dS z
        A byte-iterator over the decoded response content.
        This allows us to handle gzip, deflate, and brotli encoded responses.
        r  Nr   r  r  )r  rW   r  ranger  r   r   r  iter_rawrI   r  rY   r  r   r  chunker	raw_bytesdecodedchunks           rc   r  zResponse.iter_bytes  s     
 4$$ 	 /9/AT]+++zJ1c$-00*== 8 8mAJ$6777778 8 //11G!Z888G 777 	  	 !% $ $I%nnY77G!(!8!8 $ $#$!--//$^^G44    EKKKK$]]__    EKKKK 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s    BEE	Ec              #     K   t          | j        pd          }t          |          }t          | j                  5  |                                 D ]3}|                    |          }|                    |          D ]}|V  4|                                }|                    |          D ]}|V  |                                D ]}|V  	 ddd           dS # 1 swxY w Y   dS z
        A str-iterator over the decoded response content
        that handles both gzip, deflate, etc but also detects the content's
        string encoding.
        r1  rX  r  r  N)r   r%  r   r   r  r  rI   r  rY   r  r  r  byte_contenttext_contentr   s          rc   	iter_textzResponse.iter_text  sU      t}'?@@@444T]333 		 		 $ 1 1    &~~l;;$^^L99    EKKKK "==??L 55     		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		s   BC!!C%(C%c              #      K   t                      }t          | j                  5  |                                 D ]}|                    |          D ]}|V  |                                D ]}|V  	 d d d            d S # 1 swxY w Y   d S Nr  )r   r   r  r&  rI   r  rY   r  r  lines       rc   
iter_lineszResponse.iter_lines  s      --T]333 	 	((  #NN400  DJJJJ  



		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   ABB
Bc              #   ,  K   | j         rt                      | j        rt                      t	          | j        t                    st          d          d| _         d| _        t          |          }t          | j                  5  | j        D ];}| xj        t          |          z  c_        |                    |          D ]}|V  <	 ddd           n# 1 swxY w Y   |                                D ]}|V  |                                  dS )@
        A byte-iterator over the raw response content.
        z5Attempted to call a sync iterator on an async stream.Tr   r  r  N)r  r   r  r   rF   r  r!   r  r  r   r   r  rW   rI   r  closerY   r  r  raw_stream_bytesr   s        rc   r  zResponse.iter_raw  st      " 	# """> 	!.. $+~66 	XVWWW"&%&"444T]333 	  	 $(K     **c2B.C.CC**$^^,<==    EKKKK  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ]]__ 	 	EKKKK

s   	ACC!Cc                    t          | j        t                    st          d          | j        sPd| _        t          | j                  5  | j                                         ddd           dS # 1 swxY w Y   dS dS )
        Close the response and release the connection.
        Automatically called if the response body is read to completion.
        z3Attempted to call an sync close on an async stream.Tr  N)rF   r  r!   r  r  r   r  r.  rf   s    rc   r.  zResponse.close  s    
 $+~66 	VTUUU~ 	$!DN 777 $ $!!###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $	$ 	$s   A44A8;A8c                    K   t          | d          s<d                    d |                                 2              d{V           | _        | j        S )r  r  rg   c                 "   K   g | 3 d {V }|
6 S r   rE   r  s     rc   r   z"Response.aread.<locals>.<listcomp>+  s.      %P%P%P%P%P%P%P%PTd%P%P%P%Pr  N)r  r   aiter_bytesr  rf   s    rc   r  zResponse.aread&  sc       tZ(( 	RHH%P%PT=M=M=O=O%P%P%P%P%P%P%P%P%PQQDM}rg   c                  K   t          | d          rU|t          | j                  n|}t          dt          | j                  |          D ]}| j        |||z            W V  dS |                                 }t          |          }t          | j                  5  |                                 2 3 d{V }|	                    |          }|	                    |          D ]}|W V  :6 |
                                }|	                    |          D ]}|W V  |
                                D ]}|W V  	 ddd           dS # 1 swxY w Y   dS r  )r  rW   r  r  r  r   r   r  	aiter_rawrI   r  r  s           rc   r5  zResponse.aiter_bytes.  s     
 4$$ 	 /9/AT]+++zJ1c$-00*== 8 8mAJ$67777778 8 //11G!Z888G 777 	  	 '+~~'7'7 $ $ $ $ $ $ $)%nnY77G!(!8!8 $ $#$ (8 "--//$^^G44    EKKKKK$]]__    EKKKKK 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   !E6C0<BEEEc                  K   t          | j        pd          }t          |          }t          | j                  5  |                                 2 3 d{V }|                    |          }|                    |          D ]}|W V  :6 |                                }|                    |          D ]}|W V  |                                D ]}|W V  	 ddd           dS # 1 swxY w Y   dS r"  )r   r%  r   r   r  r5  rI   r  r#  s          rc   
aiter_textzResponse.aiter_textE  s}      t}'?@@@444T]333 		 		&*&6&6&8&8              l&~~l;;$^^L99    EKKKKK  '9 #==??L 55     		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		s   C*BBC**C.1C.c                0  K   t                      }t          | j                  5  |                                 2 3 d {V }|                    |          D ]}|W V  %6 |                                D ]}|W V  	 d d d            d S # 1 swxY w Y   d S r(  )r   r   r  r9  rI   r  r)  s       rc   aiter_lineszResponse.aiter_linesX  s     --T]333 	 	"oo//       d#NN400  DJJJJJ 0    




		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   BA <BBBc                H  K   | j         rt                      | j        rt                      t	          | j        t                    st          d          d| _         d| _        t          |          }t          | j                  5  | j        2 3 d{V }| xj        t          |          z  c_        |                    |          D ]}|W V  B6 	 ddd           n# 1 swxY w Y   |                                D ]}|W V  |                                  d{V  dS )r-  z6Attempted to call an async iterator on an sync stream.Tr   r  r  N)r  r   r  r   rF   r  r    r  r  r   r   r  rW   rI   r  acloser/  s        rc   r7  zResponse.aiter_rawa  s      " 	# """> 	!.. $+77 	YWXXX"&%&"444T]333 	  	 *.+              &**c2B.C.CC**$^^,<==    EKKKKK  +6+	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ]]__ 	 	EKKKKKkkmms   	C!C=C!!C%(C%c                   K   t          | j        t                    st          d          | j        sVd| _        t          | j                  5  | j                                         d{V  ddd           dS # 1 swxY w Y   dS dS )r2  z3Attempted to call an async close on an sync stream.Tr  N)rF   r  r    r  r  r   r  r=  rf   s    rc   r=  zResponse.aclose{  s      
 $+77 	VTUUU~ 	+!DN 777 + +k((*********+ + + + + + + + + + + + + + + + + +	+ 	+s    A<<B B )r8   N)r8   r  r   )>r   r   r   r|   r#   r*   rG   r   r   r   r!   r    r  r   r  rd   r  r  r   datetime	timedeltar  r  r  r  r  r   r4   r6   r   r  r  r%  r  r  r   r  r   r  r  r  r  r  r	  r  r   r  r  r  r!  r  r&  r+  r  r.  r  AsyncIteratorr5  r9  r;  r7  r=  rE   rg   rc   r  r    s       
  $#'@D+/2' 2' 2'2' 	2'
 !2' 2' 2' j2' ^_<=2' 2' 2' Z(2' 2' 2' 2'h0CH(= 0$ 0 0 0 0 
+ 
 
 
 X
 ^ x1  d       ^      X ^W     ^ c    X =s = = = X=  V_S)       X      X
 c    X &/#.    X" _c d    _ .&/#"6 . . . X. 
96?3#7 
9 
9 
9 X
9n    2 0$ 0 0 0 X0 RT R R R XRK K K K.2VZ 2FJ 2 2 2 2    X v{6?3#7S#X9N#NO    X *c * * * X*G# G G G G
fk#vz/: 
 
 
 
)&+c6:o"> )4 ) ) ) )e       S  FOE4J        . C 6?33G    &FOC0     3 &/%2H    4$ $ $ $U       C  6;OPU;V        . 3 &:Ns:S    &6#7#<     # 9Me9T    4+ + + + + +rg   r  c                      e Zd ZdZd!deddfdZdeddfdZdeddfd	Z	d"de
de
de
de
ddf
dZ	 d#de
de
de
de
dej        e
         f
dZd$de
de
de
ddfdZd$de
de
ddfdZd!deddfdZde
de
ddfdZde
de
fdZde
ddfdZdefdZdej        e
         fdZdefdZde
fdZ G d dej        j                  Z G d d           ZdS )%r  z-
    HTTP Cookies, as a mutable mapping.
    Nr  r8   c                 &   |t          |t                    r\t                      | _        t          |t                    r0|                                D ]\  }}|                     ||           d S d S t          |t                    r3t                      | _        |D ]\  }}|                     ||           d S t          |t                    r9t                      | _        |j        D ]}| j                            |           d S || _        d S r   )	rF   r   r   jarr   r   r   r  
set_cookie)rY   r  r   r   cookies        rc   rd   zCookies.__init__  s'   ?j$77? {{DH'4(( )")--// ) )JCHHS%(((() )) )&& 		 {{DH% % %
Ue$$$$% %)) 	 {{DH!+ , ,##F++++, , DHHHrg   r  c                     |                      |          }|                     |j                  }| j                            ||           dS )zO
        Loads any cookies based on the response `Set-Cookie` headers.
        N)_CookieCompatResponse_CookieCompatRequestr  rD  r  )rY   r  urllib_responseurllib_requests       rc   r  zCookies.extract_cookies  sK     44X>>2283CDD  .AAAAArg   r  c                 d    |                      |          }| j                            |           dS )zM
        Sets an appropriate 'Cookie:' HTTP header on the `Request`.
        N)rI  rD  add_cookie_header)rY   r  rK  s      rc   r  zCookies.set_cookie_header  s3     227;;"">22222rg   r5   r   r  r   domainr`   c                    i ddd|d|ddddd	|d
t          |          d|                    d          d|dt          |          dddddddddddddidd}t          di |}| j                            |           dS )zU
        Set a cookie value by name. May optionally include domain and path.
        versionr   r  r   r\   Nport_specifiedFrN  domain_specifieddomain_initial_dot.r`   path_specifiedsecureexpiresdiscardTcommentcomment_urlrestHttpOnlyrfc2109rE   )r   rw   r   rD  rE  )rY   r  r   rN  r`   r7   rF  s          rc   r   zCookies.set  s!   
q
D
 U
 D	

 e
 f
 V
 !&"3"3C"8"8
 D
 d4jj
 e
 t
 t
 t
 4
  Z&!
" u#
& !!&!!F#####rg   r   c                     d}| j         D ]D}|j        |k    r7||j        |k    r*||j        |k    r|d| }t	          |          |j        }E||S |S )z
        Get a cookie by name. May optionally include domain and path
        in order to specify exactly which cookie to retrieve.
        Nz!Multiple cookies exist with name=)rD  r  rN  r`   r   r   )rY   r  r   rN  r`   r   rF  r>   s           rc   rT   zCookies.get  s     h 	- 	-F{d"">V]f%<%<|v{d':': ,&P$&P&PG"0"9"99 &=Nrg   c                     | j                                       S fd| j         D             }|D ]-}| j                             |j        |j        |j                   .dS )z
        Delete a cookie by name. May optionally include domain and path
        in order to specify exactly which cookie to delete.
        Nc                 ^    g | ])}|j         k    r|j        k    r|j        k    '|*S r   )r  rN  r`   )r   rF  rN  r  r`   s     rc   r   z"Cookies.delete.<locals>.<listcomp>  sT     
 
 
{d""6=F#:#:!4!4	  "5!4!4rg   )rD  clearrN  r`   r  )rY   r  rN  r`   r   rF  s    ```  rc   deletezCookies.delete  s    
 $"28>>&$555
 
 
 
 
 
(
 
 
  	D 	DFHNN6=&+v{CCCC	D 	Drg   c                     g }||                     |           ||J |                     |            | j        j        |  dS )z
        Delete all cookies. Optionally include a domain and path in
        order to only delete a subset of all the cookies.
        N)r   rD  ra  )rY   rN  r`   r   s       rc   ra  zCookies.clear  s\    
 KK%%%KKrg   c                 l    t          |          }|j        D ]}| j                            |           d S r   )r  rD  rE  )rY   r  rF  s      rc   r  zCookies.update  sC    '""k 	( 	(FH''''	( 	(rg   c                 .    |                      ||          S r   )r   rY   r  r   s      rc   r  zCookies.__setitem__  s    xxe$$$rg   c                 R    |                      |          }|t          |          |S r   )rT   rJ  rf  s      rc   r  zCookies.__getitem__  s'    =4.. rg   c                 ,    |                      |          S r   )rb  )rY   r  s     rc   rl  zCookies.__delitem__  s    {{4   rg   c                 *    t          | j                  S r   )rW   rD  rf   s    rc   r  zCookies.__len__  s    48}}rg   c                 $    d | j         D             S )Nc              3   $   K   | ]}|j         V  d S r   )r  r   rF  s     rc   	<genexpr>z#Cookies.__iter__.<locals>.<genexpr>  s$      33333333rg   rD  rf   s    rc   r	  zCookies.__iter__  s    33$(3333rg   c                     | j         D ]} dS dS )NTFrn  )rY   r:  s     rc   r  zCookies.__bool__  s     	 	A44urg   c                 V    d                     d | j        D                       }d| dS )NrA  c           	      D    g | ]}d |j          d|j         d|j         dS )z<Cookie =z for z />)r  r   rN  rl  s     rc   r   z$Cookies.__repr__.<locals>.<listcomp>  sJ        O6;NNNNFMNNN  rg   z	<Cookies[r  )r   rD  )rY   cookies_reprs     rc   r   zCookies.__repr__  sF    yy "h  
 
 ,<++++rg   c                   D     e Zd ZdZdeddf fdZdededdf fdZ xZS )	Cookies._CookieCompatRequest
        Wraps a `Request` instance up in a compatibility interface suitable
        for use with `CookieJar` operations.
        r  r8   Nc                     t                                          t          |j                  t	          |j                  |j                   || _        d S )N)r6   r$  r  )superrd   rG   r6   r   r$  r  r  )rY   r  r   s     rc   rd   z%Cookies._CookieCompatRequest.__init__*  sP    GG$$W_--~    
 #DLLLrg   r   r   c                 j    t                                          ||           || j        j        |<   d S r   )rx  add_unredirected_headerr  r$  )rY   r   r   r   s      rc   rz  z4Cookies._CookieCompatRequest.add_unredirected_header2  s2    GG++C777(-DL %%%rg   )	r   r   r   r   r  rd   rG   rz  __classcell__)r   s   @rc   rI  ru  $  s        	 	
	#G 	# 	# 	# 	# 	# 	# 	#	.s 	.3 	.4 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.rg   rI  c                   >    e Zd ZdZdefdZdej        j        fdZ	dS )Cookies._CookieCompatResponserv  r  c                     || _         d S r   )r  )rY   r  s     rc   rd   z&Cookies._CookieCompatResponse.__init__<  s    $DMMMrg   r8   c                     t           j                                        }| j        j                                        D ]
\  }}|||<   |S r   )emailr>   Messager  r$  r   )rY   infor   r   s       rc   r  z"Cookies._CookieCompatResponse.info?  sK    =((**D"m3??AA " "
U "S		Krg   N)
r   r   r   r   r  rd   r  r>   r  r  rE   rg   rc   rH  r}  6  sY        	 	
	%X 	% 	% 	% 	%	%-/ 	 	 	 	 	 	rg   rH  r   )r5   r   )NNNr~  ) r   r   r   r   r"   rd   r  r  r  r  rG   r   r   r   rT   rb  ra  r  r  r  rl  r|   r  r!  r	  r   r  r   urllibr  rI  rH  rE   rg   rc   r  r    s          t    "B BT B B B B3 3T 3 3 3 3$ $ $C $ $ $t $ $ $ $6 OS "%69HK		   *D D3 D D# D D D D D& C c T    ( (k (T ( ( ( (
% %C %D % % % %     ! ! ! ! ! !    4&/#. 4 4 4 4$    
,# , , , ,. . . . .v~5 . . .$         rg   r  )Nr  r?  email.messager  r  r  r   urllib.requestr  collections.abcr   http.cookiejarr   r   urllib.parser   r   r   r	   r  rx   rJ   rfc3986.exceptionsr  r   r   r   r   	_decodersr   r   r   r   r   r   r   r   _exceptionsr   r   r   r   r   r   r   r   _status_codesr   _transports.baser    r!   _typesr"   r#   r$   r%   r&   r'   r(   r)   r*   r+   _utilsr,   r-   r.   r/   r0   r1   r2   r4   MappingrG   r   r#  r  r  r  rE   rg   rc   <module>r     s   



               * * * * * * , , , , , , , , < < < < < < < < < < < <           S S S S S S S S S S S S	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 !           = = = = = = = =                                        W, W, W, W, W, W, W, W,t^
 ^
 ^
 ^
 ^
&.c* ^
 ^
 ^
Br: r: r: r: r:f#CH- r: r: r:jw) w) w) w) w) w) w) w)t^+ ^+ ^+ ^+ ^+ ^+ ^+ ^+B} } } } }n } } } } }rg   