0
쿠키를 HTTP 헤더로 설정했습니다.C에서 컬링 요청에 쿠키를 설정하는 방법
.....
CURL *curl;
CURLcode res;
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/x-www-form-urlencoded");
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
headers = curl_slist_append(headers, "charsets: utf-8");
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl,CURLOPT_HTTPHEADER,headers);
curl_easy_setopt(curl, CURLOPT_URL,"http://localhost:9763/addApp.jag");
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,reqbody);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, body_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
curl_easy_setopt(curl, CURLOPT_HEADERDATA,&cookiec);
curl_easy_setopt(curl, CURLOPT_COOKIE,cookie);
res=curl_easy_perform(curl);
......
서버 측에서는 게시 된 데이터를 검색 할 때 null 인 것으로 보입니다. 그러나 실제로 Wireshark에서 확인하면 해당 게시물 데이터가 전송됩니다. 하지만 제거 할 때
curl_easy_setopt(curl, CURLOPT_COOKIE,cookie);
나는 서버 측의 게시물 데이터에 액세스 할 수 있습니다. 내 게시물 요청에 실수를하면 나를 바로 잡으십시오.