
    ,h                        d dl 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 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gZddZ G d de
      Z G d de      Zy)    )annotationsN   )RequestResponse)SyncByteStream   )BaseTransport)
OptExcInfo)WSGIApplication_TWSGITransportc                `    t        |       } | D ]  }|st        j                  |g|       c S  g S N)iter	itertoolschain)bodychunks     X/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/httpx/_transports/wsgi.py_skip_leading_empty_chunksr      s7    :D 2??E7D112 I    c                  $    e Zd ZddZddZddZy)WSGIByteStreamc                H    t        |dd       | _        t        |      | _        y )Nclose)getattr_closer   _result)selfresults     r   __init__zWSGIByteStream.__init__   s    fgt41&9r   c              #  6   K   | j                   D ]  }|  y wr   )r   )r   parts     r   __iter__zWSGIByteStream.__iter__#   s     LL 	DJ	s   c                >    | j                   | j                          y y r   )r   )r   s    r   r   zWSGIByteStream.close'   s    ;;"KKM #r   N)r    ztyping.Iterable[bytes]returnNone)r&   ztyping.Iterator[bytes])r&   r'   )__name__
__module____qualname__r!   r$   r    r   r   r   r      s    :r   r   c                  @    e Zd ZdZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZddZy)r   a  
    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.
    ```
    Nc                J    || _         || _        || _        || _        || _        y r   )appraise_app_exceptionsscript_nameremote_addrwsgi_errors)r   r.   r/   r0   r1   r2   s         r   r!   zWSGITransport.__init__M   s+     $8!&&&r   c                z   |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fd}| j-                  ||      }	t/        |	      }
J J rd   r| j0                  rd   t3        j5                         d         }D cg c]'  \  }}|j7                  d      |j7                  d      f) }}}t9        |||
      S c c}}w )NP   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_c                    | ||d S )Nc                     y r   r+   )rA   s    r   <lambda>zFWSGITransport.handle_request.<locals>.start_response.<locals>.<lambda>   s    r   r+   )statusresponse_headersexc_infoseen_exc_infoseen_response_headersseen_statuss      r   start_responsez4WSGITransport.handle_request.<locals>.start_response{   s     !K$4!$M!!r   r   r   )headersstreamr   )rH   strrI   zlist[tuple[str, str]]rJ   zOptExcInfo | Noner&   z$typing.Callable[[bytes], typing.Any])readioBytesIOcontenturlportschemer2   sysstderrmethodr0   pathquerydecodehostrQ   r1   rO   rawupperreplacer.   r   r/   intsplitencoder   )r   request
wsgi_inputrW   environ
header_keyheader_valuekeyrN   r    rP   status_codevaluerO   rK   rL   rM   s                 @@@r   handle_requestzWSGITransport.handle_request[   s/   ZZ0
{{QB#=gkk>P>P#Q"&{{11$++9szz $!&"%nn++ ))#KK--44W=";;++t9)++
" )0(;(; 	8$J##G,224<<S#FC<<m'..w7GCL		8  $
 +/		"		"3		" (		" 2			" '>2'&&$00]1-$2K2K""+++-a01 4
U ZZ %,,w"78
 

 WVDD
s   :,H7)T z	127.0.0.1N)r.   r   r/   boolr0   rQ   r1   rQ   r2   ztyping.TextIO | Noner&   r'   )rf   r   r&   r   )r(   r)   r*   __doc__r!   rn   r+   r   r   r   r   ,   s[    F &*&,0'' #' 	'
 ' *' 
':Er   )r   typing.Iterable[_T]r&   rr   )
__future__r   rS   r   rY   typing_modelsr   r   _typesr   baser	   TYPE_CHECKING	_typeshedr
   _typeshed.wsgir   TypeVarr   __all__r   r   r   r+   r   r   <module>r}      sg    " 	  
  ' # 	$.V^^D 
^ iEM iEr   