-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/transport/http/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyc

ó
î:ïNc@@sÀdZddlmZddlmZddlZddlZddlmZmZm	Z	ddl
mZmZm
Z
mZyddlZWn5ek
rÃZe	jdeƒejdeƒ‚nXyejƒWn8ejk
rZe	jd	eƒejdeƒ‚nXd
„ZeddƒZed
dƒZeddƒZeddƒZeddƒZeddƒZeddƒZeddƒZeddƒZdefd„ƒYZ d„Z!dS( s!http/https transport using pycurli(tabsolute_import(tStringION(tdebugterrorsttrace(t	ca_bundletHttpTransportBasetresponsetunhtml_roughlysfailed to import pycurl: %stpycurlsfailed to initialize pycurl: %scC@stjj||ƒS(sÀ
    Returns the numerical error code for a symbol defined by pycurl.

    Different pycurl implementations define different symbols for error
    codes. Old versions never define some symbols (wether they can return the
    corresponding error code or not). The following addresses the problem by
    defining the symbols we care about.  Note: this allows to define symbols
    for errors that older versions will never return, which is fine.
    (R	t__dict__tget(tsymboltdefault((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyt_get_pycurl_errcodeLs
tE_COULDNT_CONNECTitE_COULDNT_RESOLVE_HOSTitE_COULDNT_RESOLVE_PROXYit
E_GOT_NOTHINGi4tE_PARTIAL_FILEitE_SEND_ERRORi7tE_RECV_ERRORi8tE_SSL_CACERTi<tE_SSL_CACERT_BADFILEiMtPyCurlTransportcB@sªeZdZdd„Zd„Zd„Zd„Zdd„Zd„Z	d„Z
d	„ZdZd„Z
d
„Zd„Zddd„Zd„Zd„Zgd„ZRS(sãhttp client transport using pycurl

    PyCurl is a Python binding to the C "curl" multiprotocol client.

    This transport can be significantly faster than the builtin
    Python client.  Advantages include: DNS caching.
    cC@sutt|ƒj|dd|ƒ|jdkrbtjƒd}d|krbtjddƒ‚qbntj	ƒ|_
dS(NR	t_from_transportthttpsisno https support(tsuperRt__init__t_unqualified_schemeR	tversion_infoRtDependencyNotPresentRtget_ca_pathtcabundle(tselftbaseRt	supported((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyRlscC@sG|jƒ}|dkrCtjƒ}|jƒ}|j||ƒn|S(N(t_get_connectiontNoneR	tCurlt_create_autht_set_connection(R"t
connectiontauth((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyt	_get_curlwscC@s)|jƒ}|dk	r%|jƒndS(N(R%R&tclose(R"R*((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyt
disconnect†scC@sò|jƒ}|j|ƒ}|jtj|ƒ|j|ƒ|jtjdƒ|jtjdƒtƒ}|jtj	|j
ƒtƒ}|jtj|j
ƒ|j||ƒ|j
tjƒ}|dkrÑtS|dkrátS|j|ƒdS(sSee Transport.has()ii”iÈN(R,t_remote_pathtsetoptR	tURLt_set_curl_optionstHTTPGETtNOBODYRtHEADERFUNCTIONtwritet
WRITEFUNCTIONt
_curl_performtgetinfot	HTTP_CODEtFalsetTruet_raise_curl_http_error(R"trelpathtcurltabspaththeadert	blackholetcode((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pythas‹s"
		icC@s?|dk	s|dkr.|j||d|ƒS|j|ƒSdS(Nittail_amount(iN(R&t_get_rangedt	_get_full(R"R>toffsetsRE((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyt_get¨scC@s6|jtjdƒ|jtjdƒ|j||ƒS(Nii(R0R	R4R3t_setup_request(R"R?R>((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyt_setup_get_request¯scC@sz|j|ƒ}|jtj|ƒ|j|ƒtƒ}tƒ}|jtj|jƒ|jtj|jƒ|||fS(s€Do the common setup stuff for making a request

        :param curl: The curl object to place the request on
        :param relpath: The relative path that we want to get
        :return: (abspath, data, header)
                 abspath: full url
                 data: file that will be filled with the body
                 header: file that will be filled with the headers
        (	R/R0R	R1R2RR7R6R5(R"R?R>R@tdataRA((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyRJ·s

		cC@s|jƒ}|j||ƒ\}}}|j||ƒ|jtjƒ}|jdƒ|dkrttj|ƒ‚n|dkr“|j	|dƒn||fS(s"Make a request for the entire fileii”iÈs&expected 200 or 404 for full response.(
R,RKR8R9R	R:tseekRt
NoSuchFileR=(R"R>R?R@RLRARC((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyRGÌs

iicC@s|jƒ}|j||ƒ\}}}|j||ƒ}|dkrR|j|ƒS|j||d|gƒ|jdƒ|jtj	ƒ}	|	dkr©t
j|ƒ‚n4|	dkrÝt
j||d|jtj	ƒƒ‚n|j
|ƒ}
|	tj||	|
|ƒfS(	s)Make a request for just part of the file.sRange: bytes=%sii”ii sServer return code %dN(ii (R,RKt_attempted_range_headerR&RGR8RMR9R	R:RRNtInvalidHttpRanget_parse_headersRthandle_response(R"R>RHRER?R@RLRAtrange_headerRCtmsg((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyRFås 

cC@s*|jdƒ|jƒtj|ƒ}|S(s:Transform the headers provided by curl into an HTTPMessagei(RMtreadlinethttplibtHTTPMessage(R"tstatus_and_headersRT((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyRQÿs

c
C@s,|jƒ}|j|dƒ\}}}|jtjdƒt|ƒ}|jtjt|ƒƒ|jtj|j	ƒy|j
||ddgƒWnMtjk
rá}|dtkrÛt
jd|d|d||ƒqâ‚nX|jdƒ|jtjƒ}|j|ƒ}	|tj|||	|ƒfS(Ns
.bzr/smartisExpect: s&Content-Type: application/octet-streamis.got pycurl error in POST: %s, %s, %s, url: %s (R,RJR0R	tPOSTRt
POSTFIELDSIZEtlentREADFUNCTIONtreadR8terrortCURLE_SEND_ERRORRtmutterRMR9R:RQRRR(
R"t
body_bytesR?R@RLRAt	fake_fileteRCRT((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyt_posts&
	
c	C@sÁ|jtjƒ}|jtjƒ}|dk	rK|jƒ}t|ƒ}nd}d}|dkrtjd||fƒ‚n>|dkr”d}n
d|}tj	|d|||fƒ‚dS(s_Common curl->bzrlib error translation.

        Some methods may choose to override this for particular cases.

        The URL and code are automatically included as appropriate.

        :param info: Extra information to include in the message.

        :param body: File-like object from which the body of the page can be
            read.
        ti“s@Server refuses to fulfill the request (403 Forbidden) for %s: %ss: s#Unable to handle http code %d%s: %sN(
R9R	R:t
EFFECTIVE_URLR&R]RRtTransportErrortInvalidHttpResponse(	R"R?tinfotbodyRCturlt
response_bodytplaintext_bodyRT((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyR=*s"	
cC@s×|tjtjfkrl|jt|ƒdƒ|tjkrÓdtjkrÓtjd|j	ƒfƒqÓng|tj
tjfkrZ|jt|ƒdƒ|tj
krÓdtjkrÓg}xy|j	ƒjƒD]e}y|j
ddƒ\}}Wntk
rd}nX|d
kr)d	|f}n|j|ƒqÑWtjd
dj|ƒƒqÓny|tjkr’dtjkr’tjd|j	ƒƒnA|tjtjtjfkrÓdtjkrÓtjd|ƒndS(NR]thttps< %sR6t:it
AuthorizationsProxy-Authorizations%s: <masked>s> s
> s* %s(RpsProxy-Authorization(R	tINFOTYPE_HEADER_INtINFOTYPE_DATA_INt_report_activityR[Rtdebug_flagsRR`trstriptINFOTYPE_HEADER_OUTtINFOTYPE_DATA_OUTt
splitlinestsplitt
ValueErrorR&tappendtjoint
INFOTYPE_TEXTtINFOTYPE_SSL_DATA_INtINFOTYPE_SSL_DATA_OUT(R"tkindttexttlinestlineRAtdetails((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyt	_debug_cbKs2 

 cC@sdtjtjf}|jtj|ƒ|jtjdƒ|jtj|jƒ|j	rt|jtj
|j	ƒn|jtjtjƒ|jtj
tjƒ|jƒ}|jddƒ}|jddƒ}d}|dk	r|d}|dk	r||7}n|jtj|ƒndS(sSet options for all requestssbzr/%s (pycurl: %s)itusertpasswordRoN(tbzrlibt__version__R	tversionR0t	USERAGENTtVERBOSEt
DEBUGFUNCTIONR…R!tCAINFOtHTTPAUTHtHTTPAUTH_ANYt	PROXYAUTHt_get_credentialsRR&tUSERPWD(R"R?tua_strR+R†R‡tuserpass((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyR2hs"	

c

C@s¢y4dddg}|jtj||ƒ|jƒWnøtjk
r.}|jtjƒ}tjd|d|d||ƒ|dt	t
ttt
tfkr¾tjd|d|fƒ‚nj|dtkrîtjd|d|fƒ‚n:|dtkr(tj|dd	d
d	dd	dd
ƒ‚n‚nX|jtjƒ}|dkrž|jtjƒ}|j|ƒ}|jdƒ}	tj||	d|dkƒ‚ndS(s0Perform curl operation and translate exceptions.sCache-control: max-age=0sPragma: no-cachesConnection: Keep-Alives&got pycurl error: %s, %s, %s, url: %s iis curl connection error (%s)
on %stoffsettunknowntlengthtactualtextrasServer aborted the requesti-i.i/i3tlocationtis_permanentN(i-i.i/i3(R0R	t
HTTPHEADERtperformR^R9RfRR`tCURLE_COULDNT_RESOLVE_HOSTtCURLE_COULDNT_RESOLVE_PROXYtCURLE_COULDNT_CONNECTtCURLE_GOT_NOTHINGtCURLE_SSL_CACERTtCURLE_SSL_CACERT_BADFILERtConnectionErrortCURLE_RECV_ERRORtConnectionResettCURLE_PARTIAL_FILEtShortReadvErrorR:RQt	getheadertRedirectRequested(
R"R?RAtmore_headerstheadersRcRkRCRTt
redirected_to((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyR8}sF		
	Nii@(t__name__t
__module__t__doc__R&RR,R.RDRIRKRJRGt
_get_max_sizeRFRQRdR=R…R2R8(((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyRcs"									#!		c@s“ddlm}ddlm}t|jfg}|jjƒrddlm}m‰dtf‡‡fd†ƒY‰|j	ˆ|j
fƒn|S(s.Return the permutations to be used in testing.i(tfeatures(thttp_server(thttps_servert	ssl_certstHTTPS_pycurl_transportc@seZd‡‡fd†ZRS(c@s5tˆ|ƒj||ƒtˆjdƒƒ|_dS(Nsca.crt(RRtstrt
build_pathR!(R"R#R(R·R¶(sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyR¹sN(R¯R°R&R((R·R¶(sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyR··s(tbzrlib.testsR³R´RtHttpServer_PyCurltHTTPSServerFeaturet	availableRµR¶R{tHTTPSServer_PyCurl(R³R´tpermutationsRµ((R·R¶sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pytget_test_permutations¬s	("R±t
__future__Rt	cStringIORRVRˆRRRtbzrlib.transport.httpRRRRR	tImportErrorRcR`RR'R^RR¡RŸR R¢R¨R_R¦R£R¤RRÀ(((sA/usr/lib/python2.7/dist-packages/bzrlib/transport/http/_pycurl.pyt<module>s:"
	ÿJ

Copyright © 2017 || Recoded By Mr.Bumblebee