cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Regarding the problem I am getting in the HTTP PUT Request usinglibcurl

From: Venkataragavan Vijayakumar, TLS-Chennai <venkataragavan.v_at_hcl.in>
Date: Fri, 28 Mar 2008 14:33:33 +0530

On Thu, 27 Mar 2008, Daniel Stenberg wrote:

>#1 You don't set the size of the input file with CURLOPT_INFILESIZE
>#2 libcurl will continue to call the read callback until it reaches the
end > of the input, which is signaled by the callback returning 0

Yes now I changed my callback to return 0 and also
I set the size of the input string.
But still problem is not solved; only 100 continue response is coming.

But if i not set the file size means, the put request is going to the
server with the content having value null.

Please help me to solve this issue.

The following is the code:

CURL *curl;
CURLcode res;
struct curl_slist *headers=NULL;
const char *data="hi";
curl = curl_easy_init();

if(curl) {

curl_easy_setopt(curl, CURLOPT_URL,
"http://example.com/AUID/users/XUI/list.txt");
headers = curl_slist_append(headers, "Content-Type:
application/xcap-el+xml");
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
curl_easy_setopt(curl, CURLOPT_READDATA, &data);
curl_easy_setopt(curl, CURLOPT_INFILESIZE,(curl_off_t)strlen(data));
curl_easy_setopt(curl, CURLOPT_PUT, 1);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
My read callback function
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void
**userp)
{
ptr = malloc (sizeof (char)* strlen((const char*)userp)+1);
strcpy (ptr, (const char*)userp);
return 0;
}

Thanks and regards,
Venkataragavan v

DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------
Received on 2008-03-28