在编译库之前,我已经开始使用cURL库。我发送请求,并有一些问题。我使用cURL工作的代码:cURL请求已更改
CURL *curl=NULL;
CURLcode res;
struct curl_slist *headers=NULL; // init to NULL is important
curl_slist_append(headers, "POST /oauth/authorize HTTP/1.1");
curl_slist_append(headers, "Host: sp-money.yandex.ru");
curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
curl_slist_append(headers, "charset: UTF-8");
curl_slist_append(headers, "Content-Length: 12345");
curl = curl_easy_init();
if(!curl)
return 0;
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, "sp-money.yandex.ru");
curl_easy_setopt(curl, CURLOPT_PROXY, "127.0.0.1:8888");
if(curl_easy_perform(curl)!=CURLE_OK)
return 1;
我已经使用proxy,fiddler2来检查发送到服务器的数据。当我检查发送的数据 我得到的结果:
POST HTTP://sp-money.yandex.ru/ HTTP/1.1
Host: sp-money.yandex.ru
Accept: */*
Connection: Keep-Alive
Content-Length: 151
Content-Type: application/x-www-form-urlencoded
也是我使用Wiresharck,导致相同的检查这个数据。
你知道为什么在第一线卷曲写道:
POST HTTP://sp-money.yandex.ru/ HTTP/1.1
我送
POST /oauth/authorize HTTP/1.1
我使用VS 2010的工作,也是我不使用框架
+1我的发现也很遗憾没有经历过卷曲 – sehe
我不是一个libcurl大师,不会说我有经验,但是我碰巧用它了一下:) –