Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/requests_toolbelt/utils/ |
| [Home] [System Details] [Kill Me] |
�
ӵ Yc@s�dZddlZddlmZdZidd6dd 6d
d6Zejdd
dg�Zdefd��YZd�Z d�Z
d�Zdd�Z
d�Zd�Zdddd�Zddd�ZdS(sGThis module
provides functions for dumping information about
responses.i����N(tcompatt
dump_responsetdump_alls0.9i s1.0i
s1.1itPrefixSettingstrequesttresponsecBseZd�ZRS(cCs4t|�}t|�}tt|�j|||�S(N(t_coerce_to_bytestsuperRt__new__(tclsRR((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyRs(t__name__t
__module__R(((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyRscCsUt|jdt�rQi}|jj}|jd�rCd|d<n||d<|SdS(Nt
proxy_managershttps://tCONNECTtmethodtrequest_path(tgetattrt
connectiontFalseRturlt
startswithtNone(Rt
proxy_infotrequest_url((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyt_get_proxy_informations
cCst|�dt|�dS(Ns: s
(R(tnametvalue((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyt_format_header&scCsptj|�}|jd�}|dk r4||fSt|j�}|jrf|dt|j�7}n||fS(NRt?(RturlparsetgetRRtpathtquery(RRturit proxy_urlR((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyt_build_request_path+s
cCsU|dkri}n|j}t|jd|j��}t|j|�\}}|j||d|d�|jj �}t|jd|j
��} |j|d| d�x4|j�D]&\}
}|j|t|
|��q�W|j|d�|j
rDt|j
tj�r4|j|t|j
��qD|jd�n|jd�dS(NRt
s HTTP/1.1
tHostsHost: s
s,<< Request body is not a string-like type
>>(RRRtpopRR#RtextendtheaderstcopytnetloctitemsRtbodyt
isinstanceRt
basestring(RtprefixestbytearrRtprefixRRR!R(thost_headerRR((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyt_dump_request_data8s" c Cs�|j}|j}tj|jd�}|j|d|dt|j�jd�dt |j
�d�|j}xH|j�D]:}x1|j
|�D]
}|j|t||��q�Wq�W|j|d�|j|j�dS(NRsHTTP/R$tasciis
(Rtrawt
HTTP_VERSIONSRtversionR'tstrtstatustencodeRtreasonR(tkeystgetlistRtcontent( RR/R0R1R5tversion_strR(RR((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyt_dump_response_dataVs > "cCs5t|t�r1t|d�r1|jd�}n|S(NR:sutf-8(R-tbytesthasattrR:(tdata((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyRmss<
s>
cCs�|dk r|nt�}t||�}t|d�sHtd��nt|�}t|j||d|�t|||�|S(sDump
a single request-response cycle's information.
This will take a response object and dump only the data that requests
can
see for that single request-response cycle.
Example::
import requests
from requests_toolbelt.utils import dump
resp =
requests.get('https://api.github.com/users/sigmavirus24')
data = dump.dump_response(resp)
print(data.decode('utf-8'))
:param response:
The response to format
:type response: :class:`requests.Response`
:param request_prefix: (*optional*)
Bytes to prefix each line of the request data
:type request_prefix: :class:`bytes`
:param response_prefix: (*optional*)
Bytes to prefix each line of the response data
:type response_prefix: :class:`bytes`
:param data_array: (*optional*)
Bytearray to which we append the request-response cycle data
:type data_array: :class:`bytearray`
:returns: Formatted bytes of request and response information.
:rtype: :class:`bytearray`
Rs"Response has no associated requestRN( Rt bytearrayRRBt
ValueErrorRR3RR@(Rtrequest_prefixtresponse_prefixt
data_arrayRCR/R((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyRsscCsNt�}t|j�}|j|�x!|D]}t||||�q-W|S(s�Dump
all requests and responses including redirects.
This takes the response returned by requests and will dump all
request-response pairs in the redirect history in order followed by the
final request-response.
Example::
import requests
from requests_toolbelt.utils import dump
resp = requests.get('https://httpbin.org/redirect/5')
data = dump.dump_all(resp)
print(data.decode('utf-8'))
:param response:
The response to format
:type response: :class:`requests.Response`
:param request_prefix: (*optional*)
Bytes to prefix each line of the request data
:type request_prefix: :class:`bytes`
:param response_prefix: (*optional*)
Bytes to prefix each line of the response data
:type response_prefix: :class:`bytes`
:returns: Formatted bytes of request and response information.
:rtype: :class:`bytearray`
(RDtlistthistorytappendR(RRFRGRCRJ((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyR�s
(s
dump_responsesdump_all(t__doc__tcollectionstrequestsRt__all__R6t
namedtuplet_PrefixSettingsRRRR#RR3R@RRR(((s@/usr/lib/python2.7/site-packages/requests_toolbelt/utils/dump.pyt<module>s&
+