o ]Lb@spddlmZddlZddlmZddlmZddlmZmZddl m Z ej Z ej Z Gdd d e Zd d ZdS) )absolute_importN)_)open)pycompatutil)urlutilc@s8eZdZdZddZddZddZdd Zd d Zd S) httpsendfilezThis is a wrapper around the objects returned by python's "open". Its purpose is to send file-like objects via HTTP. It do however not define a __len__ attribute because the length might be more than Py_ssize_t can handle. cOs\||_t|i||_|jj|_|jj|_|jj|_t|jj |_ d|_ | |_ dS)Nr)uir_dataseekclosewriteosfstatfilenost_sizelength_pos _makeprogress _progress)selfr argskwargsr:/usr/lib/python3/dist-packages/mercurial/httpconnection.py__init__&s   zhttpsendfile.__init__cCs$|jjtdtd|jdddS)Nssendingskb)unittotal)r makeprogressrrrrrrr0szhttpsendfile._makeprogresscOsL|jj|i|}|s|j|S|jt|7_|j|jd|S)Nr)r readrcompleterlenupdate)rrrretrrrr#:s zhttpsendfile.readcCs|SNrr"rrr __enter__Cszhttpsendfile.__enter__cCs |dSr()r )rexc_typeexc_valexc_tbrrr__exit__Fs zhttpsendfile.__exit__N) __name__ __module__ __qualname____doc__rrr#r)r-rrrrr s   r cCst|}i}|dD]2\}}|dvrq d|vr#|td|q |dd\}}||i}|dvr:t|}|||<q | dd\} } d} d} d} t |D]\}}|ra|| d |kraqR| d }|siqRt |}|jrw|j|krwqRd|_t|}| dd}t|dkr|dg|d}}n | d pd }|d ks| |rt|| kst|| kr| sd |vr| |vrt|} ||f} | d } |r| s||d <qR| S)Nsauth)s cookiefile.s!ignoring invalid [auth] key '%s' r)usernamescertskeys://rr3sprefixsschemesshttps*)rbytesurl configitemswarnrrsplit setdefaultr expandpathsplit iteritemsgetrurluserbytesr% startswith)r urir?groupskeyvalgroupsettinggdictschemehostpathbestuserbestlenbestauthauthprefix prefixurlpschemesrrrreadauthforuriKs\           rS) __future__rri18nrrrrutilsrurlerrurlreqobjectr rSrrrrs     -