cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

Put request with postfields libcurl c++

From: Zaid Amir <z.alamir_at_genie-soft.com>
Date: Mon, 2 Nov 2009 09:26:56 +0200

Hi

 

I am somewhat new to libcurl and I was recently faced with a problem that I
hope someone can have the answer to it. My problem is that I'm supposed to
send a PUT request to a website and that request should also include an XML
as raw data. The problem is I can't seem to be able to configure my read
callback to read from a string if that is actually how its done. Basically
I'm trying to send this request to Amazon S3 to enable their new versioning
feature, and as described by Amazon, I am supposed to do something like
this:

 

PUT /?versioning HTTP/1.1

Host: bucket.s3.amazonaws.com

Date: Wed, 12 Oct 2009 17:50:00 GMT

Authorization: AWS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE=

Content-Type: text/plain

Content-Length: 124

 

<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">

   <Versioning>true</Versioning>

</VersioningConfiguration>

 

 

Now the first part of the request is straight forward and I don't really
have any problem with it; the xml data part however is giving me nightmares
as I have tried almost everything to make it work, I even tried adding it
manually via the HTTPHEADER and it did not work.

 

And as I mentioned above, I tried reading the data directly from a string
although I don't think it's the right approach but still here is my
READFUNCTION:

 

size_t readTextCallback(void* ptr,size_t size, size_t nmemb, void* stream)

{

      #ifdef _DEBUG

            cout << "read_data being called" << endl;

      #endif

      string* strptrdst = static_cast<string*>(ptr);

      strptrdst = static_cast<string*>(stream);

      return nmemb*size;

}

 

Now for some reason, when I use a read function Curl keeps calling the
function until the request gets terminated by the remote host.

 

Can someone please help..

 

Regards

 

 

cid:image001.jpg_at_01CA35ED.DA0878B0

Zaid Al-Amir

C++ Software Developer

...........................................

Email: z.alamir_at_genie-soft.com

Web: <http://www.genie-soft.com/> www.genie-soft.com

cid:image002.jpg@01CA35ED.DA0878B0 http://www.linkedin.com/in/zaidamir

 

 

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

image001.jpg image002.jpg
Received on 2009-11-02

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET