1、返回411
HTTP 411 错误表示客户端发送的请求没有包含必需的 Content-Length 头字段;
解决方案一 手动指定Content-Length pCurlHeadList = curl_slist_append(pCurlHeadList, “Content-length: 0”);
解决方案二 curl_easy_setopt(pCurlHandle, CURLOPT_POSTFIELDS, “”);
在这里我采用第二种,将头和数据进行分离
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
//常规调用
string CMESDLL::postMessageToUrl(string p_strUrlHead , string p_strData)
{
if (p_strUrlHead.size() < 5)
{
return "false , IP地址设置错误";
}
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &CurlWriteCallback);
curl_easy_setopt(curl, CURLOPT_CUST

最低0.47元/天 解锁文章
3万+

被折叠的 条评论
为什么被折叠?



