[libcurl] post data 전송
1. crul post data보내는 방법
- 전체 코드는 sameple프로그램을 보자.
- post데이터 전송시 data 크기를 지정해 주지 않을경우 data부분은 strlen으로 계산 하여 보낸다.
- post데이터 전송시 data 크기를 지정해 주었을경우 지정하 크기만큼 본낸다.
이를 이용하여 post data부분에 구조체 정보를 담아 보낼수 있다.
if(curl){
curl_easy_setopt(curl, CURLOPT_URL, send_query);
}
if( dsize > 0 ){ //dsize는 보낼 post data의 크기
/* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_POST,1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, dsize);//post 데이터의 크기를 지정
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,data);
}
2. curl sample코드 정리 사이트
- get sample
https://curl.haxx.se/libcurl/c/https.html
- post sample
https://curl.haxx.se/libcurl/c/http-post.html
- curl sample코드 정리 사이트
https://curl.haxx.se/libcurl/c/example.html