Debian Codegraph @

doc/docstrings/multi_setopt.rst

raw
1 setopt(option, value) -> None
2
3 Set curl multi option. Corresponds to `curl_multi_setopt`_ in libcurl.
4
5 *option* specifies which option to set. PycURL defines constants
6 corresponding to ``CURLMOPT_*`` constants in libcurl, except that
7 the ``CURLMOPT_`` prefix is replaced with ``M_`` prefix.
8 For example, ``CURLMOPT_PIPELINING`` is
9 exposed in PycURL as ``pycurl.M_PIPELINING``. For convenience, ``CURLMOPT_*``
10 constants are also exposed on CurlMulti objects::
11
12 import pycurl
13 m = pycurl.CurlMulti()
14 m.setopt(pycurl.M_PIPELINING, 1)
15 # Same as:
16 m.setopt(m.M_PIPELINING, 1)
17
18 *value* specifies the value to set the option to. Different options accept
19 values of different types:
20
21 - Options specified by `curl_multi_setopt`_ as accepting ``1`` or an
22 integer value accept Python integers and booleans::
23
24 m.setopt(pycurl.M_PIPELINING, True)
25 m.setopt(pycurl.M_PIPELINING, 1)
26
27 - ``*FUNCTION`` options accept a function. Supported callbacks are
28 ``CURLMOPT_SOCKETFUNCTION`` and ``CURLMOPT_TIMERFUNCTION``; see the
29 ``SOCKETFUNCTION`` and ``TIMERFUNCTION`` sections of the
30 :ref:`callbacks <callbacks>` page. ``CURLMOPT_SOCKETDATA`` and
31 ``CURLMOPT_TIMERDATA`` are reserved by PycURL (set internally to the
32 ``CurlMulti`` instance) and cannot be set from Python.
33
34 Raises TypeError when the option value is not of a type accepted by the
35 respective option, and pycurl.error exception when libcurl rejects the
36 option or its value.
37
38 .. _curl_multi_setopt: https://curl.haxx.se/libcurl/c/curl_multi_setopt.html