cURL / Mailing Lists / curl-library / Single Mail

curl-library

Regarding the problem I am getting in the HTTP PUT Request using libcurl

From: Venkataragavan Vijayakumar, TLS-Chennai <venkataragavan.v_at_hcl.in>
Date: Thu, 27 Mar 2008 18:55:33 +0530

Hi all,

 

            I am trying to use HTTP PUT in libcurl. The problem is I am
not able to PUT anything into the server. The response I am getting for
this is 100 Continue continuously, may be my call back function I had
written is wrong ,and also while debugging the code ,I observed the
callback is continuously called, I don't know why it is happening like
this may be I am returning wrong thing in the callback.

Please help me to solve this issue.

 

The following are the code I had written for this.

 

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");

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_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 strlen((char*)userp);

}

 

 

Thanks & 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-27