ok
Direktori : /proc/thread-self/root/proc/self/root/lib64/python3.6/urllib/__pycache__/ |
Current File : //proc/thread-self/root/proc/self/root/lib64/python3.6/urllib/__pycache__/request.cpython-36.pyc |
3 ��f~� � ) @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlZddlZddlmZmZmZ ddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z, yddl-Z-W n e.k �r& dZ/Y nX dZ/dd d ddd ddddddddddddddddddd d!d"d#d$d%d&d'd(g!Z0d)e j1dd*� Z2da3dej4fddddd+�d,d�Z5d-d � Z6g Z7d~d.d%�Z8d/d&� Z9e j:d0e j;�Z<d1d2� Z=G d3d� d�Z>G d4d � d �Z?d5d!� Z@G d6d � d �ZAG d7d� deA�ZBG d8d� deA�ZCG d9d� deA�ZDd:d;� ZEG d<d� deA�ZFG d=d� d�ZGG d>d� deG�ZHG d?d� deH�ZIG d@d� d�ZJG dAd� deJeA�ZKG dBd� deJeA�ZLejMZNG dCd� d�ZOG dDd� deAeO�ZPG dEd� deAeO�ZQG dFdG� dGeA�ZRG dHd� deR�ZSeTejUdI��r2G dJdK� dKeR�ZVe0jWdK� G dLd � d eA�ZXG dMd� deA�ZYdNdO� ZZdPdQ� Z[G dRd� deA�Z\dSdT� Z]G dUd� deA�Z^G dVd� de^�Z_G dWd� deA�Z`dXZaejbdYk�r�ddZlcmdZdmeZe nd[d#� Zdd\d"� Zei ZfG d]d'� d'�ZgG d^d(� d(eg�Zhdaid_d`� Zjdakdadb� Zldamdcdd� Zndaodedf� ZpG dgdh� dh�Zqdidj� Zrddkdl�Zsdmdn� Zte judok�r�ddplvmwZwmxZx dqdr� Zydsdt� Zzdudv� Z{dwd$� Z|n6ejbdYk�r�dxdy� Z}dzd$� Z|d{d|� Z~d}dv� Z{nerZ|esZ{dS )�a� 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 OSError); 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 -- internals: BaseHandler and parent _call_chain conventions Example usage: import urllib.request # set up authentication info authinfo = urllib.request.HTTPBasicAuthHandler() authinfo.add_password(realm='PDQ Application', uri='https://mahler:8092/site-updates.py', user='klem', passwd='geheim$parole') proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"}) # build a new opener that adds authentication and caching FTP handlers opener = urllib.request.build_opener(proxy_support, authinfo, urllib.request.CacheFTPHandler) # install it urllib.request.install_opener(opener) f = urllib.request.urlopen('http://www.python.org/') � N)�URLError� HTTPError�ContentTooShortError)�urlparse�urlsplit�urljoin�unwrap�quote�unquote� splittype� splithost� splitport� splituser�splitpasswd� splitattr� splitquery� splitvalue�splittag�to_bytes�unquote_to_bytes� urlunparse)� addinfourl�addclosehookFT�Request�OpenerDirector�BaseHandler�HTTPDefaultErrorHandler�HTTPRedirectHandler�HTTPCookieProcessor�ProxyHandler�HTTPPasswordMgr�HTTPPasswordMgrWithDefaultRealm�HTTPPasswordMgrWithPriorAuth�AbstractBasicAuthHandler�HTTPBasicAuthHandler�ProxyBasicAuthHandler�AbstractDigestAuthHandler�HTTPDigestAuthHandler�ProxyDigestAuthHandler�HTTPHandler�FileHandler� FTPHandler�CacheFTPHandler�DataHandler�UnknownHandler�HTTPErrorProcessor�urlopen�install_opener�build_opener�pathname2url�url2pathname� getproxies�urlretrieve� urlcleanup� URLopener�FancyURLopenerz%d.%d� )�cafile�capath� cadefault�contextc C s� |s|s|rfddl }|jdtd� |dk r2td��ts>td��tjtjj||d�}t |d�}t |�} n0|r~t |d�}t |�} ntdkr�t � a} nt} | j| ||�S ) a$ Open the URL url, which can be either a string or a Request object. *data* must be an object specifying additional data to be sent to the server, or None if no such data is needed. See Request for details. urllib.request module uses HTTP/1.1 and includes a "Connection:close" header in its HTTP requests. The optional *timeout* parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used). This only works for HTTP, HTTPS and FTP connections. If *context* is specified, it must be a ssl.SSLContext instance describing the various SSL options. See HTTPSConnection for more details. The optional *cafile* and *capath* parameters specify a set of trusted CA certificates for HTTPS requests. cafile should point to a single file containing a bundle of CA certificates, whereas capath should point to a directory of hashed certificate files. More information can be found in ssl.SSLContext.load_verify_locations(). The *cadefault* parameter is ignored. This function always returns an object which can work as a context manager and has methods such as * geturl() - return the URL of the resource retrieved, commonly used to determine if a redirect was followed * info() - return the meta-information of the page, such as headers, in the form of an email.message_from_string() instance (see Quick Reference to HTTP Headers) * getcode() - return the HTTP status code of the response. Raises URLError on errors. For HTTP and HTTPS URLs, this function returns a http.client.HTTPResponse object slightly modified. In addition to the three new methods above, the msg attribute contains the same information as the reason attribute --- the reason phrase returned by the server --- instead of the response headers as it is specified in the documentation for HTTPResponse. For FTP, file, and data URLs and requests explicitly handled by legacy URLopener and FancyURLopener classes, this function returns a urllib.response.addinfourl object. Note that None may be returned if no handler handles the request (though the default installed global OpenerDirector uses UnknownHandler to ensure this never happens). In addition, if proxy settings are detected (for example, when a *_proxy environment variable like http_proxy is set), ProxyHandler is default installed and makes sure the requests are handled through the proxy. r NzJcafile, capath and cadefault are deprecated, use a custom context instead.r: zDYou can't pass both context and any of cafile, capath, and cadefaultzSSL support not available)r; r<