title: translating prototypejs ajax request to libcurl in C++
body: <p>I have an ajax request in prototype js that basically goes like this:  </p>
  
  <pre><code>new Ajax.Request("http://www.example.com", {
      method: 'post',
      postBody: '{"params":{"first":"one", "second":"two"}}',
      contentType: 'text/json'  
      requestHeaders: {  
          'Content-Length': 42  
      }  
      onComplete: function() {}  
  });
  </code></pre>
  
  <p>I tried doing this in libcurl like so:</p>
  
  <pre><code>struct curl_slist *slist = NULL;
  slist = curl_slist_append(slist, "Content-Type: text/json");
  curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com");
  curl_easy_setopt(curl, CURLOPT_HEADER, slist);
  curl_easy_setopt(curl, CURLOPT_POST, 1);
  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 42);
  curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, "{\"params\":{\"first\":\"one\", \"second\":\"two\"}}");
  </code></pre>
  
  <p>But on the server side it doesn't recognize the post body as it does with the prototype implementation.</p>
  
  <p>I haven't been able to make any progress on this, so I'm hoping someone here can provide the insight I need to continue. Thanks!</p>