场景
<!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><h3>Length Required</h3>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
分析
说明发送的报文中没有携带Content-Length,但是发送的报文中实体其实是0字节的
原因
libcurl库只有在调用curl_easy_setopt(pCurlHandle, CURLOPT_POSTFIELDS, “”);,才会去自动生成Content-Length
解决方案一 手动指定Content-Length pCurlHeadList = curl_slist_append(pCurlHeadList, “Content-length: 0”);
解决方案二 curl_easy_setopt(pCurlHandle, CURLOPT_POSTFIELDS, “”);
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/191798.html