Send string in PUT request with libcurl

后端 未结 3 1401
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 22:28

My code looks like this:

curl = curl_easy_init();

if (curl) {
    headers = curl_slist_append(headers, client_id_header);
    headers = curl_slist_append(he         


        
3条回答
  •  北海茫月
    2020-12-08 23:01

    CURLOPT_PUT is deprecated, and has been for a while. You should use CURLOPT_UPLOAD.

    For unknown amounts of data with HTTP, you should be using chunked transfer encoding. The CURLOPT_UPLOAD docs say:

    If you use PUT to a HTTP 1.1 server, you can upload data without knowing the size before starting the transfer if you use chunked encoding. You enable this by adding a header like "Transfer-Encoding: chunked" with CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked transfer, you must specify the size.

提交回复
热议问题