1. CURLOPT_FAILONERROR
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FAILONERROR, long fail);
当http code >= 400时,默认是返回页面。通过这个把fail设置为1,perform执行的请求会是失败。
https://curl.se/libcurl/c/CURLOPT_FAILONERROR.html
CURL *curl = curl_easy_init();
if(curl) {
CURLcode ret;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
ret = curl_easy_perform(curl);
if(ret == CURLE_HTTP_RETURNED_ERROR) {
/* an HTTP response error problem */
}
}
2. 速度限制
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。