On Fri, 12 Nov 2010, Matthew McNaughton wrote:

Hello!

I'm having an issue with my read function. The requirement behind the function below is that it needs to take two arguments. The first is a string that contains a SOAP request, while the second is the variable I need to wrt In response I need to write the SOAP response to the variable outStr.

The pointer you pass to your callback can point to anything, so make it point to a struct that you setup that contains whatever you like. See for example how we do it in the getinmemory.c example: http://curl.haxx.se/libcurl/c/getinmemory.html

size_t write_data(void *ptr, size_t size, size_t nmeb, void *stream)
{
   strcat(((char *) stream), ((char *) ptr))

Major bad. The data libcurl sends you is NOT zero terminated so strcat() may copy too much and cause a segfault or just get you junk into the buffer.

   header = curl_slist_append (header, "Transfer-Encoding: chunked");

I advice against setting this header. You're obviously sending data with a known size so that header is not what you want. Unless of course you have some dark secret reason to really want chunked encoding... :-)

--

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

Reply via email to