§
    ÎÑßj  ã                   óº   — d 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m	Z	 ddl
mZ ddlmZ  G d„ dej        j        ¦  «        Z G d	„ d
ej        j        ¦  «        ZdS )z;Native adapter for serving CherryPy via its builtin server.é    N)Ú
format_excÚ
bare_error)Úhttputilé   ©Útonativec                   ó"   — e Zd ZdZdZd„ Zd„ ZdS )ÚNativeGatewayz6Native gateway implementation allowing to bypass WSGI.Fc                 ó°  — | j         }	 |j        j        }t          |d         ¦  «        |d         f}t	          j        |d         |d         d¦  «        }t          |j        j        ¦  «        |j        j        f}t	          j        |d         |d         d¦  «        }t          |j	        ¦  «        }t          j                             t          |j        pd¦  «        ¦  «        }|€|                      dg dg¦  «         dS t          j        j        |         }t          |j        ¦  «        }t          |j        ¦  «        }t          |j        pd¦  «        }	d„ |j                             ¦   «         D ¦   «         }
|j        }d}	 g }	 |                     |||d	¦  «        \  }}d|_        d
|_        ||_        ||_        	 |                     |||	t          |j        ¦  «        |
|¦  «         n²# t          j        $ rž t=          j        ¦   «         d         }|                      ¦   «          |}| j!        sB|j        |v rtE          d|j        z  ¦  «        ‚|	rd|	z   }	| #                    ||z   |	z   ¦  «         d}|j        }|j$        }	tK          j&        ¦   «         }Y nw xY w�Œ|                      |j'        |j(        |j)        ¦  «         |                      ¦   «          dS # |                      ¦   «          w xY w# tT          $ r\ tW          ¦   «         }t          j,        |dtZ          j.        ¬¦  «         t_          ¦   «         \  }}}|                      |||¦  «         Y dS w xY w)z9Obtain response from CherryPy machinery and then send it.r   r   Ú ú/Nz404 Not Foundc              3   óX   K  — | ]%\  }}t          |¦  «        t          |¦  «        fV — Œ&d S )Nr   )Ú.0ÚhÚvs      úM/opt/saltstack/salt/lib/python3.11/site-packages/cherrypy/_cpnative_server.pyú	<genexpr>z(NativeGateway.respond.<locals>.<genexpr>(   sK   è è € ð ð á˜˜1õ ˜a‘[”[¥(¨1¡+¤+Ð.ðð ð ð ð ð ó    TzHTTP/1.1Fz1InternalRedirector visited the same URL twice: %rú?ÚGETÚNATIVE_ADAPTER)Úseverity)0ÚreqÚserverÚ	bind_addrr   r   ÚHostÚconnÚremote_addrÚremote_portÚschemeÚcherrypyÚtreeÚscript_nameÚuriÚsend_responseÚappsÚmethodÚpathÚqsÚ	inheadersÚitemsÚrfileÚget_servingÚmultithreadÚmultiprocessÚappÚprevÚrunÚrequest_protocolÚInternalRedirectÚsysÚexc_infoÚrelease_servingÚ	recursiveÚRuntimeErrorÚappendÚquery_stringÚioÚBytesIOÚoutput_statusÚheader_listÚbodyÚ	Exceptionr   ÚlogÚloggingÚERRORr   )Úselfr   ÚlocalÚremoter    Úsnr0   r'   r(   r)   Úheadersr,   r1   ÚredirectionsÚrequestÚresponseÚirÚtbÚsr   Úbs                        r   ÚrespondzNativeGateway.respond   sƒ  € àŒhˆðL	(à”JÔ(ˆEÝ˜U 1œXÑ&Ô&¨¨a¬Ð0ˆEÝ”M %¨¤(¨E°!¬H°bÑ9Ô9ˆEÝ˜cœhÔ2Ñ3Ô3°S´XÔ5IÐIˆFÝ”] 6¨!¤9¨f°Q¬i¸Ñ<Ô<ˆFå˜cœjÑ)Ô)ˆFÝ”×*Ò*­8°C´G°N¸sÑ+CÔ+CÑDÔDˆBØˆzØ×"Ò" ?°B¸¸Ñ=Ô=Ð=Ð=Ð=å”mÔ(¨Ô,�Ý! #¤*Ñ-Ô-�Ý ¤Ñ)Ô)�Ý˜cœf˜l¨Ñ+Ô+�ðð à #¤× 3Ò 3Ñ 5Ô 5ðñ ô �ð œ	�Ø�ð.*Ø#%�Lð&1Ø,/¯OªOØ! 6¨6°:ñ-?ô -?Ñ)˜ à.2˜Ô+Ø/4˜Ô,Ø&)˜œØ'+˜œð1Ø#ŸKšKØ &¨¨bÝ (¨Ô)=Ñ >Ô >Ø '¨ñô ð ð
 "øÝ'Ô8ð 1ð 1ð 1Ý!$¤¡¤°Ô!2˜BØ×/Ò/Ñ1Ô1Ð1Ø#*˜Dà#'¤>ð 
HØ#%¤7¨lÐ#:Ð#:Ý*6ð)8Ø:<¼'ñ)Bñ+Cô +Cð %Cð (*ð %6Ø-0°2©X¨Ø$0×$7Ò$7¸¸T¹	ÀB¹Ñ$GÔ$GÐ$Gð &+˜FØ#%¤7˜DØ!#¤˜BÝ$&¤J¡L¤L˜E˜E˜Eð+1øøøñ#&1ðP ×&Ò&Ø Ô.°Ô0DØ œñ'ô 'ð 'ð ×'Ò'Ñ)Ô)Ð)Ð)Ð)ø�C×'Ò'Ñ)Ô)Ð)Ð)øøøøÝð 	(ð 	(ð 	(Ý‘”ˆBåŒL˜Ð-½¼ÐFÑFÔFÐFÝ ‘l”l‰GˆAˆq�!Ø×Ò˜q ! QÑ'Ô'Ð'Ð'Ð'Ð'ð	(øøøsW   ‰C3K/ Ã>BK/ Æ :K Æ;,G( Ç'K Ç(B*JÊK ÊJÊ+K Ë K/ ËK,Ë,K/ Ë/A"MÍMc                 óô   — | j         }|pd|_        |D ]!\  }}|j                             ||f¦  «         Œ"|j        r"|j        sd|_        |                     ¦   «          |D ]}|                     |¦  «         ŒdS )zSend response to HTTP request.s   500 Server ErrorTN)r   ÚstatusÚ
outheadersr:   ÚreadyÚsent_headersÚsend_headersÚwrite)rE   rS   rI   r@   r   ÚheaderÚvalueÚsegs           r   r%   zNativeGateway.send_responsee   s¤   € àŒhˆð Ð2Ð2ˆŒ
ð %ð 	3ð 	3‰MˆF�EØŒN×!Ò! 6¨5 /Ñ2Ô2Ð2Ð2ØŒIð 	˜cÔ.ð 	Ø#ˆCÔØ×ÒÑÔÐð ð 	ð 	ˆCØ�IŠI�c‰NŒNˆNˆNð	ð 	r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r8   rQ   r%   © r   r   r
   r
      sA   € € € € € Ø@Ð@à€IðO(ð O(ð O(ðbð ð ð ð r   r
   c                   ó&   — e Zd ZdZej        fd„ZdS )ÚCPHTTPServera#  Wrapper for cheroot.server.HTTPServer.

    cheroot has been designed to not reference CherryPy in any way, so
    that it can be used in other frameworks and applications. Therefore,
    we wrap it here, so we can apply some attributes from config ->
    cherrypy.server -> HTTPServer.
    c                 ó¢  — || _         | j         j        p| j         j        pd}t          j        j                             | |j        t          |j	        |j
        |¬¦  «         | j         j        pd| _        | j         j        pd| _        | j         j        | _        | j         j        | _        | j         j        | _        | j         j        | _        | j         j        | _        | j         j        pd}| j         j        rrt          j                             |¦  «        } || j         j        | j         j        | j         j        | j         j        ¦  «        | _        | j         j        | j        _        dS | j         j        r\t          j                             |¦  «        } || j         j        | j         j        | j         j        | j         j        ¦  «        | _        dS dS )zInitialize CPHTTPServer.N)Ú
minthreadsÚ
maxthreadsÚserver_namer   Ú	pyopenssl)Úserver_adapterÚsocket_hostÚsocket_fileÚcherootr   Ú
HTTPServerÚ__init__r   r
   Úthread_poolÚthread_pool_maxÚmax_request_header_sizeÚmax_request_body_sizeÚsocket_queue_sizeÚrequest_queue_sizeÚsocket_timeoutÚtimeoutÚshutdown_timeoutÚprotocol_versionÚprotocolÚnodelayÚ
ssl_moduleÚssl_contextÚget_ssl_adapter_classÚssl_certificateÚssl_private_keyÚssl_certificate_chainÚssl_ciphersÚssl_adapterÚcontext)rE   rh   rf   rz   Úadapter_classs        r   rm   zCPHTTPServer.__init__�   sÍ  € à,ˆÔàÔ*Ô6ð ØÔ*Ô6ðàð 	õ 	ŒÔ!×*Ò*Ø�.Ô*­MØ%Ô1Ø%Ô5Ø#ð	 	+ñ 	%ô 	%ð 	%ð ÔÔ7Ð<¸1ð 	Ô$ð ÔÔ5Ð:¸ð 	Ô"à"&Ô"5Ô"GˆÔØÔ*Ô9ˆŒØ $Ô 3Ô DˆÔØÔ+Ô<ˆŒØÔ*Ô2ˆŒàÔ(Ô3ÐB°{ˆ
ØÔÔ*ð 	1Ý#œN×@Ò@ÀÑLÔLˆMØ,˜}ØÔ#Ô3ØÔ#Ô3ØÔ#Ô9ØÔ#Ô/ñ	 1ô  1ˆDÔð
 (,Ô':Ô'FˆDÔÔ$Ð$Ð$ØÔ Ô0ð 	1Ý#œN×@Ò@ÀÑLÔLˆMØ,˜}ØÔ#Ô3ØÔ#Ô3ØÔ#Ô9ØÔ#Ô/ñ	 1ô  1ˆDÔÐÐð	1ð 	1r   N)r\   r]   r^   r_   r!   r   rm   r`   r   r   rb   rb   x   s9   € € € € € ðð ð '/¤oð '1ð '1ð '1ð '1ð '1ð '1r   rb   )r_   rC   r5   r<   Úcheroot.serverrk   r!   Úcherrypy._cperrorr   r   Úcherrypy.libr   Ú	_cpcompatr   r   ÚGatewayr
   rl   rb   r`   r   r   ú<module>r‰      sè   ðØ AÐ Aà €€€Ø 
€
€
€
Ø 	€	€	€	à Ð Ð Ð à €€€Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð ðfð fð fð fð f�G”NÔ*ñ fô fð fðR01ð 01ð 01ð 01ð 01�7”>Ô,ñ 01ô 01ð 01ð 01ð 01r   