
    tc=              7       	   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Z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 ddlmZ ddlmZ dndZd	edefd
Zdodej        dedefdZdededej        e         dej         ej!        eef                  def
dZ"dodej        deddfdZ#dededej        e         dej         ej!        eef                  ddf
dZ$d	eddfdZ%ej!        ej!        eef         df         Z&ej!        e&df         Z'ej(        eej)        ee'e&f         f         Z*de*defdZ+	 dodedej,        eej-        f         deddfdZ.d	edej/        ddfdZ0d ej1        d!ej)        ej2        ej3        f         d"ej-        dej-        fd#Z4d ej1        d!ej)        ej2        ej3        f         d"ej-        dej-        fd$Z5d ej1        d!ej)        ej2        ej3        f         d"ej-        ddfd%Z6 ej7        d&           ej8        d'e(           ej9        d)d*d+ed,-           ej9        d.d/d0eefd1d23           ej9        d4d5d6ed7-           ej9        d8d9d:eefd1d;3           ej9        d<d=d>e ej:        d?@          fd1dA3           ej9        dBdCdDee4dEF           ej9        dGdHdeefd1dI3           ej9        dJdKeefd1dL3           ej9        dMdNeefdOe5dPQ           ej9        dRdSeddTU           ej9        dVdWe;dXdYU           ej9        dZd[d1dd\]           ej9        d^d_d1d1d`]           ej9        daded1ddbc           ej9        dd ej:        de          df-           ej9        dgdhed1ddic           ej9        djd1d1de6dkl          d'ed+ed0ej         ej!        eef                  d6ed:ej         ej!        eef                  d>ej         ej!        eej:        f                  dDedej         ej!        eef                  dKej         ej!        eef                  dNej        ej!        eef                  dSedWe;d[ed_ededej        ej/                 deddf$dm                                                                                                                                                                                                                                    Z<dS )p    N   )Client)RequestError)Response)codesreturnc                     t           j                                        } |                     dd           |                                  |                     dd           |                                  |                     dd           |                                  t           j        j                            dd	          }|                    d
ddd           |                    d           |                    dd           |                    dd           |                    dd           |                    dd           |                    dd           |                    dd           |                    dd           |                    dd           |                    dd           |                    d d!           |                    d"d#           |                    d$d%           |                    d&d'           |                    d(d)           |                    d*d+           |                    d,d-           |                    d.d/           |                     |           d S )0Nz[bold]HTTPX :butterfly:center)justifyzA next generation HTTP client.z7Usage: [bold]httpx[/bold] [cyan]<URL> [OPTIONS][/cyan] leftr   T)paddingpad_edge	Parameterbold)no_wrapr   styleDescriptionz-m, --method [cyan]METHODz{Request method, such as GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD.
[Default: GET, or POST if a request body is included]z#-p, --params [cyan]<NAME VALUE> .../Query parameters to include in the request URL.z-c, --content [cyan]TEXT,Byte content to include in the request body.z!-d, --data [cyan]<NAME VALUE> ...)Form data to include in the request body.z%-f, --files [cyan]<NAME FILENAME> ...*Form files to include in the request body.z-j, --json [cyan]TEXT)JSON data to include in the request body.z$-h, --headers [cyan]<NAME VALUE> .../Include additional HTTP headers in the request.z --cookies [cyan]<NAME VALUE> ..."Cookies to include in the request.z--auth [cyan]<USER PASS>Username and password to include in the request. Specify '-' for the password to use a password prompt. Note that using --verbose/-v will expose the Authorization header, including the password encoding in a trivially reversible format.z--proxies [cyan]URLISend the request via a proxy. Should be the URL giving the proxy address.z--timeout [cyan]FLOATzTimeout value to use for network operations, such as establishing the connection, reading some data, etc... [Default: 5.0]--follow-redirectsAutomatically follow redirects.--no-verifyDisable SSL verification.--http2@Send the request using HTTP/2, if the remote server supports it.z--download [cyan]FILE?Save the response content as a file, rather than displaying it.z-v, --verbosez1Verbose output. Show request as well as response.--helpShow this message and exit.)	richconsoleConsoleprinttableTablegrid
add_columnadd_row)r(   r+   s     -/usr/lib/python3/dist-packages/httpx/_main.py
print_helpr1      s   l""$$GMM+XM>>>MMOOOMM2HMEEEMMOOOMMA6     MMOOOJ!!!d!;;E	[$fMMM	]###	MM#	@  
 
MM-9   
MM"$R   
MM+-X   
MM/4   
MM)+VWWW	MM.9   
MM*,P   
MM"	T   
MMS  
 
MM	3   
MM&(IJJJ	MM-!<===	MMU   
MMI  
 
MM/#VWWW	MM(9:::MM%    responsec                 B   | j                             d          }||                    d          \  }}}	 t          j        t
          t          j                            |	                                          j
                  S # t          j        j        $ r Y nw xY wdS )NzContent-Type; )headersget	partitiontypingcaststrpygmentslexersget_lexer_for_mimetypestripnameutilClassNotFound)r3   content_type	mime_type_s       r0   get_lexer_for_responserG   b   s    #''77L&0055	1a	;X_;;IOO<M<MNNS   }* 	 	 	D	2s   AB BBFrequesthttp2c                    rdnd}fd| j         D             }| j                            d          }| j        j                            d          }| d| d| gd |D             z   }d                    |          S )NzHTTP/2zHTTP/1.1c                 J    g | ]\  }}r|                                 n||f S  )lower).0rA   valuerI   s      r0   
<listcomp>z*format_request_headers.<locals>.<listcomp>q   s@       5@T5	(D%0  r2   ascii c                 n    g | ]2\  }}|                     d            d|                     d            3S rQ   : decoderN   rA   rO   s      r0   rP   z*format_request_headers.<locals>.<listcomp>v   O     0 0 0?JtU4;;w::5<<#8#8::0 0 0r2   
)r7   methodrW   urltargetjoin)rH   rI   versionr7   r[   r]   liness    `     r0   format_request_headersra   o   s    /hhZG   DKO  G ^""7++F[&&w//F++++'++, 0 0NU0 0 0 E 99Ur2   http_versionstatusreason_phraser7   c                     |                      d          }|t          j        |          n|                     d          }| d| d| gd |D             z   }d                    |          S )NrQ   rR   c                 n    g | ]2\  }}|                     d            d|                     d            3S rT   rV   rX   s      r0   rP   z+format_response_headers.<locals>.<listcomp>   rY   r2   rZ   )rW   r   get_reason_phraser^   )rb   rc   rd   r7   r_   reasonr`   s          r0   format_response_headersri   |   s     !!'**G   	'''!!'** 
 ++&++6++, 0 0NU0 0 0 E 99Ur2   c                 D   t           j                                        }t          | |          }t           j                            |ddd          }|                    |           t           j                            dddd          }|                    |           d S )NrI   http	ansi_darkTtheme	word_wrapr6   )r'   r(   r)   ra   syntaxSyntaxr*   )rH   rI   r(   	http_textrq   s        r0   print_request_headersrt      s    l""$$G&we<<<I[	6PTUUFMM&[F+NNFMM&r2   c                 F   t           j                                        }t          | |||          }t           j                            |ddd          }|                    |           t           j                            dddd          }|                    |           d S )Nrl   rm   Trn   r6   )r'   r(   r)   ri   rq   rr   r*   )rb   rc   rd   r7   r(   rs   rq   s          r0   print_response_headersrv      s     l""$$G'fmWUUI[	6PTUUFMM&[F+NNFMM&r2   c                    t           j                                        }t          |           }|r|                                dk    rC	 |                                 }t          j        |d          }n# t          $ r
 | j        }Y nw xY w| j        }t           j	        
                    ||dd          }|                    |           d S |                    dt          | j                   d           d S )	Njson   )indentrm   Trn   <z bytes of binary data>)r'   r(   r)   rG   rM   rx   dumps
ValueErrortextrq   rr   r*   lencontent)r3   r(   
lexer_namedatar~   rq   s         r0   print_responser      s    l""$$G'11J I''%}}z$q111 % % %}% =D##D*KSW#XXfG#h.//GGGHHHHHs   	*A4 4BB.certc           
      B   g }|                                  D ]\  }}t          |t          t          f          r|                    d| d           |D ]}|dv r-|D ])}|                    d|d          d|d                    *3t          |t                    r;t          |          dk    r(|                    d|d          d|d                    |                    d|           |                    d| d|           d	                    |          S )
Nz*   :)subjectissuerz*     r   rU   r      rZ   )items
isinstancelisttupleappendr   r^   )r   r`   keyrO   itemsub_items         r0   format_certificater      s]   Ejjll 2 2
UedE]++ 	2LL''' 4 4///$( N N%Lhqk%L%LXa[%L%LMMMMNe,, 4TaLL!@$q'!@!@T!W!@!@AAAALL!2$!2!233334 LL000u00111199Ur2   rA   infoverbosec                 4   t           j                                        }| dk    r$|r"|d         }|                    d|           d S | dk    rH|rF|d         }|                    d          }|                    d|d         d	|d
                     d S | dk    r|r|d         }|                    d          }|                                }|                                }	|                                }
|                                }|                    d|d|	d                    |                    d|           |
r9|                    d           |                    t          |
                     d S d S | dk    r|r|d         }t          |d           d S | dk    r|r|d         }t          |d           d S | dk    r!|d         \  }}}}t          ||||           d S | dk    r#|d         \  }}d}d }t          ||||           d S d S )Nzconnection.connect_tcp.startedhostz* Connecting to zconnection.connect_tcp.completereturn_valueserver_addrz* Connected to r   z	 on port r   zconnection.start_tls.complete
ssl_objectz* SSL established using z / z* Selected ALPN protocol: z* Server certificate:z#http11.send_request_headers.startedrH   Frk   z"http2.send_request_headers.startedTz(http11.receive_response_headers.completez'http2.receive_response_headers.completes   HTTP/2)r'   r(   r)   r*   get_extra_infor_   ciphergetpeercertselected_alpn_protocolr   rt   rv   )rA   r   r   r(   r   streamr   r   r_   r   server_certalpnrH   rb   rc   rd   r7   s                    r0   tracer      s    l""$$G///G/F|11122222	2	2	2w	2n%++M::SASS;q>SSTTTTT	0	0	0W	0n%**<88
$$&&""$$ ,,..0022LLLvayLLMMM;4;;<<< 	;MM1222MM,[99:::::	; 	; 
6	6	67	6y/gU333333	5	5	5'	5y/gT222222	;	;	;7;N7K4fmW|V]GLLLLL	:	:	:~. |V]GLLLLL	 
;	:r2   downloadc                    t           j                                        }|                                 | j                            d          }t           j                            ddt           j                            d           t           j        	                                t           j        
                                          5 }dt           j                            |j                   }|                    |t          |pd          |d u          }|                                 D ]3}|                    |           |                    || j                   4	 d d d            d S # 1 swxY w Y   d S )	NzContent-Lengthz([progress.description]{task.description}z-[progress.percentage]{task.percentage:>3.0f}%)	bar_widthzDownloading [bold]r   )totalstart)	completed)r'   r(   r)   r*   r7   r8   progressProgress	BarColumnDownloadColumnTransferSpeedColumnmarkupescaperA   add_taskint
iter_byteswriteupdatenum_bytes_downloaded)r3   r   r(   content_lengthr   descriptiondownload_taskchunks           r0   download_responser      s   l""$$GMMOOO%))*:;;N			27$//$$&&))++
 
 T 
N4;+=+=hm+L+LNN ))n)** , * 
 

 ((** 	T 	TENN5!!!OOMX5ROSSSS	TT T T T T T T T T T T T T T T T T Ts   BE--E14E1ctxparamrO   c                     |d S 	 t          j        |          S # t           j        $ r t          j        d          w xY w)NzNot valid JSON)rx   loadsJSONDecodeErrorclickBadParameterr   r   rO   s      r0   validate_jsonr     sS    
 }t3z%    3 3 3 !12223s    $>c                 \    |dk    rd S |\  }}|dk    rt          j        dd          }||fS )NNN-PasswordT)
hide_input)r   prompt)r   r   rO   usernamepasswords        r0   validate_authr     sF    
 tHh3<
t<<<hr2   c                 `    |r| j         rd S t                       |                                  d S )N)resilient_parsingr1   exitr   s      r0   handle_helpr   (  s5    
  C) LLLHHJJJJJr2   )add_help_optionr\   )typez--methodz-mr[   z{Request method, such as GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD. [Default: GET, or POST if a request body is included])r   helpz--paramsz-pparamsTr   )r   multipler   z	--contentz-cr   r   z--dataz-dr   r   z--filesz-ffilesrb)moder   z--jsonz-jrx   r   )r   callbackr   z	--headersz-hr   z	--cookiescookiesr   z--authauthr   r   )r   defaultr   r   z	--proxiesproxiesr   )r   r   r   z	--timeouttimeoutg      @r   r   follow_redirectsr   )is_flagr   r   r    verifyr!   r"   r#   )r   r   r   r   z
--downloadwbr$   z	--verbosez-vz*Verbose. Show request as well as response.r%   r&   )r   is_eagerexpose_valuer   r   c                    |s|s|s|s|rdnd}	 t          |
|||          5 }|                    || t          |          |t          |          |||t          |          |	|dt	          j        t          |          i          5 }|t          ||           n*|                                 |j	        rt          |           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   nv# t          $ ri}t          j                                        }|                    dt!          |          j         d	|            t%          j        d
           Y d}~nd}~ww xY wt%          j        |j        rdnd
           dS )zU
    An HTTP command line client.
    Sends a request and displays the response.
    POSTGET)r   r   r   rI   r   )r   )
r   r   r   r   rx   r7   r   r   r   
extensionsNz[red]z[/red]: r   r   )r   r   r   dict	functoolspartialr   r   readr   r   r   r'   r(   r)   r*   r   __name__sysr   
is_success)r\   r[   r   r   r   r   rx   r7   r   r   r   r   r   r   rI   r   r   clientr3   excr(   s                        r0   mainr   4  s:   D  G"FdFeFtF	
 
 
 	1
 F||$ZZW!1#Y%6ug%N%N%NO    1 '%h9999MMOOO' 1&x000'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 	16    ,&&((?d3ii0??#??@@@
 H(%,QQ1-----s`   C4 A$C(>CC(C	C(C	C(C4 (C,,C4 /C,0C4 4
E'>AE""E')r   N)F)=r   rx   r   r:   r   httpcorepygments.lexersr=   pygments.utilrich.consoler'   rich.markuprich.progressrich.syntax
rich.table_clientr   _exceptionsr   _modelsr   _status_codesr   r1   r<   rG   Requestboolra   bytesr   OptionalListTupleri   rt   rv   r   _PCTRTT_PCTRTTTDictUnion_PeerCertRetDictTyper   MappingAnyr   BinaryIOr   ContextOptionr   r   r   r   commandargumentoptionFilefloatr   rL   r2   r0   <module>r     sE	        



                                      % % % % % %                  I I I IX
X 
# 
 
 
 

 
H$4 
T 
c 
 
 
 
 ?5) [eUl34	
 	   $ 8#3 D T     ?5) [eUl34	
 
   IX I$ I I I I& ,v|CH-s2
3<%{3S(G5K(L#LM 1 c    & GL$M $M
$M^CO4$M?C$M	$M $M $M $MNT TFO T T T T T,3	3<eo563 :3 Z	3 3 3 3 	 <eo56  :  Z	       			<eo56	 :	 
		 	 	 	 u%%%C   		@	 	 	 
s	:   		7   

s	4   
zuzt$$$	%	5   
		4   
s	:   
s	-   

s	L   		T   		?	 	 	 	*   	$   		K   	D			J  
 		5   	&  ;.	;.;. KS#X./;. 	;.
 +fl38,
-;. ;v|CO45;. ;. [c3h/0;. [c3h/0;. /&,sCx0
1;. ;. ;. ;. ;. ;.  ofo.!;." #;.$ 
%;. ;. ;.      	 	         	 	 !  &%V;. ;. ;.r2   