2013-03-31 43 views
1

我已經編寫了一個HTTP客戶端程序。我從另一個進程獲取數據並將其添加到請求的POST字段中。但是libcurl使用內容類型爲application/x-www-form-urlencoded。 但我只想將內容類型更改爲binary,我應該如何更改只有content-type而不需要手動更改其他字段,如內容長度,代理等等。更改libcurl中HTTP請求中的單個頭字段

   curl_global_init(CURL_GLOBAL_ALL); 
       curl = curl_easy_init(); 
       curl_easy_setopt(curl, CURLOPT_URL, shell_machine); //shell_machine is xxx.xx.xx.xx:8080/xxx 
       curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buf); // buf is my post data 
       curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, post_size); // size of my        post data 

       curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0"); 

       res = curl_easy_perform(curl); 

回答