Ë
    ,Œ:j½  ã                   ó  — d dl Z d dlZd dlZd dlZddlmZmZ ddlmZ ddl	m
Z
 ej                  rd dlmZ d dlmZ  ej                   d	«      Zd
ej$                  e   dej$                  e   fd„Z G d„ de«      Z G d„ de
«      Zy)é    Né   )ÚRequestÚResponse)ÚSyncByteStreamé   )ÚBaseTransport)Ú
OptExcInfo)ÚWSGIApplicationÚ_TÚbodyÚreturnc                 ó`   — t        | «      } | D ]  }|sŒt        j                  |g| «      c S  g S ©N)ÚiterÚ	itertoolsÚchain)r   Úchunks     úX/var/www/html/tokenscope/api/venv/lib/python3.12/site-packages/httpx/_transports/wsgi.pyÚ_skip_leading_empty_chunksr      s7   € Ü�‹:€DØò 2ˆÚÜ—?‘? E 7¨DÓ1Ò1ð2ð €Ió    c                   ód   — e Zd Zdej                  e   ddfd„Zdej                  e   fd„Zdd„Z	y)ÚWSGIByteStreamÚresultr   Nc                 óH   — t        |dd «      | _        t        |«      | _        y )NÚclose)ÚgetattrÚ_closer   Ú_result)Úselfr   s     r   Ú__init__zWSGIByteStream.__init__   s   € Ü˜f g¨tÓ4ˆŒÜ1°&Ó9ˆ�r   c              #   ó6   K  — | j                   D ]  }|–— Œ y ­wr   )r   )r   Úparts     r   Ú__iter__zWSGIByteStream.__iter__   s   è ø€ Ø—L‘Lò 	ˆDØ‹Jñ	ùs   ‚c                 ó>   — | j                   �| j                  «        y y r   )r   )r   s    r   r   zWSGIByteStream.close"   s   € Ø�;‰;Ð"Ø�K‰K�Mð #r   )r   N)
Ú__name__Ú
__module__Ú__qualname__ÚtypingÚIterableÚbytesr    ÚIteratorr#   r   © r   r   r   r      s8   „ ð:˜vŸ™¨uÑ5ð :¸$ó :ð˜&Ÿ/™/¨%Ñ0ó ôr   r   c                   óx   — e Zd ZdZ	 	 	 	 ddddedededej                  ej                     d	dfd
„Z	de
d	efd„Zy)ÚWSGITransporta  
    A custom transport that handles sending requests directly to an WSGI app.
    The simplest way to use this functionality is to use the `app` argument.

    ```
    client = httpx.Client(app=app)
    ```

    Alternatively, you can setup the transport instance explicitly.
    This allows you to include any additional configuration arguments specific
    to the WSGITransport class:

    ```
    transport = httpx.WSGITransport(
        app=app,
        script_name="/submount",
        remote_addr="1.2.3.4"
    )
    client = httpx.Client(transport=transport)
    ```

    Arguments:

    * `app` - The WSGI application.
    * `raise_app_exceptions` - Boolean indicating if exceptions in the application
       should be raised. Default to `True`. Can be set to `False` for use cases
       such as testing the content of a client 500 response.
    * `script_name` - The root path on which the WSGI application should be mounted.
    * `remote_addr` - A string indicating the client IP of incoming requests.
    ```
    NÚappr
   Úraise_app_exceptionsÚscript_nameÚremote_addrÚwsgi_errorsr   c                 óJ   — || _         || _        || _        || _        || _        y r   )r/   r0   r1   r2   r3   )r   r/   r0   r1   r2   r3   s         r   r    zWSGITransport.__init__H   s+   € ð ˆŒØ$8ˆÔ!Ø&ˆÔØ&ˆÔØ&ˆÕr   Úrequestc                 óJ  ‡‡‡— |j                  «        t        j                  |j                  «      }|j                  j
                  xs dddœ|j                  j                     }d|j                  j                  || j                  xs t        j                  ddd|j                  | j                  |j                  j                  |j                  j                  j                  d«      |j                  j                  t!        |«      d| j"                  d	œ}|j$                  j&                  D ]Q  \  }}|j                  d«      j)                  «       j+                  d
d«      }|dvrd|z   }|j                  d«      ||<   ŒS d Šd Šd Š	 ddt         dt,        j.                  t,        j0                  t         t         f      dt,        j2                  d   dt,        j4                  t6        gt,        j8                  f   fˆˆˆfd„}| j;                  ||«      }	t=        |	«      }
‰€J ‚‰€J ‚‰r‰d   r| j>                  r‰d   ‚tA        ‰jC                  «       d   «      }‰D ��cg c]'  \  }}|jE                  d«      |jE                  d«      f‘Œ) }}}tG        |||
¬«      S c c}}w )NéP   i»  )ÚhttpÚhttps)r   r   TFÚasciizHTTP/1.1)zwsgi.versionzwsgi.url_schemez
wsgi.inputzwsgi.errorszwsgi.multithreadzwsgi.multiprocesszwsgi.run_onceÚREQUEST_METHODÚSCRIPT_NAMEÚ	PATH_INFOÚQUERY_STRINGÚSERVER_NAMEÚSERVER_PORTÚSERVER_PROTOCOLÚREMOTE_ADDRú-Ú_)ÚCONTENT_TYPEÚCONTENT_LENGTHÚHTTP_ÚstatusÚresponse_headersÚexc_infor	   r   c                 ó   •— | Š|Š|Šd„ S )Nc                  ó   — y r   r,   )rD   s    r   ú<lambda>zFWSGITransport.handle_request.<locals>.start_response.<locals>.<lambda>   s   � r   r,   )rH   rI   rJ   Úseen_exc_infoÚseen_response_headersÚseen_statuss      €€€r   Ústart_responsez4WSGITransport.handle_request.<locals>.start_responsev   s   ø€ ð !ˆKØ$4Ð!Ø$ˆMÙ!Ð!r   r   r   )ÚheadersÚstreamr   )$ÚreadÚioÚBytesIOÚcontentÚurlÚportÚschemer3   ÚsysÚstderrÚmethodr1   ÚpathÚqueryÚdecodeÚhostÚstrr2   rR   ÚrawÚupperÚreplacer(   ÚListÚTupleÚOptionalÚCallabler*   ÚAnyr/   r   r0   ÚintÚsplitÚencoder   )r   r5   Ú
wsgi_inputrY   ÚenvironÚ
header_keyÚheader_valueÚkeyrQ   r   rS   Ústatus_codeÚvaluerR   rN   rO   rP   s                 @@@r   Úhandle_requestzWSGITransport.handle_requestV   sh  ú€ Ø�‰ŒÜ—Z‘Z §¡Ó0ˆ
à�{‰{×ÑÒQ¨B¸Ñ#=¸g¿k¹k×>PÑ>PÑ#Qˆà"Ø&Ÿ{™{×1Ñ1Ø$Ø×+Ñ+Ò9¬s¯z©zØ $Ø!&Ø"Ø%Ÿn™nØ×+Ñ+Ø Ÿ™×)Ñ)Ø#ŸK™K×-Ñ-×4Ñ4°WÓ=Ø"Ÿ;™;×+Ñ+Ü˜t›9Ø)Ø×+Ñ+ñ
ˆð" )0¯©×(;Ñ(;ò 	8Ñ$ˆJ˜Ø×#Ñ# GÓ,×2Ñ2Ó4×<Ñ<¸SÀ#ÓFˆCØÐ<Ñ<Ø ‘m�Ø'×.Ñ.¨wÓ7ˆG�CŠLð		8ð ˆØ $ÐØˆð
 7;ñ		"Üð		"ä$Ÿk™k¬&¯,©,´s¼C°xÑ*@ÑAð		"ô —o‘o lÑ3ð		"ô �_‰_œe˜W¤f§j¡jÐ0Ñ1÷			"ð —‘˜' >Ó2ˆä Ó'ˆàÐ&Ð&Ð&Ø$Ð0Ð0Ð0Ù˜]¨1Ò-°$×2KÒ2KØ Ñ"Ð"ä˜+×+Ñ+Ó-¨aÑ0Ó1ˆð 4÷
á��Uð �Z‰Z˜Ó  %§,¡,¨wÓ"7Ò8ð
ˆñ 
ô
 ˜¨W¸VÔDÐDùó
s   É",J)TÚ z	127.0.0.1N)r%   r&   r'   Ú__doc__Úboolrb   r(   rh   ÚTextIOr    r   r   ru   r,   r   r   r.   r.   '   sx   „ ñðF &*ØØ&Ø6:ñ'àð'ð #ð'ð ð	'ð
 ð'ð —_‘_ V§]¡]Ñ3ð'ð 
ó'ð:E gð :E°(ô :Er   r.   )rU   r   r[   r(   Ú_modelsr   r   Ú_typesr   Úbaser   ÚTYPE_CHECKINGÚ	_typeshedr	   Ú_typeshed.wsgir
   ÚTypeVarr   r)   r   r   r.   r,   r   r   ú<module>r�      sz   ðÛ 	Û Û 
Û ç 'Ý #Ý à	×ÒÝ$Ý.à€V‡^�^�DÓ€ð V§_¡_°RÑ%8ð ¸V¿_¹_ÈRÑ=Pó ô�^ô ôiE�Mõ iEr   