Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Libcurl lesson 9 the adding Mechanism of Content-Length

Shulou Source: shulou.com Published: 2022-06-03 06:29:35 11月23日 Update

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, "")

Tags: Message solution reason only scenario byte entity manual automatic generation analysis generation mechanism Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MySQL vpn Shulou Information Redmi