2013-03-31 3 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); 

답변

관련 문제