cURL / Mailing Lists / curl-library / Single Mail

curl-library

Content-Length Question

From: Jim Birkenseer <jim_at_premediasystems.com>
Date: Mon, 17 Apr 2006 12:34:16 -0700

Hi All,

First off, I'm new to libcurl, and to HTTP, so please forgive me if this is
a silly question. Actually, I hope this is a silly question and someone can
easily answer it for me! ;-)

I have written the code below, and it looks like the Content-Length is being
sent out set to zero. I think the Content-Length should be 4. Why is it
being sent out with a zero length?

My Code:

CURLcode resCode;
CURL *curl = nil;
char errorBuffer[CURL_ERROR_SIZE];
std::string buffer;

curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
curl_easy_setopt(curl, CURLOPT_STDERR, stdout);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_easy_setopt(curl, CURLOPT_URL, fURL.c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "test");
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 4);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
curl_easy_perform(curl);

Debug Message:

* About to connect() to xxx.yyy.com port 80
* Trying ##.##.##.##... * connected
* Connected to xxx.yyy.com (##.##.##.##) port 80
> POST /aaaa/bbbbb.php HTTP/1.0
Host: xxx.yyy.com
Accept: */*
Content-Length: 0
Content-Type: application/x-www-form-urlencoded

Thanks in advance!!

-- Jim
Received on 2006-04-17