Libcurl lesson 9 the adding Mechanism of Content-Length
Scene
Length Required
Length Required
HTTP Error 411. The request must be chunked or have a content length.
Analysis.
It indicates that there is no Content-Length in the message sent, but the entity in the message sent is actually 0 bytes.
Reason
The libcurl library automatically generates Content-Length only when curl_easy_setopt (pCurlHandle, CURLOPT_POSTFIELDS, ""); is called.
Solution 1 manually specify Content-Length pCurlHeadList = curl_slist_append (pCurlHeadList, "Content-length: 0")
Solution two curl_easy_setopt (pCurlHandle, CURLOPT_POSTFIELDS, "")