如何将 http 状态代码直接获取到 cURL 库中的变量中?

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

我知道 curl_easy_getinfo 函数可用于获取 http 状态代码。无论如何设置一个变量(curl_easy_setopt)并在执行请求后直接从中读取值?

不,你用curl_easy_getinfo() to extract information from the previous transfer. Even for HTTP response codes: CURLINFO_RESPONSE_CODE