title: c libcurl POST doesn't work consistently
body: <p>I am trying to POST xml data from a c program using libcurl to a website.  When I use the command line program in linux, curl like this it works fine:</p>
  
  <p>curl -X POST -H 'Content-type: text/xml' -d 'my xml data' <a href="http://test.com/test.php" rel="nofollow">http://test.com/test.php</a></p>
  
  <p>(I changed the actual data for security)</p>
  
  <p>But as soon as I try to write c code using libcurl, it fails almost every time but succeeds every once in a while.  Here is my c code:</p>
  
  <pre><code>CURL *curl;
  CURLcode res;
  
  curl = curl_easy_init();
  
  if(curl)
  {
      curl_easy_init(curl, CURLOPT_URL, "http://test.com/test.php");
      curl_easy_setopt(curl, CURLOPT_POSTFIELDS, xmlString.c_str());
      curl_easy_perform(curl);
  }
  
  curl_easy_cleanup(curl);
  </code></pre>
  
  <p>I have this code in a loop that runs about every 10 seconds and it will only succeed about every 4 or 5 calls.  I get back errors from the server that say "XML Head not found".</p>
  
  <p>I tried specifying the HTTP header with:</p>
  
  <pre><code>struct curl_slist *chunk = NULL
  chunk = curl_slist_append(chunk, "Content-type: text/xml");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
  </code></pre>
  
  <p>But I didn't have any luck.  Any ideas?</p>