如何使用libcurl使用摘要式身份validation发布http请求

我正在尝试执行发布请求,我正在尝试使用摘要式身份validation。 使用libcurl ,我设置了选项:

 url_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_easy_setopt(curl_handle, CURLOPT_USERPWD, "user:pdw"); 

在设置所有其他选项(post,url和所有内容)之前。 服务器关闭我的连接,我认为没有摘要。 我只是不知道如何自动获得摘要的挑战 – 响应行为。 如果我将HTTPAUTH设置为CURLAUTH_BASICHTTPAUTH这些东西进行编码 ,我在VERBOSE选项中看到包含authorization = basic的标头。 使用摘要没有标题。

你知道我怎么做,或者你能给我一些例子吗? 我真的到处搜寻。

对于基本的POST请求,您应该:

 curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:pwd"); curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); 

对于多部分POST (也称为multipart/form-data ):

 struct curl_httppost *post; struct curl_httppost *postend; /* setup your POST body with `curl_formadd(&post, &postend, ...)` */ curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:pwd"); curl_easy_setopt(hnd, CURLOPT_HTTPPOST, post); curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); 

专业提示:使用curl命令行工具和--libcurl request.c :它将用于执行相应请求的选项列表输出到此C文件中。