It's already been covered how to get the response code in this question:
Http status code with libcurl?
And how to receive data with a callback here:
My question is about receiving or checking the status inside the callback.
Points to consider:
The callback does not receive the CURL handle by default. That means I don't know if it's safe to call functions like
curl_easy_getinfo()
inside it, if I pass the CURL handle myself.I want the information inside the callback, so it can decide how to operate based on whether the HTTP status code is 200, or something else.
I can't just check after the call to
curl_easy_perform()
because that would defeat the purpose of my callback.The documentation doesn't say anything about the behaviour of calling
curl_easy_*()
functions inside the callback, so at a first guess I think it's unsafe to do.
Do I have any options to do this?
EDIT: The book Everything Curl by Daniel Steinberg says
These information values are designed to be provided after the transfer is completed.
And so I will not be "accepting" my own answer.