cURL / Mailing Lists / curl-library / Single Mail

curl-library

Content-Lenght in HTTP Header

From: Roberto Curti <roberto.curti_at_libero.it>
Date: Tue, 14 Nov 2006 18:14:36 +0100

Hi all,

i have the following problem :
The deamon receiver server (it’s not a webServer) receives exactly this HTTP Header:
POST / HTTP/1.1
SOAPAction: urn:FROM_HOST_TO_NJT/OpCreate
Content-Type: text/xml; charset="utf-8"
Content-Lenght: 491
User-Agent: Java/1.4.1_02
Host: 10.12.193.204:7777
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 491

The Headers are sent correctly (also the body), but you can note that the Content-Length field was sent twice.
This is a problem because the server discards the request.
The Header has to be sent exactly in the format above listed.

Do you have any idea to solve this problem? I’m using the curl version 7.15.1

This is my code:

curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, "http://host:port");
....
headers = curl_slist_append(headers, "POST / HTTP/1.1");
headers = curl_slist_append(headers, "SOAPAction: urn:FROM_HOST_TO_NJT/OpCreate");
headers = curl_slist_append(headers, "Content-Type: text/xml; charset=\"utf-8\"");
headers = curl_slist_append(headers, "Content-Lenght: 300);
headers = curl_slist_append(headers, "User-Agent: Java/1.4.1_02");
headers = curl_slist_append(headers, "Host: 999.999.999.999:1111");
headers = curl_slist_append(headers, "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2");
headers = curl_slist_append(headers, "Connection: keep-alive");
....
curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS,postBuffer);
curl_easy_setopt(curl_handle, CURLOPT_CURLOPT_POSTFIELDSIZE,bufferLenght);
curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
....
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_easy_setopt(curl_handle, CURLOPT_CAINFO, certFile);
curl_easy_setopt(curl_handle, CURLOPT_CAPATH, chCertPath);
curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
….
curl_easy_perform(curl_handle);
curl_slist_free_all(headers);
curl_easy_cleanup(curl_handle);

------------------------------------------------------
Chi punta sull’inglese naturale Wall Street Institute, vince un English Box! Scopri come ritirare i tuoi premi, clicca qui!
http://click.libero.it/wallstreet14nov
Received on 2006-11-14