| 1 |
setopt_string(option, value) -> None |
| 2 |
|
| 3 |
Set curl session option to a string value. |
| 4 |
|
| 5 |
This method allows setting string options that are not officially supported |
| 6 |
by PycURL, for example because they did not exist when the version of PycURL |
| 7 |
being used was released. |
| 8 |
:py:meth:`pycurl.Curl.setopt` should be used for setting options that |
| 9 |
PycURL knows about. |
| 10 |
|
| 11 |
**Warning:** No checking is performed that *option* does, in fact, |
| 12 |
expect a string value. Using this method incorrectly can crash the program |
| 13 |
and may lead to a security vulnerability. |
| 14 |
Furthermore, it is on the application to ensure that the *value* object |
| 15 |
does not get garbage collected while libcurl is using it. |
| 16 |
libcurl copies most string options but not all; one option whose value |
| 17 |
is not copied by libcurl is `CURLOPT_POSTFIELDS`_. |
| 18 |
|
| 19 |
*option* would generally need to be given as an integer literal rather than |
| 20 |
a symbolic constant. |
| 21 |
|
| 22 |
*value* can be a binary string or a Unicode string using ASCII code points, |
| 23 |
same as with string options given to PycURL elsewhere. |
| 24 |
|
| 25 |
Example setting URL via ``setopt_string``:: |
| 26 |
|
| 27 |
import pycurl |
| 28 |
c = pycurl.Curl() |
| 29 |
c.setopt_string(10002, "http://www.python.org/") |
| 30 |
|
| 31 |
.. _CURLOPT_POSTFIELDS: https://curl.haxx.se/libcurl/c/CURLOPT_POSTFIELDS.html |