Viewing File: /usr/lib/python2.7/site-packages/httplib2/__init__.pyc


7Yc@spddlmZdZdZdddddd	d
gZdZdZdd
lZdd
lZdd
l	Z	dd
l
Z	dd
lZ	dd
lZ	dd
l
Z
dd
lZdd
lZdd
lZdd
lZdd
lZdd
lZdd
lZdd
lZdd
lZdd
lZdd
lZdd
lZyddlmZmZWn;ek
r~dd
l Z dd
lZe j!Zej!ZnXdd
l"Z"ddl#m#Z$dd
l%Z%yddl&m'Z'WnAek
rydd
l'Z'Wnee(fk
re)Z'nXnXy"dd
l*Z*e*j+Z,dZ-Wn&e(efk
rIe)Z,dZ-nXej.ddfkrrddl/m/Z/n	dZ/dZ0ddddddddd d!d"gZ1d#Z2dZ3ej.dd$fkrd%Z4nd&Z5e6ej7d're5ej7_8nde9fd(YZ:d)e:fd*YZ;de;fd+YZ<de;fd,YZ=de;fd-YZ>de;fd.YZ?d e;fd/YZ@d0e:fd1YZAd2e:fd3YZBd4e:fd5YZCd"e:fd6YZDd7e:fd8YZEd9e:fd:YZFd;e:fd<YZGd=eFfd>YZHd?ZIydd
lJZJeJjKZLWnek
rd@ZLnXdAdBdCdDdEdFdGdHgZMdIZNejOdJZPdKZQdLZRejOdMZSejOdNZTdOZUejOdPZVdQZWdRZXd#ZYejOdSZZejOdTZ[ejOdUZ\dVdWZ]dXZ^dYZ_dZZ`d[Zad\Zbd]ecfd^YZdd_edfd`YZedaedfdbYZfdcedfddYZgdeedfdfYZhdgedfdhYZiieedi6ehdj6efdk6egdl6eidm6ZjdldmdkdjdigZkdnecfdoYZldpecfdqYZmdremfdsYZndtecfduYZodecfdvYZpdwdxZqdwdyZrdzejsfd{YZtd|ejufd}YZvietdw6evd~6ZwyyUddlxmyZyeyjzj{de)krJenddl|m}Z}ddl|m~Z~Wnhee(fk
rddlmyZyeyjzj{de)krenddlm}Z}ddlm~Z~nXdZdejsfdYZdejufdYZiedw6ed~6ZwWnee(fk
r?nXdecfdYZdefdYZd
S(i(t
generatorss!Joe Gregorio (joe@bitworking.org)sCopyright 2006, Joe Gregorios!Thomas Broyer (t.broyer@ltgt.net)sJames AntillsXavier Verges FarrerosJonathan FeinbergsBlair ZajacsSam RubysLouis NyffeneggertMITs0.9.2N(tsha1tmd5(tgettext(tsocksc
Cs@|rtj}n	tj}tj|d|d|d|d|S(Ntkeyfiletcertfilet	cert_reqstca_certs(tsslt	CERT_NONEt
CERT_REQUIREDtwrap_socket(tsocktkey_filet	cert_filetdisable_validationR	R((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_ssl_wrap_socketFs
	cCs:|stdntj|||}tj||S(NsSSL certificate validation is not supported without the ssl module installed. To avoid this error, install the ssl module, or explicity disable validation.(t CertificateValidationUnsupportedtsocketR
thttplibt
FakeSocket(RRRRR	tssl_sock((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRSs
ii(tiri2uricCs|S(N((turi((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRascCs2ttdr(|dk	o'|tjk	S|dk	S(Nt_GLOBAL_DEFAULT_TIMEOUT(thasattrRtNoneR(ttimeout((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pythas_timeoutdstHttptResponset	ProxyInfot
HttpLib2ErrortRedirectMissingLocationt
RedirectLimittFailedToDecompressContentt"UnimplementedDigestAuthOptionErrort&UnimplementedHmacDigestAuthOptionErrort
debugleveltProxiesUnavailableErroriicCs|j|S(N(tsort(tseq((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytsortedys
cCs+|jdkrtjn|jjS(s&Return list of (header, value) tuples.N(tmsgRRtResponseNotReadytitems(tself((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytHTTPResponse__getheaders~st
getheaderscBseZRS((t__name__t
__module__(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR"stHttpLib2ErrorWithResponsecBseZdZRS(cCs&||_||_tj||dS(N(tresponsetcontentR"t__init__(R0tdescR6R7((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s		(R3R4R8(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR5scBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR#scBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR$scBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR%scBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR&scBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR'stMalformedHeadercBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR:stRelativeURIErrorcBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR;stServerNotFoundErrorcBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR<scBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR)sRcBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRstSSLHandshakeErrorcBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR=stNotSupportedOnThisPlatformcBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR>stCertificateHostnameMismatchcBseZdZRS(cCs&tj||||_||_dS(N(R"R8thosttcert(R0R9R@RA((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s	(R3R4R8(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR?sis /etc/pki/tls/certs/ca-bundle.crtt
connections
keep-alivesproxy-authenticatesproxy-authorizationttettrailersstransfer-encodingtupgradecCsptt}|jg|jddjdD]}|j^q.g|jD]}||krT|^qTS(NRBtt,(tlistt
HOP_BY_HOPtextendtgettsplittstriptkeys(R6thopbyhoptxtheader((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_get_end2end_headerss;s9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?cCs<tj|j}|d|d|d|d|dfS(sParses a URI using the regex given in Appendix B of RFC 3986.

        (scheme, authority, path, query, fragment) = parse_uri(uri)
    iiiii(tURItmatchtgroups(RRU((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt	parse_uriscCst|\}}}}}|s)|r<td|n|j}|j}|scd}n|r~dj||gp|}|j}|d||}||||fS(Ns(Only absolute URIs are allowed. uri = %st/t?s://(RVR;tlowertjoin(Rtschemet	authoritytpathtquerytfragmenttrequest_urit
defrag_uri((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyturlnorms	!s^\w+://s[?/:|]+cCsyUtj|rTt|trB|jd}|jd}qT|jd}nWntk
rhnXt|tr|jd}nt|j	}tj
d|}tj
d|}t|dkr|d }ndj
||fS(sReturn a filename suitable for the cache.

    Strips dangerous and common characters to create a filename we
    can use to store the cache in.
    sutf-8tidnaRFRGi(t
re_url_schemeRTt
isinstancetstrtdecodetencodetUnicodeErrortunicodet_md5t	hexdigesttsubtre_slashtlenRZ(tfilenametfilemd5((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytsafenames 

s(?:\r\n)?[ \t]+cCsGtg|jD]0\}}|jtj|djf^qS(Nt (tdictt	iteritemsRYtNORMALIZE_SPACERmRM(theaderstkeytvalue((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_normalize_headers	scCsi}|jdr|djd}g|D]R}d|jdkr/tg|jddD]}|jj^q`^q/}g|D]3}d|jdkr|jjdf^q}t||}n|S(Ns
cache-controlRGit=i(thas_keyRLtfindttupleRMRYRt(RwtretvaltpartstpartRPtparts_with_argstnamet
parts_wo_args((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_parse_cache_controls_@s^(?:\s*(?:,\s*)?([^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+)\s*=\s*\"?((?<=\")(?:[^\0-\x08\x0A-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?(?=\")|(?<!\")[^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={} \t]+(?!\"))\"?)(.*)$sk^(?:\s*(?:,\s*)?([^ \t\r\n=]+)\s*=\s*\"?((?<=\")(?:[^\\\"]|\\.)*?(?=\")|(?<!\")[^ \t\r\n,]+(?!\"))\"?)(.*)$s\\(.)swww-authenticatecCsBi}|j|r>y||j}tr4tp7t}x|r|dkr_d|}}n|jdd\}}|j|}i}xk|r|rt|jdkr|j\}	}
}t	j
d|
||	j<n|j|}qW|||j<|j}q=WWq>tk
r:t
dq>Xn|S(sCReturns a dictionary of dictionaries, one dict
    per auth_scheme.sauthentication-infotdigestRsiis\1sWWW-Authenticate(R|RMtUSE_WWW_AUTH_STRICT_PARSINGtWWW_AUTH_STRICTtWWW_AUTH_RELAXEDRLtsearchRoRUt
UNQUOTE_PAIRSRmRYt
ValueErrorR:(Rwt
headernameRtauthenticatetwww_authtauth_schemetthe_restRTtauth_paramsRxRy((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_parse_www_authenticate#s*		
cCsHd}t|}t|}|jdrn|djjddkrnd}d|krDd|d<qDn|jdrd}n|jdrd}n|jdrd}n|jd	rDtjtjj|d	}t	j	}t
d
||}|jdrCyt|d}Wqtk
r?d
}qXn_|jdrtjj|d}	d|	kr}d
}qt
d
tj|	|}nd
}|jdryt|d}Wqtk
rd
}qXn|jd
r,yt|d
}
Wntk
rd
}
nX||
7}n||krDd}qDn|S(sDetermine freshness from the Date, Expires and Cache-Control headers.

    We don't handle the following:

    1. Cache-Control: max-stale
    2. Age: headers are not used in the calculations.

    Not that this algorithm is simpler than you might think
    because we are operating as a private (non-shared) cache.
    This lets us ignore 's-maxage'. We can also ignore
    'proxy-invalidate' since we aren't a proxy.
    We will never return a stale document as
    fresh as a design decision, and thus the non-implementation
    of 'max-stale'. This also lets us safely ignore 'must-revalidate'
    since we operate as if every server has sent 'must-revalidate'.
    Since we are private we get to ignore both 'public' and
    'private' parameters. We also ignore 'no-transform' since
    we don't do any transformations.
    The 'no-store' parameter is handled at a higher level.
    So the only Cache-Control parameters we look at are:

    no-cache
    only-if-cached
    max-age
    min-fresh
    tSTALEtpragmasno-cacheitTRANSPARENTs
cache-controlsonly-if-cachedtFRESHtdateismax-agetexpiress	min-freshN(RR|RYR}tcalendarttimegmtemailtUtilstparsedate_tzttimetmaxtintRR(tresponse_headerstrequest_headersRtcctcc_responseRtnowtcurrent_agetfreshness_lifetimeRt	min_fresh((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_entry_dispositionCsT.			

	




cCs|}y|jdd}|d	kr|dkrWtjdtj|j}n|dkrutj|}ntt	||d<|d|d<|d=nWn<t
k
rd}ttd|jd||nX|S(
Nscontent-encodingtgziptdeflatetfileobjscontent-lengths-content-encodingRFsDContent purported to be compressed with %s but failed to decompress.(sgzipR(
RKRRtGzipFiletStringIOtreadtzlibt
decompressRfRotIOErrorR%t_(R6tnew_contentR7tencoding((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_decompressContents$
)cCs|rt|}t|}|jds<|jdrL|j|qtjj}x3|jD]%\}}	|dkrh|	||<qhqhW|jdd}
|
r|
jj	ddj
d}xA|D]6}d	|}y||||<Wqtk
rqXqWn|j}
|
d
kr,d}
nd|
}|j
}tjd
d|}dj|||g}|j||ndS(Nsno-storetstatusscontent-encodingstransfer-encodingtvaryRsRFRGs
-varied-%si0isstatus: %d
s
(?!
)|(?<!
)
s
(sstatusscontent-encodingstransfer-encoding(RR|tdeleteRtMessageRuRKRRYtreplaceRLtKeyErrorRt	as_stringtreRmRZtset(RRR7tcachetcachekeyRRtinfoRxRyRtvary_headersRQRt
status_headert
header_strttext((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_updateCaches4!


		
c	CsStdtjgtdD]}dtjdd^qfj}|d S(Ns%s:%sit
0123456789ii	i(RkRtctimetrangetrandomt	randrangeRl(titdig((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_cnoncesKcCs,tjtd|||fjjS(Ns%s%s%s(tbase64t	b64encodet_shaRRM(tcnoncetiso_nowtpassword((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_wsse_username_tokenstAuthenticationcBs5eZdZdZdZdZdZRS(c
CsCt|\}}	}
}}|
|_||_||_||_dS(N(RVR]R@tcredentialsthttp(
R0RR@R`RwR6R7RR[R\R]R^R_((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s
			cCs5t|\}}}}}|t|jjdS(NRW(RVRoR]tcount(R0R`R[R\R]R^R_((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytdepthscCs:t|\}}}}}||jko9|j|jS(N(RVR@t
startswithR](R0R@R`R[R\R]R^R_((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytinscopescCsdS(snModify the request headers to add the appropriate
        Authorization header. Over-ride this in sub-classes.N((R0tmethodR`RwR7((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytrequestscCstS(sGives us a chance to update with new nonces
        or such returned from the last authorized response.
        Over-rise this in sub-classes if necessary.

        Return TRUE is the request is to be retried, for
        example Digest may return stale=true.
        (tFalse(R0R6R7((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR6s(R3R4R8RRRR6(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs
				tBasicAuthenticationcBseZdZdZRS(c	Cs&tj||||||||dS(N(RR8(R0RR@R`RwR6R7R((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8scCs(dtjd|jj|d<dS(sOModify the request headers to add the appropriate
        Authorization header.sBasic s%s:%st
authorizationN(RRRRM(R0RR`RwR7((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs(R3R4R8R(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs	tDigestAuthenticationcBs,eZdZdZddZdZRS(sMOnly do qop='auth' and MD5, since that
    is all Apache currently implementsc	CsYtj||||||||t|d}|d|_|jjdd}	dg|	jD]}
|
j^qckrdpd|jd<|jddkrtt	d|	n|jjddj
|jd<|jddkrtt	d|jdnd	j|jd
d|jdd|jd
g|_
d
|jd<dS(Nswww-authenticateRtqoptauthsUnsupported value for qop: %s.t	algorithmtMD5s$Unsupported value for algorithm: %s.RFit:trealmitnc(RR8Rt	challengeRKRLRMRR&RtupperRZRtA1(R0RR@R`RwR6R7RRRRP((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s"
>" 6c	s<dfd}dj|d|g}|p<t|jd<d||jd|jdd	|jd
|jd|jd|f}d|jd
|jd|jd||jd||jd|jd
|jdf	|d<|jjdr%|dcd|jd7<n|jd
cd7<dS(sModify the request headerscSst|jS(N(RkRl(RP((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt<lambda>scsd||fS(Ns%s:%s((tstd(tH(s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRsRFRRs"%s"s%s:%s:%s:%s:%stnonces%08xRRsoDigest username="%s", realm="%s", nonce="%s", uri="%s", algorithm=%s, response=%s, qop=%s, nc=%08x, cnonce="%s"iRRRtopaques
, opaque="%s"iN(RZRRRRRK(	R0RR`RwR7RtKDtA2trequest_digest((Rs5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs,	







cCs|jdsdt|djdi}d|jdkr|d|jd<d|jd<tSnKt|djdi}|jd	r|d	|jd<d|jd<ntS(
Nsauthentication-infoswww-authenticateRttruetstaleRiRt	nextnonce(R|RRKRtTrueR(R0R6R7Rtupdated_challenge((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR6*s
N(R3R4t__doc__R8RRR6(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs	tHmacDigestAuthenticationcBs/eZdZdZdZdZdZRS(s@Adapted from Robert Sayre's code and DigestAuthentication above.s!Thomas Broyer (t.broyer@ltgt.net)c		Cs:tj||||||||t|d}|d|_|jjdd|jd<|jddkr}d|jd<n|jjdd|jd<|jjdsttd	n|jjd
d|jd
<|jd
dkrttd
|jd
n|jjdd|jd<|jddkr^ttd|jdn|jd
dkr}t|_n	t	|_|jddkrt|_
n	t	|_
dj|jdd|j
j
dj|jd|jdgjjd|jdg|_|j
j
|jjj|_dS(Nswww-authenticatet
hmacdigesttreasontunauthorizedt	integritytsaltRFtsnoncesCThe challenge doesn't contain a server nonce, or this one is empty.Rs
HMAC-SHA-1sHMAC-MD5s$Unsupported value for algorithm: %s.spw-algorithmsSHA-1Rs'Unsupported value for pw-algorithm: %s.iRiR(RR(s
HMAC-SHA-1sHMAC-MD5(sSHA-1sMD5(RR8RRRKR'RRkthashmodRt	pwhashmodRZRtnewRlRYRx(	R0RR@R`RwR6R7RR((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8>s2"
  		8c	Cst|}djg|D]}d|^q}djg|D]}||^q?}tjdtj}	t}
d|||
|jd|f}tj|j	||j
jj}d|j
d|jd|jd|
||	||f|d	<d
S(sModify the request headersRFs%s s%Y-%m-%dT%H:%M:%SZs%s:%s:%s:%s:%sRssHMACDigest username="%s", realm="%s", snonce="%s", cnonce="%s", uri="%s", created="%s", response="%s", headers="%s"iRRN(RRRZRtstrftimetgmtimeRRthmacRRxRRlRYR(R0RR`RwR7RNtktkeylisttheaders_valtcreatedRR((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR\s &&	 '


cCs8t|djdi}|jddkr4tStS(Nswww-authenticateRRRR(s	integritysstale(RRKRR(R0R6R7R((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR6os(R3R4Rt
__author__R8RR6(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR:s
		tWsseAuthenticationcBs eZdZdZdZRS(sThis is thinly tested and should not be relied upon.
    At this time there isn't any third party server to test against.
    Blogger and TypePad implemented this algorithm at one point
    but Blogger has since switched to Basic over HTTPS and
    TypePad has implemented it wrong, by never issuing a 401
    challenge but instead requiring your client to telepathically know that
    their endpoint is expecting WSSE profile="UsernameToken".c	Cs&tj||||||||dS(N(RR8(R0RR@R`RwR6R7R((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8~scCsid|d<tjdtj}t}t|||jd}d|jd|||f|d<dS(	sOModify the request headers to add the appropriate
        Authorization header.sWSSE profile="UsernameToken"Rs%Y-%m-%dT%H:%M:%SZisJUsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"isX-WSSEN(RRR	RRR(R0RR`RwR7RRtpassword_digest((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs
	
(R3R4RR8R(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRvs	tGoogleLoginAuthenticationcBseZdZdZRS(cCsWddlm}tj||||||||t|d}	|	djdd}
|
dkr|jddkrd	}
ntd
|dd|dd|
d
|d}|jj	dddd||didd6\}}|j
d}
tg|
D]$}|rt|j
dd^q}|jdkrFd|_
n
|d|_
dS(Ni(t	urlencodeswww-authenticatetgooglelogintservicetxapiRitcltEmailtPasswditsources
user-agents+https://www.google.com/accounts/ClientLoginRtPOSTtbodyRws!application/x-www-form-urlencodedsContent-Types
R{iRFtAuth(turllibRRR8RRKR}RtRRRLR~RR(R0RR@R`RwR6R7RRRRRtresptlinestlineR((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s"!	-77cCsd|j|d<dS(sOModify the request headers to add the appropriate
        Authorization header.sGoogleLogin Auth=RN(R(R0RR`RwR7((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs(R3R4R8R(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs	tbasictwsseRRRt	FileCachecBs5eZdZedZdZdZdZRS(sUses a local directory as a store for cached files.
    Not really safe to use if multiple threads or processes are going to
    be running on the same cache.
    cCs;||_||_tjj|s7tj|jndS(N(RtsafetosR]texiststmakedirs(R0RR%((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s		cCshd}tjj|j|j|}y)t|d}|j}|jWnt	k
rcnX|S(Ntrb(
RR&R]RZRR%tfileRtcloseR(R0RxRt
cacheFullPathtf((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRKs!
cCsKtjj|j|j|}t|d}|j||jdS(Ntwb(R&R]RZRR%R*twriteR+(R0RxRyR,R-((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs!
cCsGtjj|j|j|}tjj|rCtj|ndS(N(R&R]RZRR%R'tremove(R0RxR,((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs!(R3R4RRrR8RKRR(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR$s
		tCredentialscBs/eZdZddZdZdZRS(cCs
g|_dS(N(R(R0((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8sRFcCs#|jj|j||fdS(N(RtappendRY(R0RRtdomain((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytaddscCs
g|_dS(N(R(R0((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytclearsccsGx@|jD]5\}}}|dks1||kr
||fVq
q
WdS(NRF(R(R0R3tcdomainRR((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytiters(R3R4R8R4R5R7(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR1s		tKeyCertscBseZdZRS(sNIdentical to Credentials except that
    name/password are mapped to key/cert.(R3R4R(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8stAllHostscBseZRS((R3R4(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR9scBsJeZdZdZedddZdZdZdZ	dZ
RS(s,Collect information required to use a proxy.cCs:||_||_||_||_||_||_dS(s_
        Args:
          proxy_type: The type of proxy server.  This must be set to one of
          socks.PROXY_TYPE_XXX constants.  For example:

            p = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP,
              proxy_host='localhost', proxy_port=8000)

          proxy_host: The hostname or IP address of the proxy server.

          proxy_port: The port that the proxy server is running on.

          proxy_rdns: If True (default), DNS queries will not be performed
          locally, and instead, handed to the proxy to resolve.  This is useful
          if the network does not allow resolution of non-local names.  In
          httplib2 0.9 and earlier, this defaulted to False.

          proxy_user: The username used to authenticate with the proxy server.

          proxy_pass: The password used to authenticate with the proxy server.
        N(t
proxy_typet
proxy_hostt
proxy_portt
proxy_rdnst
proxy_usert
proxy_pass(R0R:R;R<R=R>R?((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s					cCs(|j|j|j|j|j|jfS(N(R:R;R<R=R>R?(R0((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytastuplescCs|jdko|jdkS(N(R;RR<(R0((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytisgoodscCs|j|S(N(tbypass_host(R0thostname((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt
applies_toscCsI|jtkrtSt}x)|jD]}|j|r#t}q#q#W|S(s1Has this host been excluded from the proxy config(tbypass_hostsR9RRtendswith(R0RCtbypassR3((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRBs
(N(R3R4RRERRR8R@RARDRB(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR!s			RcCs|d
krdS|d}tjj|tjj|j}|sKdSt||}tjjdtjjdd}g}|r|jd}n|d	krt}n||_|S(s9
    Read proxy info from the environment variables.
    RthttpsNt_proxytno_proxytNO_PROXYRFRGt*(shttpshttps(R&tenvironRKRtproxy_info_from_urlRLR9RE(Rtenv_varturltpiRJRE((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytproxy_info_from_environment&s
'$		c	
Cs.tj|}d}d}d}d|dkr}|djdd\}}d|krt|jdd\}}q|}n
|d}d|kr|jdd\}}n|}|rt|}ntdddd|}|dkrd}nd	}td
|d|d|d
|pdd|p*dS(sG
    Construct a ProxyInfo from a URL (such as http_proxy env var)
    t@iRRHiRiPiiR:R;R<R>R?N(turlparseRRLRRtR!(	RPRtusernameRtporttidentt	host_portR@R:((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRN>s2	
	tHTTPConnectionWithTimeoutcBs,eZdZdddddZdZRS(s8
    HTTPConnection subclass that supports timeouts

    All timeouts are in seconds. If None is passed for timeout then
    Python's default timeout for sockets will be used. See for example
    the docs of socket.setdefaulttimeout():
    http://docs.python.org/library/socket.html#socket.setdefaulttimeout
    cCs/tjj||||||_||_dS(N(RtHTTPConnectionR8Rt
proxy_info(R0R@RVtstrictRR[((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8ps	c
Cs|jr$td
kr$tdnd}|jrx|jjrxt}|jj\}}}}}}|}	|}
nt}|j}	|j	}
xt
j|	|
dt
jD]}|\}}
}}}y|r
tj
||
||_|jj||||||n4t
j
||
||_|jjt
jt
jdt|jrc|jj|jn|jdkrd|j|j	fGH|rdt|||||fGHqn|jj|j|j	f|dWnt
jk
ra}|jdkr9d|j|j	fGH|r9d	t|||||fGHq9n|jrR|jjnd
|_qnXPqW|jst
j|nd
S(s3Connect to the host and port specified in __init__.s2Proxy support missing but proxy use was requested!s!getaddrinfo returns an empty listiisconnect: (%s, %s) ************sproxy: %s ************isconnect fail: (%s, %s)s	proxy: %sN(R[RRR)RARR@RR@RVRtgetaddrinfotSOCK_STREAMt
socksocketRtsetproxyt
setsockopttIPPROTO_TCPtTCP_NODELAYRRt
settimeoutR(RftconnectterrorR+(R0R-t	use_proxyR:R;R<R=R>R?R@RVtrestaftsocktypetprotot	canonnametsa((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyReusN!			""$($			N(R3R4RRR8Re(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRYfstHTTPSConnectionWithTimeoutc	BsJeZdZdddddddedZdZdZdZRS(s2
    This class allows communication via SSL.

    All timeouts are in seconds. If None is passed for timeout then
    Python's default timeout for sockets will be used. See for example
    the docs of socket.setdefaulttimeout():
    http://docs.python.org/library/socket.html#socket.setdefaulttimeout
    c

Cshtjj||d|d|d|d|||_||_|dkrRt}n||_|	|_dS(NRVRRR\(	RtHTTPSConnectionR8RR[RtCA_CERTSR	t"disable_ssl_certificate_validation(
R0R@RVRRR\RR[R	Rq((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s
				cCsd|krPg|dD]&}|djdkr|d^q}|rP|Sng|dD].}|ddjdkr[|dd^q[S(sReturns a list of valid host globs for an SSL certificate.

        Args:
          cert: A dictionary representing an SSL certificate.
        Returns:
          list: A list of valid host globs.
        tsubjectAltNameitdnsitsubjectt
commonname(RY(R0RARPthosts((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_GetValidHostsForCerts&cCse|j|}xO|D]G}|jddjdd}tjd|f|tjrtSqWtS(sValidates that a given hostname is valid for an SSL certificate.

        Args:
          cert: A dictionary representing an SSL certificate.
          hostname: The hostname to test.
        Returns:
          bool: Whether or not the hostname is valid for this certificate.
        t.s\.RLs[^.]*s^%s$(RwRRRtIRR(R0RARCRvR@thost_re((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_ValidateCertificateHostnames	
c	Cspd}|jrT|jjrTt}|jj\}}}}}}|}	|}
nt}|j}	|j}
tj|	|
dtj	}x|D]\}}
}}}y|rt
j||
|}|j||||||n.tj||
|}|j
tjtjdt|jr0|j|jn|j|j|jft||j|j|j|j|_|jdkrd|j|jfGH|rdt|||||fGHqn|js#|jj}|jjddd}|j||s#td||f||q#nWn(t tfk
r}|rO|j!n|jrh|jj!nd
|_t#|dr|j$t%j&krt'|qOntjtj(fk
rntj)k
rN}|jdkr&d	|j|jfGH|r&dt|||||fGHq&n|jr?|jj!nd
|_qnXPqW|jsltj)|nd
S(s(Connect to a host on a given (SSL) port.s!getaddrinfo returns an empty listiisconnect: (%s, %s)s	proxy: %sRs<Server presented certificate that does not match host %s: %sterrnosconnect fail: (%s, %s)N(*R[RARR@RR@RVRR]R^RR_R`RaRbRcRRRdReRRRRqR	RR(RftgetpeercertRLR{R?tssl_SSLErrorR+RRR|R
t
SSL_ERROR_SSLR=tgaierrorRf(R0R-RgR:R;R<R=R>R?R@RVtaddress_infotfamilyRjRkRltsockaddrRRARCte((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyResr!			$	 
		!$			N(	R3R4RRRR8RwR{Re(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRns		 		RH(tapiproxy_stub_mapturlfetch(tfetch(tInvalidURLErrorcs%ddittdfd}|S(NtGETcsU|dkr!tjpd}nt|d|d|d|d|d|d|dS(	NitpayloadRRwtallow_truncatedtfollow_redirectstdeadlinetvalidate_certificate(RRtgetdefaulttimeoutR(RPRRRwRRR(R(s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytfixed_fetchVs(RRR(RR((Rs5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_new_fixed_fetchUs	tAppEngineHttpConnectionc	Bs/eZdZdddddddedZRS(sUse httplib on App Engine, but compensate for its weirdness.

        The parameters key_file, cert_file, proxy_info, ca_certs, and
        disable_ssl_certificate_validation are all dropped on the ground.
        c

	Cs)tjj||d|d|d|dS(NRVR\R(RRZR8(
R0R@RVRRR\RR[R	Rq((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8gsN(R3R4RRRR8(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRas	tAppEngineHttpsConnectionc	Bs/eZdZdddddddedZRS(s4Same as AppEngineHttpConnection, but for HTTPS URIs.c


CsEtjj||d|d|d|d|d|t|	|_dS(NRVRRR\R(RRoR8Rt_fetch(
R0R@RVRRR\RR[R	Rq((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8osN(R3R4RRRR8(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRms	cBseZdZddededZdZdZdZ	ddZ
dZdZd	Z
d
ZdZdddedd
ZdZRS(sAn HTTP client that handles:

    - all methods
    - caching
    - ETags
    - compression,
    - HTTPS
    - Basic
    - Digest
    - WSSE

    and more.
    cCs||_||_||_i|_|rKt|trKt||_n	||_t|_	t
|_g|_t
|_ddg|_t|_t|_t|_||_t|_dS(sIf 'cache' is a string then it is used as a directory name for
        a disk cache. Otherwise it must be an object that supports the
        same interface as FileCache.

        All timeouts are in seconds. If None is passed for timeout
        then Python's default timeout for sockets will be used. See
        for example the docs of socket.setdefaulttimeout():
        http://docs.python.org/library/socket.html#socket.setdefaulttimeout

        `proxy_info` may be:
          - a callable that takes the http scheme ('http' or 'https') and
            returns a ProxyInfo instance per request. By default, uses
            proxy_nfo_from_environment.
          - a ProxyInfo instance (static proxy config).
          - None (proxy disabled).

        ca_certs is the path of a file containing root CA certificates for SSL
        server certificate validation.  By default, a CA cert file bundled with
        httplib2 is used.

        If disable_ssl_certificate_validation is true, SSL cert validation will
        not be performed.
        tPUTtPATCHN(R[R	RqtconnectionsRet
basestringR$RR1RR8tcertificatestauthorizationsRRtoptimistic_concurrency_methodsRtfollow_all_redirectstignore_etagtforce_exception_to_status_codeRtforward_authorization_headers(R0RRR[R	Rq((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8s"											cCsBtj|j}d|kr(|d=nd|kr>|d=n|S(NRR(tcopyt__dict__(R0t
state_dict((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt__getstate__s

cCs|jj|i|_dS(N(RtupdateR(R0tstate((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt__setstate__sc	
cstt|d}x^|jj|D]J}xAtD]9}|j|r/t||||||||Vq/q/Wq"WdS(scA generator that creates Authorization objects
           that can be applied to requests.
        swww-authenticateN(RRR7tAUTH_SCHEME_ORDERR|tAUTH_SCHEME_CLASSES(	R0R@R`RwR6R7t
challengestcredR[((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_auth_from_challenges

RFcCs|jj|||dS(s]Add a name and password that will be used
        any time a request requires authentication.N(RR4(R0RRR3((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytadd_credentialsscCs|jj|||dS(sXAdd a key and cert that will be used
        any time a request requires authentication.N(RR4(R0RxRAR3((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytadd_certificatescCs|jjg|_dS(sKRemove all the names and passwords
        that are used for authenticationN(RR5R(R0((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pytclear_credentialss
cCsd}t}x|tkr|d7}yEt|drS|jdkrS|jn|j||||Wnotjk
rnYtj	k
r|j
td|jn)t
k
r|j
ntjk
rF}d}	t|dr
t|dd}	n	|j}	|	tjtjfkr@|tkr@qnntjk
rt|dr|jdkr|tdkr|j
|jqq|j
n|tdkr|j
|jqqnXy|j}
Wntjk
rH|r8|dkr8d}t}|j
|jqq|j
ntjtjfk
r|tdkr|j
|jqq|j
nVXd}|dkr|j
n|
j}t|
}
|dkrt|
|}nPqW|
|fS(NiiRsUnable to find the server at %stargsRFtHEAD(RtRETRIESRRRReRRRRR+R<R@R~RftgetattrR|tENETUNREACHt
EADDRNOTAVAILRt
HTTPExceptiontgetresponset
BadStatusLineRRR R(R0tconnR`RRRwRtseen_bad_status_lineRterrR6R7((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt
_conn_requests~




	$












c
CsEg|jD]-}
|
j||r
|
j||
f^q
}|rWt|ddpZd}
|
r||
j||||n|j|||||\}}
|
r|
j||r|
j|||||j|||||\}}
d|_qn|j	dkrx|j
|||||
D]p}|j|||||j|||||\}}
|j	dkr&|jj||j||Pq&q&Wn|js|dks|j	dkr;|j
r|j	dkr|r|jdr|j	dkrttd||
n|jdru|d}t|\}}}}}|dkrutj|||d<qun|j	dkr|dkr|d|d
<|jds||d<nt|||
|j|	n|jdr|d=n|jdr|d=nd|kr(|jr(|d=n|jdr|d}tj|}|jdsl||d<n|}|j	dkrd}d}n|j|d|d|d|d|d\}}
||_qq8td||
q;|j	dkr;|dkr;|jds||d<nt|||
|j|	q;n||
fS( smDo the actual request using the connection object
        and also follow one level of redirects if necessaryiiiRRi/i,i-i.i3tlocations:Redirected but the response is missing a Location: header.s-x-permanent-redirect-urlscontent-locations
if-none-matchsif-modified-sinceRRRRwtredirectionss3Redirected more times than rediection_limit allows.iiN(sGETsHEAD(i,i-i.i/i3(sGETsHEAD(i.i/(ii(sGETsHEAD(RRRR,RRRR6t
_stale_digestRRR2RRR|R#RRVRTturljoinRRRRtdeepcopytpreviousR$(R0RR@tabsolute_uriR`RRRwRRRtauthsR6R7RRR[R\R]R^R_told_responsetredirect_method((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt_requestJsv= !!"!$






	
cCs
t|S(N(Rz(R0Rw((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRzsRc Csy|d7kri}n|j|}|jdsGdt|d<nt|}t|\}}}	}
|jddd!}t|dkr|ddkr|dkrd	}|d}n|j||}|d|}
|
|j	kr|j	|
}n|st
|}nt|jj
|}|d	kr|r||d
|ddd|ddd|jd
|d|jd|j}|j	|
<q||d|jd
|d|jd|j}|j	|
<n&||d|jd
|}|j	|
<|jtd|kr(d|kr(d|d<ntjj}d7}|jr|
jd}|jj|}|ryM|jdd\}}tjj}|j||j}d7|_Wqttfk
r|jj|d7}d7}qXqnd7}||jkrJ|jrJ|jdrJ|j rJd|krJ|d|d<n|d8krx|jrx|rx|jj|n|d9krd|kr|d}|j!j"ddjd}xG|D]<}d|}||}|j|d7|krd7}PqqWn|r|d:kr|jrd|kr|jdr|dkr\t#didn|j$|dd dd!|d"|d\}}t%||_&t'|j&_(n	t)||}|d#kr|sd$|d%<d}nt%|}|rt'|_(n||fS|d&krv|jdrG|j rGd'|krG|d|d'<n|jd(rd(|kr|d(|d)<qn|d*krn|j*||||	|||||	\}}|j+d+krP|dkrPx"t,|D]}||||<qWt%|}t-|d,r|j.|_.nt/||||j||}d-|_+t'|_(q|j+d-krh|}q|jj||}ngt0|}|jd.rd$|d%<t%|}d}n-|j*||||	|||||	\}}Wnt1k
r}|j2rt3|t4r@|j5}|j6}d/|_+t7||_8qt3|t9jrd0}t%id1d26d3d%6t|d46}d0|_8qt7|}t%id1d26d5d%6t|d46}d6|_8qnX||fS(;sd Performs a single HTTP request.

        The 'uri' is the URI of the HTTP resource and can begin with either
        'http' or 'https'. The value of 'uri' must be an absolute URI.

        The 'method' is the HTTP method to perform, such as GET, POST, DELETE,
        etc. There is no restriction on the methods allowed.

        The 'body' is the entity body to be sent with the request. It is a
        string object.

        Any extra headers that are to be sent with the request should be
        provided in the 'headers' dictionary.

        The maximum number of redirect to follow before raising an
        exception is 'redirections. The default is 5.

        The return value is a tuple of (response, content), the first
        being and instance of the 'Response' class, the second being
        a string that contains the response entity body.
        s
user-agentsPython-httplib2/%s (gzip)Riiit443RRHRRRR[R	RqRsaccept-encodings
gzip, deflatesutf-8s

tetagsif-matchRRRRsRFRGs
-varied-%ss-x-permanent-redirect-urls3Redirected more times than rediection_limit allows.RRwRRt504RRs
if-none-matchs
last-modifiedsif-modified-sinceRi0Risonly-if-cachedisRequest Timeouts
text/plainscontent-typet408scontent-lengtht400sBad RequestN(sGETsHEAD(sGETsHEAD(sGETsHEAD(:RRzR|t__version__RRbRLRot_get_proxy_infoRtSCHEME_TO_CONNECTIONRHRR7RR	Rqtset_debuglevelR(RRRRhRKt
FeedParsertfeedR+t_parset
IndexErrorRRRRRYRR$RR RRt	fromcacheRRRRRRRRRt	ExceptionRReR5R6R7RfRR( R0RRRRwRtconnection_typeR[R\R`Ratdomain_portR[tconn_keyRtcertsRtcached_valueRR7t
feedparserRRRQRxRyR6Rtentry_dispositiontmerged_responseRR((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs	.

		

	

=
!


'

	
%-			
	1				cCsetj|\}}|j}t|r9||}nt|dra|j|rad}n|S(sYReturn a ProxyInfo instance (or None) based on the scheme
        and authority.
        RDN(Rt	splitportR[tcallableRRDR(R0R[R\RCRVR[((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRss		N(R3R4RRRRRR8RRRRRRRRRztDEFAULT_MAX_REDIRECTSRR(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyRs
C	
		
			M	J	cBs>eZdZeZdZdZdZdZ	dZ
dZRS(s<An object more like email.Message than httplib.HTTPResponse.iitOkcCs8t|tjryx*|jD]\}}|||j<qW|j|_t|j|d<|j|_|j|_nt|t	j
j
rx*|jD]\}}|||j<qWt|d|_ncx*|j
D]\}}|||j<qWt|jd|j|_|jd|j|_dS(NRR(ReRtHTTPResponseR2RYRRfRtversionRRR/RRuRK(R0RRxRy((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR8scCs|dkr|St|dS(NRt(tAttributeError(R0R((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt__getattr__sN(R3R4RRRRRRRRR8R(((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyR s	(t
__future__RRt
__copyright__t__contributors__t__license__RRtsysRtemail.Utilst
email.Messagetemail.FeedParserRRRRRTRRR&RRRRR|thashlibRRRRktImportErrortshaRR
RRRthttplib2RRRR
tSSLErrorR~Rtversion_infoRRt__all__R(RR,R1RRR2RR"R5R#R$R%R&R'R:R;R<R)RR=R>R?Rtca_certs_locaterRKRpRIRRtcompileRSRVRbRdRnRrRvRzRRRRRRRRRRRtobjectRRRRRRRRR$R1R8R9R!RRRNRZRYRoRnRtgoogle.appengine.apiRtapiproxytGetStubtgoogle.appengine.api.urlfetchRRtgoogle3.apphosting.apitgoogle3.apphosting.api.urlfetchRRRRRtR (((s5/usr/lib/python2.7/site-packages/httplib2/__init__.pyt<module>sD	
	

	

			

						
 	J		%		"
:<
!9(B
			

Back to Directory File Manager