Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/urllib3/ |
| [Home] [System Details] [Kill Me] |
�
_X�Tc@s�ddlZddlZddlmZddlmZddlmZm Z m
Z
ddlmZ
mZmZddlmZmZddlmZd efd
��YZdefd��YZd
�Zdejfd��YZdS(i����N(ttimeouti(tHTTPHeaderDict(t
ProtocolErrortDecodeErrortReadTimeoutError(tstring_typestbinary_typetPY3(t
HTTPExceptiontBaseSSLError(tis_fp_closedtDeflateDecodercBs#eZd�Zd�Zd�ZRS(cCs(t|_t�|_tj�|_dS(N(tTruet
_first_tryRt_datatzlibt
decompressobjt_obj(tself((s4/usr/lib/python2.7/site-packages/urllib3/response.pyt__init__s cCst|j|�S(N(tgetattrR(Rtname((s4/usr/lib/python2.7/site-packages/urllib3/response.pyt__getattr__scCs�|s
|S|js#|jj|�S|j|7_y|jj|�SWnTtjk
r�t|_tjtj�|_z|j|j�SWdd|_XnXdS(N(
R
Rt
decompressRRterrortFalseRt MAX_WBITStNone(Rtdata((s4/usr/lib/python2.7/site-packages/urllib3/response.pyRs (t__name__t
__module__RRR(((s4/usr/lib/python2.7/site-packages/urllib3/response.pyRs tGzipDecodercBs#eZd�Zd�Zd�ZRS(cCstjdtj�|_dS(Ni(RRRR(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR+scCst|j|�S(N(RR(RR((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR.scCs|s
|S|jj|�S(N(RR(RR((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR1s(RRRRR(((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR)s cCs|dkrt�St�S(Ntgzip(RR(tmode((s4/usr/lib/python2.7/site-packages/urllib3/response.pyt_get_decoder7stHTTPResponsecBseZdZddgZdddddgZddd d dd eedddd
�Zd�Zd�Z e
d
��Zd�Zdde
d�Zddd�Zed��Zd�Zdd�Zd�Ze
d��Zd�Zd�Zd�Zd�ZRS(s�
HTTP Response container.
Backwards-compatible to httplib's HTTPResponse but the response
``body`` is
loaded and decoded on-demand when the ``data`` property is accessed.
This
class is also compatible with the Python standard library's
:mod:`io`
module, and can hence be treated as a readable object in the context of
that
framework.
Extra parameters for behaviour not present in httplib.HTTPResponse:
:param preload_content:
If True, the response's body will be preloaded during
construction.
:param decode_content:
If True, attempts to decode specific content-encoding's based
on headers
(like 'gzip' and 'deflate') will be skipped and
raw data will be used
instead.
:param original_response:
When this HTTPResponse wrapper is generated from an
httplib.HTTPResponse
object, it's convenient to include the original for debug
purposes. It's
otherwise unused.
R
tdeflatei-i.i/i3i4ticCst|t�r||_nt|�|_||_||_||_||_||_d|_ d|_
d|_| |_d|_
|r�t|ttf�r�||_
n|
|_||_t|d�r�||_n|r|j
r|jd|�|_
ndS(Nitreadtdecode_content(t
isinstanceRtheaderststatustversiontreasontstrictR'Rt_decodert_bodyt_fpt_original_responset_fp_bytes_readt
basestringRt_poolt_connectionthasattrR&(RtbodyR)R*R+R,R-tpreload_contentR'toriginal_responsetpoolt
connection((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR[s* cCs&|j|jkr"|jjd�StS(s
Should we redirect and where to?
:returns: Truthy redirect location string if we got a redirect
status
code and valid location. ``None`` if redirect status and no
location. ``False`` if not a redirect status code.
tlocation(R*tREDIRECT_STATUSESR)tgetR(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pytget_redirect_location{scCs8|js|jrdS|jj|j�d|_dS(N(R4R5t _put_connR(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pytrelease_conn�scCs-|jr|jS|jr)|jdt�SdS(Nt
cache_content(R/R0R&R(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR�s cCs|jS(s�
Obtain the number of bytes pulled over the wire so far. May differ
from
the amount of content returned by :meth:``HTTPResponse.read`` if
bytes
are encoded on the wire (e.g, compressed).
(R2(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pyttell�sc Cso|jjdd�j�}|jdkrN||jkrNt|�|_qNn|dkrf|j}n|jdkrydSt }z�yi|dkr�|jj
�}t}nAt }|jj
|�}|dkr�|r�|jj�t}nWn�t
k
rt|jdd��netk
rR}dt|�kr:�nt|jdd��n&tk
rw}td||��nX|jt|�7_y(|r�|jr�|jj|�}nWn/ttjfk
r�}td||��nX|r+|r+|jr+|jjt��}|||jj�7}n|r=||_n|SWd|jrj|jj�rj|j
�nXdS( sP
Similar to :meth:`httplib.HTTPResponse.read`, but with two
additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is
skipped
because it doesn't make sense to cache partial content as
the full
response.
:param decode_content:
If True, will attempt to decode the body based on the
'content-encoding' header.
:param cache_content:
If True, will save the returned data such that the same result
is
returned despite of the state of the underlying file object.
This
is useful if you want the ``.data`` property to continue
working
after having ``.read()`` the file object. (Overridden if
``amt`` is
set.)
scontent-encodingR%NisRead timed out.sread operation timed
outsConnection broken: %rsEReceived response with content-encoding: %s,
but failed to decode
it.(!R)R>tlowerR.RtCONTENT_DECODERSR"R'R0RR&Rtcloset
SocketTimeoutRR4R tstrRRR2tlenRtIOErrorRRRRtflushR/R1tisclosedRA( RtamtR'RBtcontent_encodingt
flush_decoderRtetbuf((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR&�sV
iiccs@x9t|j�s;|jd|d|�}|r|VqqWdS(s_
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed.
:param amt:
How much of the content to read. The generator will return up
to
much data per iteration, but may return less. This is
particularly
likely when using compressed data. However, the empty string
will
never be returned.
:param decode_content:
If True, will attempt to decode the body based on the
'content-encoding' header.
RMR'N(R
R0R&(RRMR'R((s4/usr/lib/python2.7/site-packages/urllib3/response.pytstreamscKs�|j}t|t�sEtr3t|j��}qEtj|�}nt|dd�}|d|d|d|jd|jd|j d|d||�}|S( s
Given an :class:`httplib.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object.
Remaining parameters are passed to the HTTPResponse constructor,
along
with ``original_response=r``.
R-iR7R)R*R+R,R9(
tmsgR(RRtitemstfrom_httplibRR*R+R,(tResponseClstrtresponse_kwR)R-tresp((s4/usr/lib/python2.7/site-packages/urllib3/response.pyRUs cCs|jS(N(R)(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pyt
getheaders3scCs|jj||�S(N(R)R>(RRtdefault((s4/usr/lib/python2.7/site-packages/urllib3/response.pyt getheader6scCs|js|jj�ndS(N(tclosedR0RF(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pyRF:s cCsV|jdkrtSt|jd�r/|jjSt|jd�rN|jj�StSdS(NR]RL(R0RRR6R]RL(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR]>s
cCsM|jdkrtd��n+t|jd�r=|jj�Std��dS(Ns-HTTPResponse
has no file to get a fileno fromtfilenosOThe file-like object this
HTTPResponse is wrapped around has no file
descriptor(R0RRJR6R^(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR^Is
cCs2|jdk r.t|jd�r.|jj�SdS(NRK(R0RR6RK(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pyRKRs!cCstS(N(R(R((s4/usr/lib/python2.7/site-packages/urllib3/response.pytreadableVscCsI|jt|��}t|�dkr+dS||t|�*t|�SdS(Ni(R&RI(Rtbttemp((s4/usr/lib/python2.7/site-packages/urllib3/response.pytreadintoZs
Ni(RRt__doc__RER=RRRR?RAtpropertyRRCRR&RRtclassmethodRURZR\RFR]R^RKR_Rb(((s4/usr/lib/python2.7/site-packages/urllib3/response.pyR#>s*
` (RtiotsocketRRGt_collectionsRt
exceptionsRRRtpackages.sixRR3RRR;RR t
util.responseR
tobjectRRR"tIOBaseR#(((s4/usr/lib/python2.7/site-packages/urllib3/response.pyt<module>s