In php there are lines of code like:
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
I don’t get the exact meaning of it; I assume it is something when set to true means you get the header information along with the response. But it is called against the set methods.
In python’s pycurl library the closest I could get to was pycurl.INFOTYPE_HEADER_OUT. But it throws error when I call it against set methods:
>>> c = pycurl.Curl()
>>> c.setopt(pycurl.INFOTYPE_HEADER_OUT, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pycurl.error: (48, '')
>>> c.getinfo(pycurl.INFOTYPE_HEADER_OUT)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid argument to getinfo
What is the correct python statement I have to type in this case?
This is not a setting, but rather a flag that is used for debugging purposes to print the raw headers that are sent out by the library. To use it you need to define a callback as your
DEBUGFUNCTIONand then process the return type:Here is the relevant bits from the documentation: