title: Libcurl error Failed writing received data to disk/application
body: <p>I'm writing a class to create a simple http get request using libcurl2.
  I get back the following error:</p>
  
  <blockquote>
    <p>Libcurl error Failed writing received data to disk/application</p>
  </blockquote>
  
  <p>I'm fairly new to C++, still learning but i'm guessing it has something to do with the Access Modifiers or the scope</p>
  
  <p>I hope someone can help me out, with this.</p>
  
  <p><strong>class HTTPconnection</strong></p>
  
  <pre><code>#include "HTTPconnection.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace httptest;
  
  HTTPconnection::HTTPconnection()
  {
      curl_global_init(CURL_GLOBAL_DEFAULT);
      curl = curl_easy_init();
  }
  
  size_t HTTPconnection::write_callback(char * data, size_t 
  size, size_t nmemb, std::string * writerData)
  {
      if (writerData == NULL)
          return 0;
  
      writerData-&gt;append(data, size*nmemb);
      return size * nmemb;
  }
  
  std::string HTTPconnection::createConnection(const char *url, const char *proxy)
  {
      curl_easy_setopt(HTTPconnection::curl, CURLOPT_URL, url);
  
      curl_easy_setopt(HTTPconnection::curl, CURLOPT_WRITEFUNCTION, &amp;HTTPconnection::write_callback);
      curl_easy_setopt(HTTPconnection::curl, CURLOPT_WRITEDATA, &amp;HTTPconnection::buffer);
  
      res = curl_easy_perform(HTTPconnection::curl);
      std::cout &lt;&lt; curl_easy_strerror(res);
  
      return buffer;
  }
  
  
  HTTPconnection::~HTTPconnection()
  {
      curl_easy_cleanup(curl);
      curl_global_cleanup();
  }
  </code></pre>
  
  <p><strong>HTTPconnection.h</strong></p>
  
  <pre><code>#ifndef HTTPconnection_H
  #define HTTPconnection_H
  
  #include &lt;string&gt;
  #include "libcurl/include/curl/curl.h"
  
  #ifdef _DEBUG
  #pragma comment(lib, "libcurl/lib/libcurl_a_debug.lib")
  #else
  #pragma comment(lib, "libcurl/lib/libcurl_a.lib")
  #endif
  
  
  namespace httptest
  {
      class HTTPconnection
      {
      public:
          //Default Constructor
          HTTPconnection();
          std::string createConnection(const char *url, const char *proxy);
  
          //Destructor
          ~HTTPconnection();
  
      private:
  
          //methods
          size_t write_callback(char *data, size_t size, size_t nmemb, std::string *writerData);
  
          //members
          std::string buffer;
          CURL *curl;
          CURLcode res;
  
      };
  }
  
  #endif // !HTTPconnection_H 
  </code></pre>