
     f                        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mZ d dlmZ d dlZededej        f         deej        ddf         fd	            Zej                            ej                            e          d
          Z eed          5 Ze                                Zddd           n# 1 swxY w Y    G d de
          ZddZ G d dej                  ZddZ dS )    N)closingcontextmanager)SimpleHTTPRequestHandler)Callable	Generator)urlopenhandler.returnc              #     K   t          j        d|           }t          j        |j        ddi          }d|_        	 |                                 |V  |                                 d S # |                                 w xY w)N)z	127.0.0.1r   poll_intervalg{Gz?)targetkwargsT)socketserver	TCPServer	threadingThreadserve_foreverdaemonstartshutdown)r	   httpdthreads      e/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/h11/tests/test_against_stdlib_http.pysocket_serverr      s       "#3W==E"OT+B  F FMs   A+ +Bzdata/test-filerbc                       e Zd ZdedefdZdS )SingleMindedRequestHandlerpathr
   c                     t           S )N)test_file_path)selfr   s     r   translate_pathz)SingleMindedRequestHandler.translate_path$   s        N)__name__
__module____qualname__strr"    r#   r   r   r   #   s6        3 3      r#   r   c                     t          t                    5 } t          t          j        | j                            5 }t          j        t          j                  }|	                    |
                    t          j        dddg                               |	                    |
                    t          j                                         t                      }	 |                                }t          |           |t          j        u r)|                    |                    d                     [t'          |          t          j        u r|j        dk    sJ t'          |          t          j        u r
||j        z  }t'          |          t          j        u rnt1          |          t2          k    sJ 	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NGETz/foo)Host	localhostmethodr   headersT
      )r   r   r   socketcreate_connectionserver_addressh11
ConnectionCLIENTsendallsendRequestEndOfMessage	bytearray
next_eventprint	NEED_DATAreceive_datarecvtypeResponsestatus_codeDatadatabytestest_file_data)r   scrF   events        r   test_h11_as_clientrL   (   s2   	1	2	2 1eV-e.BCCDD 	1sz**AIIK$V>S=T      IIaffS-//00111;;DeCM)) NN166"::...;;#,.. ,3333;;#(**EJ&D;;#"222 ;;.000007	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s5   'G$FG G$G	G$G	G$$G(+G(c                       e Zd ZddZdS )H11RequestHandlerr
   Nc           
         t          | j                  5 }t          j        t          j                  }d }	 |                                }|t          j        u r)|                    |                    d                     Lt          |          t          j
        u r|}t          |          t          j        u rn|J t          j        |j                            d          |j                            d          d |j        D             d          }|                    |                    t          j        dg                                |                    |                    t          j        |                    d                                         |                    |                    t          j                                         d d d            d S # 1 swxY w Y   d S )	NTr0   asciic                 f    i | ].\  }}|                     d           |                     d           /S )rP   )decode).0namevalues      r   
<dictcomp>z,H11RequestHandler.handle.<locals>.<dictcomp>]   sF          )T5 G,,ell7.C.C     r#   r-   r1   )rD   r/   )rF   )r   requestr5   r6   SERVERr=   r?   r@   rA   rB   r:   r;   jsondumpsr.   rR   r   r/   r8   r9   rC   rE   encode)r!   rI   rJ   rW   rK   infos         r   handlezH11RequestHandler.handleI   s   T\"" 	2asz**AG
CM)) NN166"::...;;#+--#G;;#"222
 &&&:%n33G<<%n33G<<   -4_      	 	D IIaffS\c2FFFGGHHHIIaffSX4;;w+?+?@@@AABBBIIaffS-//001117	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   GG''G+.G+r
   N)r$   r%   r&   r]   r(   r#   r   rN   rN   H   s(        2 2 2 2 2 2r#   rN   c                  *   t          t                    5 } | j        \  }}d                    ||          }t	          t          |                    5 }|                                dk    sJ |                                }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j	        |
                    d                    }t          |           |d         dk    sJ |d         dk    sJ d|d	         d
         v sJ d S )Nzhttp://{}:{}/some-pathr1   rP   r.   r*   r   z
/some-pathurllibr/   z
user-agent)r   rN   r4   formatr   r   getcodereadrY   loadsrR   r>   )r   hostporturlfrF   r\   s          r   test_h11_as_serverri   h   s   	(	)	) U)
d&--dD99WS\\"" 	a99;;#%%%%6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	               :dkk'**++D	$KKK>U"""">\))))tI|4444444s5   =B$/BB$B	B$B	B$$B(+B(r^   )!rY   os.pathosr2   r   r   
contextlibr   r   http.serverr   typingr   r   urllib.requestr   r5   BaseRequestHandlerr   r   r   joindirname__file__r    openrh   rc   rH   r   rL   rN   ri   r(   r#   r   <module>ru      s              . . . . . . . . 0 0 0 0 0 0 & & & & & & & & " " " " " " 



 c<::;|%tT12    bgooh779IJJ	T.$ 1VVXXN                  !9   
1 1 1 1@2 2 2 2 27 2 2 2@5 5 5 5 5 5s   C  CC