Search code examples
curllibcurlhttp-status

How to get http status code directly into a variable in cURL lib?


I know curl_easy_getinfo function can be used to get the http status code. Is there anyway to set a variable (curl_easy_setopt) and read value directly from it after performing the request?


Solution

  • No, you use curl_easy_getinfo() to extract information from the previous transfer. Even for HTTP response codes: CURLINFO_RESPONSE_CODE.