
    .Ph                     l    d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZmZ  G d de          Zd	 Zd
S )a  Requests HTTP client support for Dulwich.

To use this implementation as the HTTP implementation in Dulwich, override
the dulwich.client.HttpGitClient attribute:

  >>> from dulwich import client as _mod_client
  >>> from dulwich.contrib.requests_vendor import RequestsHttpGitClient
  >>> _mod_client.HttpGitClient = RequestsHttpGitClient

This implementation is experimental and does not have any tests.
    )BytesIO)Session   )AbstractHttpGitClientHTTPProxyUnauthorizedHTTPUnauthorizeddefault_user_agent_string)GitProtocolErrorNotGitRepositoryc                   .     e Zd Z	 d	 d fdZddZ xZS )	RequestsHttpGitClientNreturnc                     || _         || _        t          |          | _        |||f| j        _         t                      j        d||d| d S )N)base_urldumb )	_username	_passwordget_sessionsessionauthsuper__init__)selfr   r   configusernamepasswordkwargs	__class__s          _/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/dulwich/contrib/requests_vendor.pyr   zRequestsHttpGitClient.__init__0   sa     "!"6**!)8 4DL@(@@@@@@@    Fc                    | j         j                                        }||                    |           |rd|d<   nd|d<   |r| j                             |||          }n| j                             ||          }|j        dk    rt          |j        dk    r(t          |j                            d          |          |j        d	k    r(t          |j                            d
          |          |j        dk    rt          d|j         d|           |j                            d          |_        d|_        |j        r|j        |_        t          |j                  j        }||fS )NgzipzAccept-Encodingidentity)headersdata)r%   i  i  zWWW-Authenticatei  zProxy-Authenticate   zunexpected http resp z for zContent-Type )r   r%   copyupdatepostgetstatus_coder   r   r   r
   content_typeredirect_locationhistoryurlr   contentread)r   r1   r%   r&   allow_compressionreq_headersrespr3   s           r    _http_requestz#RequestsHttpGitClient._http_request=   s   l*//11w''' 	8-3K)**-7K)* 	><$$S+D$IIDD<##C#==Ds""""s"""4<#3#34F#G#GMMMs""'(8(89M(N(NPSTTTs"""#W4;K#W#WRU#W#WXXX !L,,^<<!#< 	.%)XD"t|$$)Tzr!   )NNNN)r   N)NNF)__name__
__module____qualname__r   r7   __classcell__)r   s   @r    r   r   /   sc        HLA	A A A A A A               r!   r   c                 n   t                      }|j                            ddi           d x}x}x}}| 	 |                     dd          }t	          |t
                    r|                                }n# t          $ r Y nw xY w	 |                     dd          }t	          |t
                    r|                                }n# t          $ r Y nw xY w	 |                     dd          }n# t          $ r d}Y nw xY w	 |                     dd          }t	          |t
                    r|                                }n# t          $ r d }Y nw xY w|t                      }|j                            d	|i           |r||_
        n|d
u r||_
        |r|j                            ||d           |S )NPragmazno-caches   https   proxys	   useragents	   sslVerifyTs	   sslCAInfoz
User-agentF)httphttps)r   r%   r*   r,   
isinstancebytesdecodeKeyErrorget_booleanr	   verifyproxies)r   r   proxy_server
user_agentca_certs
ssl_verifys         r    r   r   `   s   iiGOHj12228<<L<:<:	!::gx88L,.. 5+2244 	 	 	D		G\::J*e,, 1'..00
 	 	 	D		++G\BBJJ 	 	 	JJJ		zz'<88H(E** -#??,, 	 	 	HHH	 .00
OL*5666 $!	u		# N|LLMMMNsG   ?A7 7
BB?C 
CCC0 0C?>C??E EEN)__doc__ior   requestsr   clientr   r   r   r	   errorsr
   r   r   r   r   r!   r    <module>rP      s   ,
 
                        8 7 7 7 7 7 7 7. . . . .1 . . .b, , , , ,r!   