cURL / Mailing Lists / curl-library / Single Mail

curl-library

XML libcurl problem

From: Alexander Reich <AReich_at_sysdesign-edv.de>
Date: Tue, 2 Aug 2005 17:29:32 +0200

Hello,

I have a problem to post a xml from a little c-program, using libcurl to a
webserver.

I don't know what I'doing wrong. Here's my source-code:

#include <stdio.h>
#include <curl/curl.h>

int main(void)
{
  CURL *curl;
  CURLcode res;
  struct curl_slist *headerlist = NULL;

  curl = curl_easy_init();
  if(curl) {
    /* First set the URL that is about to receive our POST. This URL can
       just as well be a https:// URL if that is what should receive the
       data. */
    curl_easy_setopt(curl, CURLOPT_URL,
"http://172.30.1.13:8080/ans/status.xml");
    /* Now specify the POST data */

    curl_slist_free_all(headerlist);
    headerlist = curl_slist_append(headerlist, "Content-Type: text/xml");
    curl_easy_setopt(curl, CURLOPT_POST, 1);
    curl_easy_setopt(curl, CURLOPT_HEADER, 1);
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "<?xml version=\"1.0\"
encoding=\"UTF-8\"?><Person>Maier</Person>");

    /* Perform the request, res will get the return code */
    res = curl_easy_perform(curl);

    /* always cleanup */
    curl_easy_cleanup(curl);
  }
  return 0;
}

And here's what my webserver receives:

POST /ans/status.xml HTTP/1.1
Host: 172.30.1.13:8080
Accept: */*
Content-Type: text/xml
Content-Length: 60

Why can't I see the xml-data?

SysDesign - The Solution Behind IT.

Selbst der heißeste Sommer kann uns nicht davon abhalten: Wir sind für Sie da!
Unser Team von hochqualifizierten Hard- und Softwarespezialisten bewahrt einen kühlen Kopf und arbeitet Hand in Hand für die maßgeschneiderten Lösungen unserer Kundschaft.
--------------------------------------------------------------
Even the hottest summer cannot stop us from being at your service.
Our team of highly skilled hard- and software experts will keep cool and cooperate hand in hand for tailor-made customer solutions.
Received on 2005-08-02