U `@spdZddlmZddlZddlmZddlmZddlmZddl m Z e d e ee ZGd d d eZdS) z NTLM authenticating pool, contributed by erikcederstran Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10 )absolute_importN) getLogger)ntlm)HTTPSConnectionPool)HTTPSConnectiona#The 'urllib3.contrib.ntlmpool' module is deprecated and will be removed in urllib3 v2.0 release, urllib3 is not able to support it properly due to reasons listed in issue: https://github.com/urllib3/urllib3/issues/2282. If you are a user of this module please comment in the mentioned issue.cs:eZdZdZdZfddZddZd fd d ZZS) NTLMConnectionPoolzQ Implements an NTLM authentication version of an urllib3 connection pool ZhttpscsLtt|j||||_||_|dd}|d|_|d|_||_ dS)z authurl is a random URL on the server that is protected by NTLM. user is the Windows user, probably in the DOMAIN\username format. pw is the password for the user. \rN) superr__init__authurlrawusersplitupperdomainuserpw)selfrrr argskwargsZ user_parts __class__I/opt/alt/python38/lib/python3.8/site-packages/urllib3/contrib/ntlmpool.pyr "s  zNTLMConnectionPool.__init__c Cs|jd7_td|j|j|jddi}d}d}t|j|jd}dt|j ||<td || d |jd|| }t | }td |j|jtd |td |dd|_||d}d}|D] } | dddkr| dd}q|dkrtd|||ft|\} } t| |j|j|j| } d| ||<td || d |jd|| }td |j|jtd t | td |dd|jdkr|jdkrtdtd|j|jfd|_td|S)Nr z3Starting NTLM HTTPS connection no. %d: https://%s%s Connection Keep-AliveZ Authorizationzwww-authenticate)hostportzNTLM %szRequest headers: %sZGETzResponse status: %s %szResponse headers: %szResponse data: %s [...]dz, zNTLM z!Unexpected %s response header: %siz3Server rejected request: wrong username or passwordzWrong server response: %s %szConnection established)Znum_connectionslogdebugrr rrrZcreate_NTLM_NEGOTIATE_MESSAGErZrequestZ getresponsedictZ getheadersZstatusreasonreadfpr ExceptionZparse_NTLM_CHALLENGE_MESSAGEZ create_NTLM_AUTHENTICATE_MESSAGErrr) rheadersZ req_headerZ resp_headerZconnresZreshdrZauth_header_valuesZauth_header_valuesZServerChallengeZNegotiateFlagsZauth_msgrrr _new_conn0sn          zNTLMConnectionPool._new_connNTc s0|dkr i}d|d<tt||||||||S)Nrr)r rurlopen)rmethodZurlZbodyr)ZretriesZredirectZassert_same_hostrrrr.ss  zNTLMConnectionPool.urlopen)NNr-TT) __name__ __module__ __qualname____doc__Zschemer r,r. __classcell__rrrrrs Gr)r3Z __future__rwarningsZloggingrrrZpackages.six.moves.http_clientrwarnDeprecationWarningr0r"rrrrrs