Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/httplib2/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/httplib2/__init__.pyc


Z)Rc@sddlmZdZdZdddddd	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
lZyddlmZmZWn;ek
rrdd
lZdd
lZej Zej ZnXdd
l!Z!ddl"m"Z#dd
l$Z$yddl%m&Z&Wnek
re'Z&nXy"dd
l(Z(e(j)Z*dZ+Wn&e,efk
re'Z*dZ+nXej-ddfkr<ddl.m.Z.n	dZ.dZ/ddddddddd d!d"gZ0d#Z1ej-dd$fkrd%Z2nd&Z3e4ej5d're3ej5_6nde7fd(YZ8d)e8fd*YZ9de9fd+YZ:de9fd,YZ;de9fd-YZ<de9fd.YZ=d e9fd/YZ>d0e8fd1YZ?d2e8fd3YZ@d4e8fd5YZAd"e8fd6YZBd7e8fd8YZCd9e8fd:YZDd;e8fd<YZEd=eDfd>YZFd?ZGd@ZHdAdBdCdDdEdFdGdHgZIdIZJejKdJZLdKZMdLZNejKdMZOejKdNZPdOZQejKdPZRdQZSdRZTd#ZUejKdSZVejKdTZWejKdUZXdVdWZYdXZZdYZ[dZZ\d[Z]d\Z^d]e_fd^YZ`d_e`fd`YZadae`fdbYZbdce`fddYZcdee`fdfYZddge`fdhYZeieadi6eddj6ebdk6ecdl6eedm6ZfdldmdkdjdigZgdne_fdoYZhdpe_fdqYZidreifdsYZjde_fdtYZkduejlfdvYZmdwejnfdxYZoiemdy6eodz6Zpydd{lqmrZrerjsjtd|e'krendd}lumvZvdd~lumwZwddlumxZxddlumyZyddlumzZzde{fdYZ|de_fdYZ}de}fdYZ~ie}dy6e~dz6ZpWnek
rgnXde_fdYZde{fdYZd
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.7.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/dist-packages/httplib2/__init__.pyt_ssl_wrap_socketBs
	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/dist-packages/httplib2/__init__.pyROs
ii(tiri2uricCs|S(N((turi((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR]scCs2ttdr(|dk	o'|tjk	S|dk	S(Nt_GLOBAL_DEFAULT_TIMEOUT(thasattrRtNoneR(ttimeout((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pythas_timeout`stHttptResponset	ProxyInfot
HttpLib2ErrortRedirectMissingLocationt
RedirectLimittFailedToDecompressContentt"UnimplementedDigestAuthOptionErrort&UnimplementedHmacDigestAuthOptionErrort
debugleveltProxiesUnavailableErroriicCs|j|S(N(tsort(tseq((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytsortedqs
cCs+|jdkrtjn|jjS(s&Return list of (header, value) tuples.N(tmsgRRtResponseNotReadytitems(tself((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytHTTPResponse__getheadersvst
getheaderscBseZRS((t__name__t
__module__(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR"stHttpLib2ErrorWithResponsecBseZdZRS(cCs&||_||_tj||dS(N(tresponsetcontentR"t__init__(R0tdescR6R7((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8s		(R3R4R8(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR5scBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR#scBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR$scBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR%scBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR&scBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR'stMalformedHeadercBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR:stRelativeURIErrorcBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR;stServerNotFoundErrorcBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR<scBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR)sRcBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRstSSLHandshakeErrorcBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR=stNotSupportedOnThisPlatformcBseZRS((R3R4(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR>stCertificateHostnameMismatchcBseZdZRS(cCs&tj||||_||_dS(N(R"R8thosttcert(R0R9R@RA((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8s	(R3R4R8(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR?sis"/etc/ssl/certs/ca-certificates.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/dist-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/dist-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/dist-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/dist-packages/httplib2/__init__.pytsafenames 

s(?:\r\n)?[ \t]+cCsGtg|jD]0\}}|jtj|djf^qS(Nt (tdictt	iteritemsRYtNORMALIZE_SPACERmRM(theaderstkeytvalue((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyt_normalize_headersscCsi}|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/dist-packages/httplib2/__init__.pyt_parse_cache_controls_@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/dist-packages/httplib2/__init__.pyt_parse_www_authenticates*		
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/dist-packages/httplib2/__init__.pyt_entry_disposition0sT.			

	




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/dist-packages/httplib2/__init__.pyt_decompressContentzs$
)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/dist-packages/httplib2/__init__.pyt_updateCaches4!


		
c	CsStdtjgtdD]}dtjdd^qfj}|d S(Ns%s:%sit
0123456789ii	i(RkRtctimetrangetrandomt	randrangeRl(titdig((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyt_cnoncesKcCs,tjtd|||fjjS(Ns%s%s%s(tbase64t	b64encodet_shaRRM(tcnoncetiso_nowtpassword((s5/usr/lib/python2.7/dist-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/dist-packages/httplib2/__init__.pyR8s
			cCs5t|\}}}}}|t|jjdS(NRW(RVRoR]tcount(R0R`R[R\R]R^R_((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytdepthscCs:t|\}}}}}||jko9|j|jS(N(RVR@t
startswithR](R0R@R`R[R\R]R^R_((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytinscopescCsdS(snModify the request headers to add the appropriate
        Authorization header. Over-rise this in sub-classes.N((R0tmethodR`RwR7((s5/usr/lib/python2.7/dist-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/dist-packages/httplib2/__init__.pyR6s(R3R4R8RRRR6(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs
				tBasicAuthenticationcBseZdZdZRS(c	Cs&tj||||||||dS(N(RR8(R0RR@R`RwR6R7R((s5/usr/lib/python2.7/dist-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/dist-packages/httplib2/__init__.pyRs(R3R4R8R(((s5/usr/lib/python2.7/dist-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/dist-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/dist-packages/httplib2/__init__.pyt<lambda>scsd||fS(Ns%s:%s((tstd(tH(s5/usr/lib/python2.7/dist-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/dist-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/dist-packages/httplib2/__init__.pyR6s
N(R3R4t__doc__R8RRR6(((s5/usr/lib/python2.7/dist-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/dist-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/dist-packages/httplib2/__init__.pyRKs &&	 '


cCs8t|djdi}|jddkr4tStS(Nswww-authenticateRRRR(s	integritysstale(RRKRR(R0R6R7R((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR6_s(R3R4Rt
__author__R8RR6(((s5/usr/lib/python2.7/dist-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/dist-packages/httplib2/__init__.pyR8nscCsid|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/dist-packages/httplib2/__init__.pyRqs
	
(R3R4RR8R(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRfs	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/dist-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/dist-packages/httplib2/__init__.pyRs(R3R4R8R(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR~s	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/dist-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/dist-packages/httplib2/__init__.pyRKs!
cCsKtjj|j|j|}t|d}|j||jdS(Ntwb(R&R]RZRR%R*twriteR+(R0RxRyR,R-((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs!
cCsGtjj|j|j|}tjj|rCtj|ndS(N(R&R]RZRR%R'tremove(R0RxR,((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs!(R3R4RRrR8RKRR(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR$s
		tCredentialscBs/eZdZddZdZdZRS(cCs
g|_dS(N(R(R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8sRFcCs#|jj|j||fdS(N(RtappendRY(R0RRtdomain((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytaddscCs
g|_dS(N(R(R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytclearsccsGx@|jD]5\}}}|dks1||kr
||fVq
q
WdS(NRF(R(R0R3tcdomainRR((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytiters(R3R4R8R4R5R7(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR1s		tKeyCertscBseZdZRS(sNIdentical to Credentials except that
    name/password are mapped to key/cert.(R3R4R(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8scBs2eZdZddddZdZdZRS(s,Collect information required to use a proxy.cCs@||||||f\|_|_|_|_|_|_dS(sThe parameter proxy_type 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)
      N(t
proxy_typet
proxy_hostt
proxy_portt
proxy_rdnst
proxy_usert
proxy_pass(R0R9R:R;R<R=R>((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8scCs(|j|j|j|j|j|jfS(N(R9R:R;R<R=R>(R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytastuplescCs|jdko|jdkS(N(R:RR;(R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytisgoodsN(R3R4RRR8R?R@(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR!s	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@tporttstrictRRC((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8s	cCs|jr$tdkr$tdnd}xtj|j|jdtjD]a}|\}}}}}y|jr|jj	rtj
||||_|jj|jj
n4tj||||_|jjtjtjdt|jr|jj|jn|jdkr6d|j|jfGHn|jj|Wnbtjk
r}|jdkrdG|j|jfGHn|jr|jjnd|_qLnXPqLW|jstj|ndS(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)s
connect fail:N(RCRRR)RtgetaddrinfoR@RDtSOCK_STREAMR@t
socksocketRtsetproxyR?t
setsockopttIPPROTO_TCPtTCP_NODELAYRRt
settimeoutR(tconnectterrorR+(R0R-trestaftsocktypetprotot	canonnametsa((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRNs8			N(R3R4RRR8RN(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRAstHTTPSConnectionWithTimeoutc	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(NRDRRRE(	RtHTTPSConnectionR8RRCRtCA_CERTSR	t"disable_ssl_certificate_validation(
R0R@RDRRRERRCR	RY((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8)s
				cCsd|krAg|dD]&}|djdkr|d^qSg|dD].}|ddjdkrL|dd^qLSdS(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
commonnameN(RY(R0RARP((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyt_GetValidHostsForCertJs
$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\.t*s[^.]*s^%s$(R^RRRtIRR(R0RAthostnamethostsR@thost_re((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyt_ValidateCertificateHostnameYs	
cCsd}xtj|j|jdtjD]\}}}}}yf|jr|jjrtj|||}|j	|jj
n.tj|||}|jtjtj
dt|jr|j|jn|j|j|jft||j|j|j|j|_|jdkr=d|j|jfGHn|js|jj}|jjddd}	|j||	std|	|f|	|qnWnttfk
r&}
|r|jn|jr|jjnd	|_t |
dr |
j!t"j#kr t$|
qntjtj%fk
rEnbtj&k
r}|jdkr~dG|j|jfGHn|jr|jjnd	|_q(nXPq(W|jstj&|nd	S(
s(Connect to a host on a given (SSL) port.s!getaddrinfo returns an empty listiisconnect: (%s, %s)Rs<Server presented certificate that does not match host %s: %sterrnos
connect fail:N('RRFR@RDRGRCR@RRHRIR?RJRKRLRRRMRNRRRRYR	RR(tgetpeercertRLReR?tssl_SSLErrorR+RRRfR
t
SSL_ERROR_SSLR=tgaierrorRO(R0R-tfamilyRRRSRTtsockaddrRRARbte((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRNisZ	.	 
		!			N(	R3R4RRRR8R^ReRN(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRV s				Rthttps(tapiproxy_stub_mapturlfetch(tfetch(tInvalidURLError(t
DownloadError(tResponseTooLargeError(tSSLCertificateErrortResponseDictcBseZdZdZRS(snIs a dictionary that also has a read() method, so
    that it can pass itself off as an httlib.HTTPResponse().cCsdS(N((R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs(R3R4RR(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRvstAppEngineHttpConnectionc	Bs\eZdZdddddddedZdZdZdZdZ	dZ
RS(sEmulates an httplib.HTTPConnection object, but actually uses the Google
    App Engine urlfetch library. This allows the timeout to be properly used on
    Google App Engine, and avoids using httplib, which on Google App Engine is
    just another wrapper around urlfetch.
    c

Csh||_||_||_|s3|s3|s3|r?tnd|_d|_|	|_t|_	dS(NR(
R@RDRR>RR6R[tvalidate_certificateRR(
R0R@RDRRRERRCR	tdisable_certificate_validation((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8s					
cs |j}|jr+d|j|jf}nd|j||f}yt|d|d|d|dtdtd|jd	|jtj|_	t
j|j	d
<j|j	_t
|j	dfdWnEtk
rtjd
n&tttfk
rtjnXdS(Ns%s:%ss	%s://%s%stpayloadRRwtallow_truncatedtfollow_redirectstdeadlineRxRRcsjS(N(R7((R6(s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRsRF(R@RDR[RqRRRxRvRwR6Rftstatus_codeRtsetattrRrRRjRsRtRuRt
HTTPException(R0RturlRRwtnetloctabsolute_uri((R6s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs"			 
cCs |jr|jStjdS(N(R6RR(R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytgetresponses	cCsdS(N((R0tlevel((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytset_debuglevelscCsdS(N((R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRNscCsdS(N((R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR+sN(R3R4RRRR8RRRRNR+(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRws					tAppEngineHttpsConnectioncBs)eZdZdddddddZRS(s4Same as AppEngineHttpConnection, but for HTTPS URIs.c	Cs/tj||||||||d|_dS(NRn(RwR8R[(R0R@RDRRRERRC((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8s
N(R3R4RRR8(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs	cBseZdZddddedZdZddZdZdZ	dZ
dZd	Zd
dde
ddZRS(
s{An 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|_||_dS(s+
        The value of proxy_info is a ProxyInfo instance.

        If '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

        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(RCR	RYtconnectionsRet
basestringR$RR1RR8tcertificatestauthorizationsRR|toptimistic_concurrency_methodsRtfollow_all_redirectstignore_etagtforce_exception_to_status_codeR(R0RRRCR	RY((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8s 										c	
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/dist-packages/httplib2/__init__.pyt_auth_from_challengeNs

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/dist-packages/httplib2/__init__.pytadd_credentialsXscCs|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/dist-packages/httplib2/__init__.pytadd_certificate]scCs|jjg|_dS(sKRemove all the names and passwords
        that are used for authenticationN(RR5R(R0((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pytclear_credentialsbs
cCsIx<tdD].}y6|jdkr2|jn|j||||Wn@tjk
rbn*tjk
r|jt	d|j
ntk
r|jntjk
r
}d}t
|drt|dd}n	|j}|tjkrqntjk
r|jdkrb|dkrR|j|jq
qb|jn|dkr|j|jq
qnXy|j}	WnFtjtjfk
r|dkr|j|jq
q:nVXd}
|dkr|	jn|	j}
t|	}	|dkr:t|	|
}
nPq
W|	|
fS(NisUnable to find the server at %sitargsRFtHEAD(RRRRNRRRRjR+R<R@RhRORtgetattrRftECONNREFUSEDRRRRR R(R0tconnR`RRRwRRmterrR6R7((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyt
_conn_requesthsb



		








c
Cs"g|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=n|jdr|d}tj|}|jdsL||d<n|}|j	dkrpd}d}n|j||d|d|d|d\}}
||_qqtd||
q|j	dkr|dkr|jds||d<nt|||
|j|	qn||
fS(smDo the actual request using the connection object
        and also follow one level of redirects if necessaryiiitGETRi/i,i-i.i3tlocations:Redirected but the response is missing a Location: header.s-x-permanent-redirect-urlscontent-locations
if-none-matchsif-modified-sinceRRwtredirectionss3Redirected more times than rediection_limit allows.iiN(RsHEAD(i,i-i.i/i3(RsHEAD(i.i/(ii(RsHEAD(RRRR,RRRR6t
_stale_digestRRR2RR|R|R#RRVturlparseturljoinRRtcopytdeepcopytpreviousR$(R0RR@RR`RRRwRRRtauthsR6R7RRR[R\R]R^R_told_responsetredirect_method((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyt_requestsl= !!"!$





	.
cCs
t|S(N(Rz(R0Rw((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRzsRcCsy|d5kri}n|j|}|jdsGdt|d<nt|}t|\}}}	}
|jddd!}t|dkr|ddkr|dkrd	}|d}n|d|}||jkr|j|}
n|st	|}nt
|jj|}t
|tr|r||d
|ddd|ddd|jd
|jd|jd|j}
|j|<q||d|jd
|jd|jd|j}
|j|<n)||d|jd
|j}
|j|<|
jtd|kr"d|kr"d|d<ntjj}d5}|jr|
}|jj|}|ryM|jdd\}}tjj}|j||j}d5|_Wqtk
r|jj|d5}d5}qXqnd5}||jkr5|jr5|jdr5|j r5d|kr5|d|d<n|d6krc|jrc|rc|jj|n|d7krd|kr|d}|j!j"ddjd}xG|D]<}d|}||}|j|d5|krd5}PqqWn|ri|d8kri|jrid|kri|jdr|dkrGt#didn|j$|ddd|d |d\}}t%||_&t'|j&_(n	t)||}|d!kr|sd"|d#<d}nt%|}|rt'|_(n||fS|d$kr^|jdr/|j r/d%|kr/|d|d%<n|jd&rmd&|krm|d&|d'<qmn|d(krmn|j*|
|||	|||||	\}}|j+d)kr8|dkr8x"t,|D]}||||<qWt%|}t-|d*r|j.|_.nt/||||j||}d+|_+t'|_(q|j+d+krP|}q|jj||}ngt0|}|jd,rd"|d#<t%|}d}n-|j*|
|||	|||||	\}}Wnt1k
r}|j2rt3|t4r(|j5}|j6}d-|_+t7||_8qt3|t9jrsd.}t%id/d06d1d#6t|d26}d.|_8qt7|}t%id/d06d3d#6t|d26}d4|_8qnX||fS(9s 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)Riiit443RRnRRRRCR	RYRsaccept-encodings
gzip, deflates

tetagsif-matchRRRRsRFRGs
-varied-%ss-x-permanent-redirect-urls3Redirected more times than rediection_limit allows.RwRRt504RRs
if-none-matchs
last-modifiedsif-modified-sinceRi0Risonly-if-cachedisRequest Timeouts
text/plainscontent-typet408scontent-lengtht400sBad RequestN(sGETsHEAD(sGETsHEAD(sGETsHEAD(:RRzR|t__version__RRbRLRoRtSCHEME_TO_CONNECTIONRHRR7t
issubclassRVRRCR	RYRR(RRRRKt
FeedParsertfeedR+t_parset
IndexErrorRRRRYRR$RR RRt	fromcacheRRRRRRRRRt	ExceptionRReR5R6R7RfRR(R0RRRRwRtconnection_typeR[R\R`Ratdomain_porttconn_keyRtcertsRtcached_valueRR7t
feedparserRRRQRxRyR6Rtentry_dispositiontmerged_responseRRm((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs
	.

				

	


=
!


',

	
%-			
	1				N(R3R4RRRR8RRRRRRRztDEFAULT_MAX_REDIRECTSR(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyRs	<	
			;	E	cBs>eZdZeZdZdZdZdZ	dZ
dZRS(s<An object more like email.Message than httplib.HTTPResponse.iitOkcCst|tjryx*|jD]\}}|||j<qW|j|_t|j|d<|j|_|j|_nt|t	j
j
rx$|jD]\}}|||<qWt|d|_nEx$|j
D]\}}|||<qWt|jd|j|_dS(NR(ReRtHTTPResponseR2RYRRfRtversionRRR/RRuRK(R0RRxRy((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR8scCs|dkr|St|dS(NRt(tAttributeError(R0R((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyt__getattr__sN(R3R4RRRRRRRRR8R(((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyR s	(t
__future__RRt
__copyright__t__contributors__t__license__RRtsysRtemail.Utilst
email.Messagetemail.FeedParserRRRRRRR&RRRRRfthashlibRRRRktImportErrortshaRR
RRRthttplib2RRR
tSSLErrorRhRRtversion_infoRRt__all__R(R,R1RRR2RR"R5R#R$R%R&R'R:R;R<R)RR=R>R?RRXRIRRtcompileRSRVRbRdRnRrRvRzRRRRRRRRRRRtobjectRRRRRRRRR$R1R8R!RBRARWRVRtgoogle.appengine.apiRotapiproxytGetStubtgoogle.appengine.api.urlfetchRqRrRsRtRuRtRvRwRRR (((s5/usr/lib/python2.7/dist-packages/httplib2/__init__.pyt<module>s 	
	


	

										
	J		%		"
;>
!3
	9