Debian Codegraph @

doc/docstrings/curl_getinfo_raw.rst

raw
1 getinfo_raw(option) -> Result
2
3 Extract and return information from a curl session,
4 returning string data as byte strings.
5 Corresponds to `curl_easy_getinfo`_ in libcurl.
6 The ``getinfo_raw`` method should not be called unless
7 ``perform`` has been called and finished.
8
9 *option* is a constant corresponding to one of the
10 ``CURLINFO_*`` constants in libcurl. Most option constant names match
11 the respective ``CURLINFO_*`` constant names with the ``CURLINFO_`` prefix
12 removed, for example ``CURLINFO_CONTENT_TYPE`` is accessible as
13 ``pycurl.CONTENT_TYPE``. Exceptions to this rule are as follows:
14
15 - ``CURLINFO_FILETIME`` is mapped as ``pycurl.INFO_FILETIME``
16 - ``CURLINFO_COOKIELIST`` is mapped as ``pycurl.INFO_COOKIELIST``
17 - ``CURLINFO_CERTINFO`` is mapped as ``pycurl.INFO_CERTINFO``
18 - ``CURLINFO_RTSP_CLIENT_CSEQ`` is mapped as ``pycurl.INFO_RTSP_CLIENT_CSEQ``
19 - ``CURLINFO_RTSP_CSEQ_RECV`` is mapped as ``pycurl.INFO_RTSP_CSEQ_RECV``
20 - ``CURLINFO_RTSP_SERVER_CSEQ`` is mapped as ``pycurl.INFO_RTSP_SERVER_CSEQ``
21 - ``CURLINFO_RTSP_SESSION_ID`` is mapped as ``pycurl.INFO_RTSP_SESSION_ID``
22
23 The type of return value depends on the option, as follows:
24
25 - Options documented by libcurl to return an integer value return a
26 Python ``int``.
27 - Options documented by libcurl to return a floating point value
28 return a Python ``float``.
29 - Options documented by libcurl to return a string value
30 return a Python ``bytes`` instance.
31 The string contains whatever data libcurl returned.
32 Use :ref:`getinfo <getinfo>` to retrieve this data as a Unicode string.
33 - ``SSL_ENGINES`` and ``INFO_COOKIELIST`` return a list of byte strings.
34 The same encoding caveats apply; use :ref:`getinfo <getinfo>` to retrieve the
35 data as a list of potentially Unicode strings.
36 - ``INFO_CERTINFO`` returns a list with one element
37 per certificate in the chain, starting with the leaf; each element is a
38 sequence of *(key, value)* tuples where both ``key`` and ``value`` are
39 byte strings. String encoding caveats apply; use :ref:`getinfo <getinfo>`
40 to retrieve
41 certificate data as potentially Unicode strings.
42
43 Example usage::
44
45 import pycurl
46 c = pycurl.Curl()
47 c.setopt(pycurl.OPT_CERTINFO, 1)
48 c.setopt(pycurl.URL, "https://python.org")
49 c.setopt(pycurl.FOLLOWLOCATION, 1)
50 c.perform()
51 print(c.getinfo_raw(pycurl.HTTP_CODE))
52 # --> 200
53 print(c.getinfo_raw(pycurl.EFFECTIVE_URL))
54 # --> b"https://www.python.org/"
55 certinfo = c.getinfo_raw(pycurl.INFO_CERTINFO)
56 print(certinfo)
57 # --> [((b'Subject', b'C = AU, ST = Some-State, O = PycURL test suite,
58 CN = localhost'), (b'Issuer', b'C = AU, ST = Some-State,
59 O = PycURL test suite, OU = localhost, CN = localhost'),
60 (b'Version', b'0'), ...)]
61
62
63 Raises pycurl.error exception upon failure.
64
65 *Added in version 7.43.0.2.*
66
67 .. _curl_easy_getinfo:
68 https://curl.haxx.se/libcurl/c/curl_easy_getinfo.html