Your IP : 3.145.168.166


Current Path : /lib64/python2.7/
Upload File :
Current File : //lib64/python2.7/urllib2.pyo

�
�mec@sWdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZyddlmZWn!ek
r�ddlmZnXyddlZWnek
reZnXeZddlmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddlm%Z%m&Z&m'Z'm(Z(e
j)d Z*da,de	j-ddedd�Z.d�Z/d	e0fd
��YZ1de1efd��YZ2ej3d
�Z4d�Z5ddDd��YZ6ddEd��YZ7d�Z8ddFd��YZ9de9fd��YZ:de9fd��YZ;de9fd��YZ<d�Z=de9fd��YZ>ddGd ��YZ?d!e?fd"��YZ@d#dHd$��YZAd%eAe9fd&��YZBd'eAe9fd(��YZCd)�ZDd*dId+��YZEd,e9eEfd-��YZFd.e9eEfd/��YZGd0e9fd1��YZHd2eHfd3��YZIeJed4�r�d5eHfd6��YZKnd7e9fd8��YZLd9e9fd:��YZMd;�ZNd<�ZOd=�ZPd>e9fd?��YZQd@e9fdA��YZRdBeRfdC��YZSdS(Js!An extensible library for opening URLs using a variety of protocols

The simplest way to use this module is to call the urlopen function,
which accepts a string containing a URL or a Request object (described
below).  It opens the URL and returns the results as file-like
object; the returned object has some extra methods described below.

The OpenerDirector manages a collection of Handler objects that do
all the actual work.  Each Handler implements a particular protocol or
option.  The OpenerDirector is a composite object that invokes the
Handlers needed to open the requested URL.  For example, the
HTTPHandler performs HTTP GET and POST requests and deals with
non-error returns.  The HTTPRedirectHandler automatically deals with
HTTP 301, 302, 303 and 307 redirect errors, and the HTTPDigestAuthHandler
deals with digest authentication.

urlopen(url, data=None) -- Basic usage is the same as original
urllib.  pass the url and optionally data to post to an HTTP URL, and
get a file-like object back.  One difference is that you can also pass
a Request instance instead of URL.  Raises a URLError (subclass of
IOError); for HTTP errors, raises an HTTPError, which can also be
treated as a valid response.

build_opener -- Function that creates a new OpenerDirector instance.
Will install the default handlers.  Accepts one or more Handlers as
arguments, either instances or Handler classes that it will
instantiate.  If one of the argument is a subclass of the default
handler, the argument will be installed instead of the default.

install_opener -- Installs a new opener as the default opener.

objects of interest:

OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages
the Handler classes, while dealing with requests and responses.

Request -- An object that encapsulates the state of a request.  The
state can be as simple as the URL.  It can also include extra HTTP
headers, e.g. a User-Agent.

BaseHandler --

exceptions:
URLError -- A subclass of IOError, individual protocols have their own
specific subclass.

HTTPError -- Also a valid HTTP response, so you can treat an HTTP error
as an exceptional event or valid response.

internals:
BaseHandler and parent
_call_chain conventions

Example usage:

import urllib2

# set up authentication info
authinfo = urllib2.HTTPBasicAuthHandler()
authinfo.add_password(realm='PDQ Application',
                      uri='https://mahler:8092/site-updates.py',
                      user='klem',
                      passwd='geheim$parole')

proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"})

# build a new opener that adds authentication and caching FTP handlers
opener = urllib2.build_opener(proxy_support, authinfo, urllib2.CacheFTPHandler)

# install it
urllib2.install_opener(opener)

f = urllib2.urlopen('http://www.python.org/')


i����N(tStringIO(tunwraptunquotet	splittypet	splithosttquotet
addinfourlt	splitporttsplittagttoBytest	splitattrt
ftpwrappert	splitusertsplitpasswdt
splitvalue(t	localhostturl2pathnamet
getproxiestproxy_bypassic		Cs�|s|s|r�|dk	r-td��ntsBtd��ntjdtjd|d|�}td|dt�}t|�}nF|r�td|�}t|�}n"t	dkr�t�a	}nt	}|j
|||�S(NsDYou can't pass both context and any of cafile, capath, and cadefaultsSSL support not availablet	cert_reqstcafiletcapathtcontexttcheck_hostname(tNonet
ValueErrort	_have_ssltsslt_create_stdlib_contextt
CERT_REQUIREDtHTTPSHandlertTruetbuild_openert_openertopen(	turltdatattimeoutRRt	cadefaultRt
https_handlertopener((s/usr/lib64/python2.7/urllib2.pyturlopen�s$	cCs
|adS(N(R!(R(((s/usr/lib64/python2.7/urllib2.pytinstall_opener�stURLErrorcBseZd�Zd�ZRS(cCs|f|_||_dS(N(targstreason(tselfR-((s/usr/lib64/python2.7/urllib2.pyt__init__�scCsd|jS(Ns<urlopen error %s>(R-(R.((s/usr/lib64/python2.7/urllib2.pyt__str__�s(t__name__t
__module__R/R0(((s/usr/lib64/python2.7/urllib2.pyR+�s	t	HTTPErrorcBsAeZdZejZd�Zd�Zed��Zd�Z	RS(sBRaised when HTTP error occurs, but also acts like non-error returncCsV||_||_||_||_||_|dk	rR|j||||�ndS(N(tcodetmsgthdrstfptfilenameRt_HTTPError__super_init(R.R#R4R5R6R7((s/usr/lib64/python2.7/urllib2.pyR/�s					cCsd|j|jfS(NsHTTP Error %s: %s(R4R5(R.((s/usr/lib64/python2.7/urllib2.pyR0�scCs|jS(N(R5(R.((s/usr/lib64/python2.7/urllib2.pyR-�scCs|jS(N(R6(R.((s/usr/lib64/python2.7/urllib2.pytinfo�s(
R1R2t__doc__RR/R9R0tpropertyR-R:(((s/usr/lib64/python2.7/urllib2.pyR3�s		
	s:\d+$cCs_|j�}tj|�d}|dkr@|jdd�}ntjd|d�}|j�S(s�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    ittHost(tget_full_urlturlparset
get_headert_cut_port_retsubtlower(trequestR#thost((s/usr/lib64/python2.7/urllib2.pytrequest_host�stRequestcBs�eZdided�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zdd�Zd�ZRS(cCs�t|�|_t|j�\|_|_d|_d|_d|_d|_||_	i|_
x*|j�D]\}}|j||�qmWi|_
|dkr�t|�}n||_||_dS(N(Rt_Request__originalRt_Request__fragmentRttypeRFtportt_tunnel_hostR$theaderstitemst
add_headertunredirected_hdrsRGtorigin_req_hosttunverifiable(R.R#R$RNRRRStkeytvalue((s/usr/lib64/python2.7/urllib2.pyR/�s								cCs^|d dkrQ|d}ttd|�rQt|d|��t||�Snt|�dS(Nit_Request__r_tget_(thasattrRHtgetattrtAttributeError(R.tattrtname((s/usr/lib64/python2.7/urllib2.pyt__getattr__�s
cCs|j�rdSdSdS(NtPOSTtGET(thas_data(R.((s/usr/lib64/python2.7/urllib2.pyt
get_methodscCs
||_dS(N(R$(R.R$((s/usr/lib64/python2.7/urllib2.pytadd_data
scCs
|jdk	S(N(R$R(R.((s/usr/lib64/python2.7/urllib2.pyR`
scCs|jS(N(R$(R.((s/usr/lib64/python2.7/urllib2.pytget_datascCs(|jrd|j|jfS|jSdS(Ns%s#%s(RJRI(R.((s/usr/lib64/python2.7/urllib2.pyR?s	cCsV|jdkrOt|j�\|_|_|jdkrOtd|j�qOn|jS(Nsunknown url type: %s(RKRRRIt_Request__r_typeR(R.((s/usr/lib64/python2.7/urllib2.pytget_types
cCsR|jdkrKt|j�\|_|_|jrKt|j�|_qKn|jS(N(RFRRRdt_Request__r_hostR(R.((s/usr/lib64/python2.7/urllib2.pytget_host s
	cCs|jS(N(Rf(R.((s/usr/lib64/python2.7/urllib2.pytget_selector'scCsJ|jdkr(|jr(|j|_n||_|j|_||_dS(Nthttps(RKRMRFRIRf(R.RFRK((s/usr/lib64/python2.7/urllib2.pyt	set_proxy*s
	cCs|j|jkS(N(RfRI(R.((s/usr/lib64/python2.7/urllib2.pyt	has_proxy3scCs|jS(N(RR(R.((s/usr/lib64/python2.7/urllib2.pytget_origin_req_host6scCs|jS(N(RS(R.((s/usr/lib64/python2.7/urllib2.pytis_unverifiable9scCs||j|j�<dS(N(RNt
capitalize(R.RTtval((s/usr/lib64/python2.7/urllib2.pyRP<scCs||j|j�<dS(N(RQRn(R.RTRo((s/usr/lib64/python2.7/urllib2.pytadd_unredirected_header@scCs||jkp||jkS(N(RNRQ(R.theader_name((s/usr/lib64/python2.7/urllib2.pyt
has_headerDscCs"|jj||jj||��S(N(RNtgetRQ(R.Rqtdefault((s/usr/lib64/python2.7/urllib2.pyRAHs	cCs)|jj�}|j|j�|j�S(N(RQtcopytupdateRNRO(R.R6((s/usr/lib64/python2.7/urllib2.pytheader_itemsMsN(R1R2RtFalseR/R]RaRbR`RcR?ReRgRhRjRkRlRmRPRpRrRARw(((s/usr/lib64/python2.7/urllib2.pyRH�s(																	tOpenerDirectorcBsSeZd�Zd�Zd�Zd�Zdejd�Z	dd�Z
d�ZRS(cCsMdt}d|fg|_g|_i|_i|_i|_i|_dS(NsPython-urllib/%ss
User-agent(t__version__t
addheadersthandlersthandle_openthandle_errortprocess_responsetprocess_request(R.tclient_version((s/usr/lib64/python2.7/urllib2.pyR/Ss
				cCs�t|d�s(tdt|���nt}xet|�D]W}|dkrSq;n|jd�}|| }||d}|jd�r�|jd�|d}||d}yt|�}Wntk
r�nX|j	j
|i�}	|	|j	|<n]|d	kr|}|j}	n?|d
kr3|}|j}	n!|dkr;|}|j
}	nq;|	j|g�}
|
rtj|
|�n
|
j|�t}q;W|r�tj|j|�|j|�ndS(
Nt
add_parents%expected BaseHandler instance, got %rtredirect_requesttdo_opent
proxy_opent_iterrorR"tresponseRE(sredirect_requestsdo_opens
proxy_open(RXt	TypeErrorRKRxtdirtfindt
startswithtintRR~RsR}RR�t
setdefaulttbisecttinsorttappendRR|R�(R.thandlertaddedtmethtitprotocolt	conditiontjtkindtlookupR|((s/usr/lib64/python2.7/urllib2.pytadd_handler^sJ



cCsdS(N((R.((s/usr/lib64/python2.7/urllib2.pytclose�sc	GsR|j|d�}x9|D]1}t||�}||�}|dk	r|SqWdS(N((RsRYR(	R.tchainR�t	meth_nameR,R|R�tfunctresult((s/usr/lib64/python2.7/urllib2.pyt_call_chain�s
c
Cs�t|t�r!t||�}n"|}|dk	rC|j|�n||_|j�}|d}x8|jj|g�D]!}t	||�}||�}qxW|j
||�}	|d}x;|jj|g�D]$}t	||�}|||	�}	q�W|	S(Nt_requestt	_response(t
isinstancet
basestringRHRRbR%ReR�RsRYt_openR(
R.tfullurlR$R%treqR�R�t	processorR�R�((s/usr/lib64/python2.7/urllib2.pyR"�s"	

cCss|j|jdd|�}|r%|S|j�}|j|j||d|�}|rZ|S|j|jdd|�S(NRttdefault_openR�tunknowntunknown_open(R�R}Re(R.R�R$R�R�((s/usr/lib64/python2.7/urllib2.pyR��s
cGs�|d
kr<|jd}|d}d|}d}|}n|j}|d}d}|||f|}|j|�}|r�|S|r�|dd	f|}|j|�SdS(NthttpRiis
http_error_%sit_erroriRtthttp_error_default(R�shttps(R~R�(R.tprotoR,tdictR�thttp_errt	orig_argsR�((s/usr/lib64/python2.7/urllib2.pyR��s 


		
N(R1R2R/R�R�R�Rtsockett_GLOBAL_DEFAULT_TIMEOUTR"R�R�(((s/usr/lib64/python2.7/urllib2.pyRyRs		/		csRddl��fd�}t�}tttttttt	g}t
td�ra|jt
�nt�}xl|D]d}x[|D]S}||�r�t||�r�|j|�q�q~t||�r~|j|�q~q~WqqWx|D]}|j|�q�Wx|D]}|j|��q�Wx3|D]+}||�r=|�}n|j|�qW|S(s+Create an opener object from a list of handlers.

    The opener will use several default handlers, including support
    for HTTP, FTP and when applicable, HTTPS.

    If any of the handlers passed as arguments are subclasses of the
    default handlers, the default handlers will not be used.
    i����Ncst|�jtf�S(N(R�t	ClassTypeRK(tobj(ttypes(s/usr/lib64/python2.7/urllib2.pytisclass�stHTTPS(R�RytProxyHandlertUnknownHandlertHTTPHandlertHTTPDefaultErrorHandlertHTTPRedirectHandlert
FTPHandlertFileHandlertHTTPErrorProcessorRXthttplibR�Rtsett
issubclasstaddR�tremoveR�(R|R�R(tdefault_classestskiptklasstcheckth((R�s/usr/lib64/python2.7/urllib2.pyR �s2				




tBaseHandlercBs)eZdZd�Zd�Zd�ZRS(i�cCs
||_dS(N(tparent(R.R�((s/usr/lib64/python2.7/urllib2.pyR�scCsdS(N((R.((s/usr/lib64/python2.7/urllib2.pyR�scCs#t|d�stS|j|jkS(Nt
handler_order(RXRR�(R.tother((s/usr/lib64/python2.7/urllib2.pyt__lt__s(R1R2R�R�R�R�(((s/usr/lib64/python2.7/urllib2.pyR�s		R�cBs#eZdZdZd�ZeZRS(sProcess HTTP error responses.i�cCsd|j|j|j�}}}d|ko7dkns`|jjd|||||�}n|S(Ni�i,R�(R4R5R:R�R�(R.RER�R4R5R6((s/usr/lib64/python2.7/urllib2.pyt
http_responses
 	(R1R2R;R�R�thttps_response(((s/usr/lib64/python2.7/urllib2.pyR�s	R�cBseZd�ZRS(cCs"t|j�||||��dS(N(R3R?(R.R�R7R4R5R6((s/usr/lib64/python2.7/urllib2.pyR�-s(R1R2R�(((s/usr/lib64/python2.7/urllib2.pyR�,sR�cBs:eZdZdZd�Zd�ZeZZZdZ	RS(ii
c	Cs�|j�}|dkr$|dks<|dkr�|dkr�|jdd	�}td
�|jj�D��}t|d|d|j�d
t�St|j	�||||��dS(s�Return a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
        i-i.i/i3R_tHEADR^t s%20css3|])\}}|j�dkr||fVqdS(scontent-lengthscontent-typeN(scontent-lengthscontent-type(RD(t.0tktv((s/usr/lib64/python2.7/urllib2.pys	<genexpr>Ls	RNRRRSN(i-i.i/i3(sGETR�(i-i.i/(
RatreplaceR�RNRORHRlRR3R?(	R.R�R7R4R5RNtnewurltmt
newheaders((s/usr/lib64/python2.7/urllib2.pyR�8s
	c	Cs�d|kr"|jd�d}n&d|krD|jd�d}ndStj|�}|jsyt|�}d|d<ntj|�}tj|j�|�}|j�}|jd�p�|jd�p�|jd�s�t	|||d	|||��n|j
||||||�}	|	dkr*dSt|d
�r�|j
}
|	_
|
j|d�|jksyt|
�|jkr�t	|j�||j|||��q�ni}
|	_
|_
|
j|d�d|
|<|j�|j�|jj|	d|j�S(
Ntlocationiturit/ishttp://shttps://sftp://s) - Redirection to url '%s' is not allowedt
redirect_dictiR%(t
getheadersR@tpathtlistt
urlunparseturljoinR?RDR�R3R�RRXR�Rstmax_repeatstlentmax_redirectionstinf_msgtreadR�R�R"R%(R.R�R7R4R5RNR�turlpartstnewurl_lowertnewtvisited((s/usr/lib64/python2.7/urllib2.pythttp_error_302ZsB	
	

soThe HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
(
R1R2R�R�R�R�thttp_error_301thttp_error_303thttp_error_307R�(((s/usr/lib64/python2.7/urllib2.pyR�0s	"	8c	Cs�t|�\}}|jd�s0d}|}nV|jd�sRtd|��n|jdd�}|dkryd}n|d|!}t|�\}}|dk	r�t|�\}}n
d}}||||fS(s3Return (scheme, user, password, host/port) given a URL or an authority.

    If a URL is supplied, it must have an authority (host:port) component.
    According to RFC 3986, having an authority component means the URL must
    have two slashes after the scheme:

    >>> _parse_proxy('file:/ftp.example.com/')
    Traceback (most recent call last):
    ValueError: proxy URL with no authority: 'file:/ftp.example.com/'

    The first three items of the returned tuple may be None.

    Examples of authority parsing:

    >>> _parse_proxy('proxy.example.com')
    (None, None, None, 'proxy.example.com')
    >>> _parse_proxy('proxy.example.com:3128')
    (None, None, None, 'proxy.example.com:3128')

    The authority component may optionally include userinfo (assumed to be
    username:password):

    >>> _parse_proxy('joe:password@proxy.example.com')
    (None, 'joe', 'password', 'proxy.example.com')
    >>> _parse_proxy('joe:password@proxy.example.com:3128')
    (None, 'joe', 'password', 'proxy.example.com:3128')

    Same examples, but with URLs instead:

    >>> _parse_proxy('http://proxy.example.com/')
    ('http', None, None, 'proxy.example.com')
    >>> _parse_proxy('http://proxy.example.com:3128/')
    ('http', None, None, 'proxy.example.com:3128')
    >>> _parse_proxy('http://joe:password@proxy.example.com/')
    ('http', 'joe', 'password', 'proxy.example.com')
    >>> _parse_proxy('http://joe:password@proxy.example.com:3128')
    ('http', 'joe', 'password', 'proxy.example.com:3128')

    Everything after the authority is ignored:

    >>> _parse_proxy('ftp://joe:password@proxy.example.com/rubbish:3128')
    ('ftp', 'joe', 'password', 'proxy.example.com')

    Test for no trailing '/' case:

    >>> _parse_proxy('http://joe:password@proxy.example.com')
    ('http', 'joe', 'password', 'proxy.example.com')

    R�s//sproxy URL with no authority: %rii����N(RR�RRR�RR
(	tproxytschemetr_schemet	authoritytendtuserinfothostporttusertpassword((s/usr/lib64/python2.7/urllib2.pyt_parse_proxy�s2		

R�cBs#eZdZdd�Zd�ZRS(idcCse|dkrt�}n||_x=|j�D]/\}}t|d||||jd��q.WdS(Ns%s_opencSs||||�S(N((trR�RKR�((s/usr/lib64/python2.7/urllib2.pyt<lambda>�s(RRtproxiesROtsetattrR�(R.R�RKR#((s/usr/lib64/python2.7/urllib2.pyR/�s	
cCs|j�}t|�\}}}}|dkr9|}n|j�|jr_t|j�r_dS|r�|r�dt|�t|�f}	tj|	�j	�}
|j
dd|
�nt|�}|j||�||ks�|dkr�dS|jj
|d|j�SdS(Ns%s:%ssProxy-authorizationsBasic RiR%(ReR�RRgRFRRtbase64t	b64encodetstripRPRjR�R"R%(R.R�R�RKt	orig_typet
proxy_typeR�R�R�t	user_passtcreds((s/usr/lib64/python2.7/urllib2.pyR��s 	
N(R1R2R�RR/R�(((s/usr/lib64/python2.7/urllib2.pyR��s
tHTTPPasswordMgrcBs8eZd�Zd�Zd�Zed�Zd�ZRS(cCs
i|_dS(N(tpasswd(R.((s/usr/lib64/python2.7/urllib2.pyR/scCs�t|t�r|g}n||jkr:i|j|<nxVttfD]H}tg|D]}|j||�^qW�}||f|j||<qGWdS(N(R�R�R	RRxttuplet
reduce_uri(R.trealmR�R�R	tdefault_porttutreduced_uri((s/usr/lib64/python2.7/urllib2.pytadd_passwords(c	Cs�|jj|i�}xjttfD]\}|j||�}xA|j�D]3\}}x$|D]}|j||�rZ|SqZWqGWq"WdS(N(NN(R	RsRRxRt	iteritemst	is_suburiR(	R.RtauthuritdomainsR
treduced_authurituristauthinfoR�((s/usr/lib64/python2.7/urllib2.pytfind_user_passwords
c
Cs�tj|�}|dr@|d}|d}|dp:d}nd
}|}d}t|�\}}|r�|d
kr�|d
k	r�idd6dd6j|�}	|	d
k	r�d	||	f}q�n||fS(s@Accept authority or URI and extract only the authority and path.iiiR�iPR�i�Ris%s:%dN(R@turlsplitRRRs(
R.R�R
tpartsR�R�R�RFRLtdport((s/usr/lib64/python2.7/urllib2.pyR(s 




	cCsi||krtS|d|dkr(tStj|d|df�}t|�t|d�kretStS(scCheck if test is below base in a URI tree

        Both args must be URIs in reduced form.
        ii(RRxt	posixpathtcommonprefixR�(R.tbasettesttcommon((s/usr/lib64/python2.7/urllib2.pyR?s(R1R2R/RRRRR(((s/usr/lib64/python2.7/urllib2.pyRs
			
tHTTPPasswordMgrWithDefaultRealmcBseZd�ZRS(cCsDtj|||�\}}|dk	r1||fStj|d|�S(N(RRR(R.RRR�R�((s/usr/lib64/python2.7/urllib2.pyRPs

(R1R2R(((s/usr/lib64/python2.7/urllib2.pyR!NstAbstractBasicAuthHandlercBsDeZejdej�Zdd�Zd�Zd�Z	d�Z
RS(s1(?:.*,)*[ 	]*([^ 	]+)[ 	]+realm=(["']?)([^"']*)\2cCs=|dkrt�}n||_|jj|_d|_dS(Ni(RRR	Rtretried(R.tpassword_mgr((s/usr/lib64/python2.7/urllib2.pyR/fs
	cCs
d|_dS(Ni(R#(R.((s/usr/lib64/python2.7/urllib2.pytreset_retry_countmsc
Cs�|j|d�}|jdkrBt|j�dd|d��n|jd7_|r�tjj|�}|r�|j�\}}}|dkr�t	j
dtd�n|j�d	kr�|j
|||�}	|	r�|	jdkr�d
|_n|	Sq�ndS(Nii�sbasic auth failedit"t'sBasic Auth Realm was unquoteditbasici(R&R'(RsRR#R3R?R"trxtsearchtgroupstwarningstwarntUserWarningRDtretry_http_basic_authR4(
R.tauthreqRFR�RNtmoR�RRR�((s/usr/lib64/python2.7/urllib2.pythttp_error_auth_reqedps"	
cCs�|jj||�\}}|dk	r�d||f}dtj|�j�}|jj|jd�|krrdS|j	|j|�|j
j|d|j�SdSdS(Ns%s:%ssBasic %sR%(
R	RRRRRRNRstauth_headerRpR�R"R%(R.RFR�RR�tpwtrawtauth((s/usr/lib64/python2.7/urllib2.pyR/�sN(R1R2tretcompiletIR)RR/R%R2R/(((s/usr/lib64/python2.7/urllib2.pyR"Xs			tHTTPBasicAuthHandlercBseZdZd�ZRS(t
AuthorizationcCs2|j�}|jd|||�}|j�|S(Nswww-authenticate(R?R2R%(R.R�R7R4R5RNR#R�((s/usr/lib64/python2.7/urllib2.pythttp_error_401�s
	
(R1R2R3R<(((s/usr/lib64/python2.7/urllib2.pyR:�stProxyBasicAuthHandlercBseZdZd�ZRS(sProxy-authorizationcCs2|j�}|jd|||�}|j�|S(Nsproxy-authenticate(RgR2R%(R.R�R7R4R5RNR�R�((s/usr/lib64/python2.7/urllib2.pythttp_error_407�s
	
(R1R2R3R>(((s/usr/lib64/python2.7/urllib2.pyR=�scCs}tjjd�r;td�}|j|�}|j�|Sgt|�D]}ttj	dd��^qH}dj
|�SdS(sReturn n random bytes.s/dev/urandomiiR=N(tosR�texistsR"R�R�trangetchrtrandomt	randrangetjoin(tntftsR�tL((s/usr/lib64/python2.7/urllib2.pytrandombytes�s
1tAbstractDigestAuthHandlercBsSeZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	cCsO|dkrt�}n||_|jj|_d|_d|_d|_dS(Ni(RRR	RR#tnonce_countt
last_nonce(R.R	((s/usr/lib64/python2.7/urllib2.pyR/�s			cCs
d|_dS(Ni(R#(R.((s/usr/lib64/python2.7/urllib2.pyR%�scCs�|j|d�}|jdkrBt|j�dd|d��n|jd7_|r�|j�d}|j�dkr�|j||�SndS(Nii�sdigest auth failediitdigest(RsRR#R3R?tsplitRDtretry_http_digest_auth(R.R3RFR�RNR0R�((s/usr/lib64/python2.7/urllib2.pyR2�scCs�|jdd�\}}tt|��}|j||�}|r�d|}|jj|jd�|krndS|j|j|�|j	j
|d|j�}|SdS(NR�is	Digest %sR%(ROtparse_keqv_listtparse_http_listtget_authorizationRNRsR3RRpR�R"R%(R.R�R6ttokent	challengetchaltauth_valtresp((s/usr/lib64/python2.7/urllib2.pyRP�s
cCs<tjd|j|tj�td�f�j�}|d S(Ns%s:%s:%s:%sii(thashlibtsha1RLttimetctimeRJt	hexdigest(R.tnoncetdig((s/usr/lib64/python2.7/urllib2.pyt
get_cnonce�scCsdyK|d}|d}|jd�}|jdd�}|jdd�}Wntk
r_dSX|j|�\}}	|dkr�dS|jj||j��\}
}|
dkr�dS|j�r�|j|j	�|�}nd}d|
||f}
d|j
�|j�f}|d	kr�||jkr?|j
d
7_
nd
|_
||_d|j
}|j|�}d||||||�f}|	||
�|�}nD|dkr�|	||
�d|||�f�}ntd
|��d|
|||j�|f}|r|d|7}n|r5|d|7}n|d|7}|r`|d||f7}n|S(NRR^tqopt	algorithmtMD5topaques%s:%s:%ss%s:%sR6is%08xs%s:%s:%s:%s:%ssqop '%s' is not supported.s>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"s
, opaque="%s"s
, digest="%s"s, algorithm="%s"s, qop=auth, nc=%s, cnonce="%s"(RsRtKeyErrortget_algorithm_implsR	RR?R`tget_entity_digestRcRaRhRMRLR`R+(R.R�RVRR^RaRbRdtHtKDR�R4tentdigtA1tA2tncvaluetcnoncetnoncebittrespdigR((s/usr/lib64/python2.7/urllib2.pyRS�sV


!		
(
csU|j�}|dkr$d��n|dkr<d��n�fd�}�|fS(NRccSstj|�j�S(N(RYtmd5R](tx((s/usr/lib64/python2.7/urllib2.pyR�AstSHAcSstj|�j�S(N(RYRZR](Rr((s/usr/lib64/python2.7/urllib2.pyR�Cscs�d||f�S(Ns%s:%s((RHtd(Rh(s/usr/lib64/python2.7/urllib2.pyR�Es(tupper(R.RbRi((Rhs/usr/lib64/python2.7/urllib2.pyRf<scCsdS(N(R(R.R$RV((s/usr/lib64/python2.7/urllib2.pyRgHsN(R1R2RR/R%R2RPR`RSRfRg(((s/usr/lib64/python2.7/urllib2.pyRK�s					
	=	tHTTPDigestAuthHandlercBs#eZdZdZdZd�ZRS(s�An authentication protocol defined by RFC 2069

    Digest authentication improves on basic authentication because it
    does not transmit passwords in the clear.
    R;i�cCs?tj|j��d}|jd|||�}|j�|S(Niswww-authenticate(R@R?R2R%(R.R�R7R4R5RNRFtretry((s/usr/lib64/python2.7/urllib2.pyR<Ws
	
(R1R2R;R3R�R<(((s/usr/lib64/python2.7/urllib2.pyRvMstProxyDigestAuthHandlercBseZdZdZd�ZRS(sProxy-Authorizationi�cCs2|j�}|jd|||�}|j�|S(Nsproxy-authenticate(RgR2R%(R.R�R7R4R5RNRFRw((s/usr/lib64/python2.7/urllib2.pyR>ds
	
(R1R2R3R�R>(((s/usr/lib64/python2.7/urllib2.pyRx_stAbstractHTTPHandlercBs/eZdd�Zd�Zd�Zd�ZRS(icCs
||_dS(N(t_debuglevel(R.t
debuglevel((s/usr/lib64/python2.7/urllib2.pyR/mscCs
||_dS(N(Rz(R.tlevel((s/usr/lib64/python2.7/urllib2.pytset_http_debuglevelpsc
Cs:|j�}|s!td��n|j�r�|j�}|jd�s[|jdd�n|jd�s�|jddt|��q�n|}|j�r�t|j	��\}}t
|�\}}n|jd�s�|jd|�nxH|jjD]:\}}	|j
�}|j|�s�|j||	�q�q�W|S(Ns
no host givensContent-types!application/x-www-form-urlencodedsContent-lengths%dR>(RgR+R`RcRrRpR�RkRRhRR�R{Rn(
R.RERFR$tsel_hostR�tseltsel_pathR\RU((s/usr/lib64/python2.7/urllib2.pytdo_request_ss.
cs�|j�}|s!td��n||d|j|�}|j|j�t|j���jt�fd�|jj	�D���d�d<td��j	�D���|j
r�i}d}|�kr��|||<�|=n|j|j
d|�ny)|j|j
�|j�|j��Wn,tjk
rS}|j�t|��n7Xy|jd	t�}	Wntk
r�|j�}	nX|	j|	_tj|	dt�}
t|
|	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
        s
no host givenR%c3s-|]#\}}|�kr||fVqdS(N((R�R�R�(RN(s/usr/lib64/python2.7/urllib2.pys	<genexpr>�s	R�t
Connectioncss'|]\}}|j�|fVqdS(N(ttitle(R�R\Ro((s/usr/lib64/python2.7/urllib2.pys	<genexpr>�ssProxy-AuthorizationRNt	buffering(RgR+R%tset_debuglevelRzR�RQRvRNRORMt
set_tunnelRERaRhR$R�R�R�tgetresponseRR�R�trecvt_fileobjectRR5R?tstatusR4R-(R.t
http_classR�thttp_conn_argsRFR�ttunnel_headerstproxy_auth_hdrterrR�R7RX((RNs/usr/lib64/python2.7/urllib2.pyR��s@
,	
	
)


(R1R2R/R}R�R�(((s/usr/lib64/python2.7/urllib2.pyRyks		R�cBseZd�ZejZRS(cCs|jtj|�S(N(R�R�tHTTPConnection(R.R�((s/usr/lib64/python2.7/urllib2.pyt	http_open�s(R1R2R�RyR�thttp_request(((s/usr/lib64/python2.7/urllib2.pyR��s	R�RcBs,eZdddd�Zd�ZejZRS(icCs&tj||�||_||_dS(N(RyR/t_contextt_check_hostname(R.R{RR((s/usr/lib64/python2.7/urllib2.pyR/�s	cCs%|jtj|d|jd|j�S(NRR(R�R�tHTTPSConnectionR�R�(R.R�((s/usr/lib64/python2.7/urllib2.pyt
https_open�sN(R1R2RR/R�RyR�t
https_request(((s/usr/lib64/python2.7/urllib2.pyR�s	tHTTPCookieProcessorcBs2eZdd�Zd�Zd�ZeZeZRS(cCs4ddl}|dkr'|j�}n||_dS(Ni����(t	cookielibRt	CookieJart	cookiejar(R.R�R�((s/usr/lib64/python2.7/urllib2.pyR/�scCs|jj|�|S(N(R�tadd_cookie_header(R.RE((s/usr/lib64/python2.7/urllib2.pyR��scCs|jj||�|S(N(R�textract_cookies(R.RER�((s/usr/lib64/python2.7/urllib2.pyR��sN(R1R2RR/R�R�R�R�(((s/usr/lib64/python2.7/urllib2.pyR��s
		R�cBseZd�ZRS(cCs |j�}td|��dS(Nsunknown url type: %s(ReR+(R.R�RK((s/usr/lib64/python2.7/urllib2.pyR�s(R1R2R�(((s/usr/lib64/python2.7/urllib2.pyR�scCsmi}x`|D]X}|jdd�\}}|ddkr[|ddkr[|dd!}n|||<q
W|S(s>Parse list of key=value strings where keys are not duplicated.t=iiR&i����(RO(tltparsedteltR�R�((s/usr/lib64/python2.7/urllib2.pyRQs
 cCs�g}d}t}}x�|D]�}|r?||7}t}qn|r�|dkr]t}qn|dkrrt}n||7}qn|dkr�|j|�d}qn|dkr�t}n||7}qW|r�|j|�ng|D]}|j�^q�S(spParse lists as described by RFC 2068 Section 2.

    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Neither commas nor quotes count if they are escaped.
    Only double-quotes count, not single-quotes.
    R=s\R&t,(RxRR�R(RHtrestparttescapeRtcur((s/usr/lib64/python2.7/urllib2.pyRRs4	


	

	cCs-ytj|�SWntjk
r(dSXdS(N(R�t
gethostbynametgaierrorR(RF((s/usr/lib64/python2.7/urllib2.pyt_safe_gethostbyname:sR�cBs)eZd�ZdZd�Zd�ZRS(cCsq|j�}|d dkr`|dd!dkr`|jr`|jdkr`d|_|jj|�S|j|�SdS(Nis//iR�Rtftp(RhRFRKR�R"topen_local_file(R.R�R#((s/usr/lib64/python2.7/urllib2.pyt	file_openBs,	cCs|tjdkruy7ttjd�dtjtj��d�t_Wqutjk
rqtjd�ft_quXntjS(NRi(	R�tnamesRR
R�tgethostbyname_extgethostnameR�R�(R.((s/usr/lib64/python2.7/urllib2.pyt	get_namesMs$cCs[ddl}ddl}|j�}|j�}t|�}y�tj|�}|j}|jj	|j
dt�}	|j|�d}
t
jtd|
p�d||	f��}|r�t|�\}}n|s�|r(t|�|j�kr(|rd||}
n
d|}
tt|d�||
�SWntk
rJ}t|��nXtd��dS(	Ni����tusegmtis6Content-type: %s
Content-length: %d
Last-modified: %s
s
text/plainsfile://trbsfile not on local host(temail.utilst	mimetypesRgRhRR?tstattst_sizetutilst
formatdatetst_mtimeRt
guess_typet	mimetoolstMessageRRR�R�RR"tOSErrorR+(R.R�temailR�RFR8t	localfiletstatstsizetmodifiedtmtypeRNRLtorigurlR5((s/usr/lib64/python2.7/urllib2.pyR�Xs0		
N(R1R2R�RR�R�R�(((s/usr/lib64/python2.7/urllib2.pyR�@s	
	R�cBseZd�Zd�ZRS(cCs�ddl}ddl}|j�}|s9td��nt|�\}}|dkrc|j}nt|�}t|�\}}|r�t	|�\}}nd}t
|�}|p�d}|p�d}ytj|�}Wn"tj
k
r�}t|��nXt|j��\}	}
|	jd�}tt
|�}|d |d}}|rg|drg|d}ny/|j||||||j�}
|r�dp�d}xM|
D]E}t|�\}}|j�d	kr�|dkr�|j�}q�q�W|
j||�\}}d}|j|j��d}|r;|d|7}n|dk	rd|dkrd|d|7}nt|�}tj|�}t|||j��SWn0|jk
r�}td|tj �d�nXdS(Ni����sftp error: no host givenR=R�iiR9tDRKtatAR�RtsContent-type: %s
sContent-length: %d
s
ftp error: %si(R�R�R�R9RtR�(!tftplibR�RgR+RRtFTP_PORTR�RR
RR�R�R�R
RhROtmaptconnect_ftpR%RRDRutretrfileR�R?RR�R�Rt
all_errorstsystexc_info(R.R�R�R�RFRLR�R	R5R�tattrstdirstfiletfwRKR[RUR7tretrlenRNR�tsf((s/usr/lib64/python2.7/urllib2.pytftp_openus\
!
c	Cs%t||||||dt�}|S(Nt
persistent(RRx(R.R�R	RFRLR�R%R�((s/usr/lib64/python2.7/urllib2.pyR��s	(R1R2R�R�(((s/usr/lib64/python2.7/urllib2.pyR�ts	5tCacheFTPHandlercBs>eZd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs1i|_i|_d|_d|_d|_dS(Nii<i(tcacheR%tsoonesttdelayt	max_conns(R.((s/usr/lib64/python2.7/urllib2.pyR/�s
				cCs
||_dS(N(R�(R.tt((s/usr/lib64/python2.7/urllib2.pyt
setTimeout�scCs
||_dS(N(R�(R.R�((s/usr/lib64/python2.7/urllib2.pytsetMaxConns�scCs�|||dj|�|f}||jkrJtj�|j|j|<n<t||||||�|j|<tj�|j|j|<|j�|j|S(NR�(RER�R[R�R%Rtcheck_cache(R.R�R	RFRLR�R%RT((s/usr/lib64/python2.7/urllib2.pyR��s"
cCstj�}|j|krrxT|jj�D]@\}}||kr+|j|j�|j|=|j|=q+q+Wnt|jj��|_t|j�|j	krxD|jj�D]3\}}||jkr�|j|=|j|=Pq�q�Wt|jj��|_ndS(N(
R[R�R%ROR�R�tmintvaluesR�R�(R.R�R�R�((s/usr/lib64/python2.7/urllib2.pyR��s


cCsBx!|jj�D]}|j�qW|jj�|jj�dS(N(R�R�R�tclearR%(R.tconn((s/usr/lib64/python2.7/urllib2.pytclear_cache�s
(R1R2R/R�R�R�R�R�(((s/usr/lib64/python2.7/urllib2.pyR��s				
	(((((((TR;RRYR�R�R?RRCR7R�R�R[R@R�R,t	cStringIORtImportErrorRRxRRturllibRRRRRRRRR	R
RRR
RRRRRtversionRzRR!R�R)R*tIOErrorR+R3R8RBRGRHRyR R�R�R�R�R�R�RR!R"R:R=RJRKRvRxRyR�RXRR�R�RQRRR�R�R�R�(((s/usr/lib64/python2.7/urllib2.pyt<module>Ls�


^"
		
	r�	'i	H-@
?	�n
	
	+	4<