curl-library
cURL on Windows Xp: "Content-Length Header required" error
Date: Sat, 10 Jan 2009 11:32:44 +0530
Hello,
I am new to cURL and started using it for some project in *Windows Xp*. I'm
using *Visual Studio 2005* for development.
*cURL version:* libcurl-7.15.1-msvc-win32-ssl-0.9.8a-zlib-1.2.3
*Project is : *To upload a video file on YouTube using cURL.
Currently, It's failing in the first phase, that is authentication.
please find the link below from google suggesting the method to do the same.
http://code.google.com/apis/youtube/2.0/developers_guide_protocol_clientlogin.html#Authentication
While executing the curl_perform it come out with an error saying that
"content-length header required" Please find the *error.html file
attached*hereby.
Can some one please let me know how this can be resolved?
*Also find the code that I'm using.* I'm pasting it after my signature at
the end of the mail.
Thanks & Regards,
Tanmay
*CODE:*
======
CURL *curl_handle=NULL;
CURLcode res=0;
char url_string[MAX_PATH] = {0};
curl_handle = curl_easy_init();
strcpy(url_string,"https://www.google.com/youtube/accounts/ClientLogin--data
'Email=testuser&Passwd=testpw&service=youtube&source=Test' --header
'Content-Type:application/x-www-form-urlencoded'");
/* Curl initializations */
res = curl_easy_setopt(curl_handle,CURLOPT_URL,url_string);
// For making sure that SSL related error doesn't come
curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYPEER,FALSE);
res = curl_easy_setopt(curl_handle,CURLOPT_POST,1);
if(res!=0)
{
printf("Error in Curl_easy_setopt");
}
//res = curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS,
"Content-Length: 372");
//if(res!=0)
//{
//printf("Error in Curl_easy_setopt");
//}
//curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION,
WriteHeaderCallback);
//curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, NULL);
//curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION,
WriteDataCallback);
//curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, NULL);
res = curl_easy_perform(curl_handle);
if(res!=0)
{
printf("Error in curl_easy_perform ");
}
- text/html attachment: error.html