�t�c@s�ddlZddlZddlZddlZddlZddlmZddlmZddlmZddl m
Z
defd��YZd�Z
d ejfd
��YZdejfd��YZead
Zdejejfd��YZdS(i�N(t
httpclient(tsslutil(tutil(t_thttpsendfilecBs eZdZd�Zd�ZRS(s�This 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||�|_|jj|_|jj|_|jj|_tj|jj��j |_
d|_|j
dd|_dS(Niii(
tuitopent_datatseektclosetwritetostfstattfilenotst_sizetlengtht_post_total(tselfRtargstkwargs((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyt__init__s cOs�y|jj||�}Wn*tk
rE|jjtd�d�nX|jt|�7_|jjtd�|jddtd�d|j �|S(Ntsendingitunittkbttotal(
RtreadtEOFErrorRtprogressRtNoneRtlenR(RRRtret((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyR+s
(t__name__t
__module__t__doc__RR(((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyRs
c
CsIt�}x�|jd�D]�\}}d|krN|jtd�|�qn|jdd�\}}|j|t��}|dkr�tj|�}n|||<qWd|kr�|jdd�\} }
n
d |} }
d}d
}d}
xU|j
�D]G\}}|r*||jd|�kr*q�|jd�}|sEq�|jdd�}t|�dkr�|d
g|d}}n|jd�p�d
j�}|dks�|
j
|�r�|�|ks�|�|kr�r�|kr�|kr�|�}||f}
|jd�}|rA|rA||d<qAq�W|
S(Ntautht.s!ignoring invalid [auth] key '%s'
itusernametcerttkeys://thttpitprefixtschemesthttpst*(susernameR&skey(tdicttconfigitemstwarnRtrsplitt
setdefaultRt
expandpathtsplitRt iteritemstgetRt
startswith(RturitusertconfigR'tvaltgrouptsettingtgdicttschemethostpathtbestusertbestlentbestauthR#R)tpR*((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pytreadauthforuri;sH
$
tHTTPResponsecBseZd�ZRS(cCsdS(N((R((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyR ms(R R!R (((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyRElstHTTPConnectioncBseZeZdid�ZRS(cCsEt|t�r|jd�ntjj|||d|d|�dS(Nitbodytheaders(t
isinstanceRRRRFtrequest(RtmethodR7RGRH((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyRJrsN(R R!REtresponse_classRRJ(((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyRFpss-%(levelname)s:%(name)s:%(lineno)d:%(message)sthttp2handlercBsAeZd�Zd�Zd�Zd�Zd�Zdd�ZRS(cCs�tjj|�||_||_i|_|jdddd�}|r�tr�t at
jd�}|jt
t
|j���t
j�}|jt
jt��|j|�ndS(NRthttp2debugleveltdefaultsmercurial.httpclient(turllib2tAbstractHTTPHandlerRRtpwmgrt_connectionsR9Rt_configuredloggingtTruetloggingt getLoggertsetLeveltgetattrtuppert
StreamHandlertsetFormattert FormattertLOGFMTt
addHandler(RRRRtlogleveltloggerthandler((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyRs
cCsBx2|jj�D]!}x|D]}|j�qWqWi|_dS(s=Close and remove all connection objects being kept for reuse.N(RStvaluesR (Rt openconnstconn((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyt close_all�s
cCs�t|dd
�}|j�}|r3|}|}nM|j�rz|j�}|j�jdd�djdd�d}nd
}|r�d|kr�|jdd�\}}nd}||f}nd
}|s�jd��n|||f} |j j
| g�}
g|
D]}|j�s|^q}|r<|d}
nu|
rY|jj
d |�nd
}|jtjk r}|j}n||d
|d|�}
|j j| g�j|
�t|j�}|j|j�td�|j�D��}y�|j�}d|kr0|jdd�djdd�d}n|ddkrMd|}n|
j|j�||j|�|
j�}Wn%tjk
r�}tj|��nX|j|_tj ||j|j!��}|j"|_#|j$|_%|S(s�Return an addinfourl object for the request, using http_class.
http_class must implement the HTTPConnection API from httplib.
The addinfourl return value is a file-like object. It also
has methods and attributes including:
- info(): return a mimetools.Message object for the headers
- geturl(): return the original request URL
- code: HTTP status code
t_tunnel_hosts://it/it:i8s
no host givens.all connections for %s busy, making a new one
ttimeouttproxy_hostportcss'|]\}}|j�|fVqdS(N(ttitle(t.0tnameR:((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pys <genexpr>�sN(&RYRtget_hostt has_proxytget_selectorR3R0RPtURLErrorRSR5tbusyRtdebugRjtsockett_GLOBAL_DEFAULT_TIMEOUTR1tappendR-RHtupdatetunredirected_hdrstitemsRJt
get_methodtdatatgetresponseterrorRtrecvturllibt
addinfourltget_full_urltstatustcodetreasontmsg(Rt
http_classtreqtuse_sslttunhostthostt proxyhostt proxyporttproxytconnkeytallconnstctconnsthRjRHtpathtrterrtresp((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pytdo_open�sb /%
)
cCs>|j�jd�r"|j|�Sd�}|j||t�S(NR+c_s#t|�}t|d<t||�S(NR�(R-tFalseRF(RRtk2((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pytmakehttpcon�s
(R�R6t
https_openR�R�(RR�R�((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyt http_open�s
cCs�|j�}|jj|�\}}t|j||�}|rk|\}}||_|jjd|�n d|_|j|j |t
�S(Ns#using auth.%s.* for authentication
(R�RRtfind_stored_passwordRDRR#RtRR�t_makesslconnectionRU(RR�turlR8tpasswordtresR;R#((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyR��s i�c
OsZd}d}|r$|jd�}n|r<|jd�}n|jr�d|jkr�d|jkr�|jd}|jd}nd|kr�d|ks�d|kr�jdd�\}}t|�}d|kr�dd!}q�|r�|d <n|r
||d
<n|jtj|j|��t ||dt
dtj|j|�|�}|S(
NiR'R&Rit[s]:ii�tkeyfiletcertfileR�t
ssl_validator(RtpopR#R0tintRxRt sslkwargsRRFRUt validator(RR�tportRRR�R�tcon((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyR�s.'
$
(R R!RRfR�R�R�R�(((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyRM~s S (RVRuR�RPRt mercurialRRRtmercurial.i18nRtobjectRRDRERFR�RTR^tHTTPHandlertHTTPSHandlerRM(((s</sys/lib/python2.7/site-packages/mercurial/httpconnection.pyt<module>
s% 1
|