cURL / Mailing Lists / curl-library / Single Mail


Sending Large file using HTTPPOST fails with error CURLE_SEND_ERROR

From: chandrakant gupta <>
Date: Thu, 9 Jul 2009 18:08:13 +0530

Sorry for if i am posting at wrong place.

I am using HTTPPOST with Callback to post files via
HTTPS. It works great for any file up to a certain size (haven't spent
the time to narrow it down exactly). But a file of 5 mb posted
fine, and a file of 10mytes fails with error code 55

here is my code

if (m_pcurl)
  struct curl_httppost* post = NULL;
  struct curl_httppost* last = NULL;
  struct curl_slist *headerlist=NULL;
  static const char buf[] = "Expect:";

  HANDLE fp = NULL ;
  if( (fp = fopen( Filepath ,"rb")) != NULL )
   EC_LOG( TestMessageFile, (LPTSTR)(_T(Filepath)), result) ;
   struct _finddata_t c_file ;
      long hFind;

      if( (hFind = _findfirst( Filepath, &c_file )) != -1L )
    _findclose( hFind ) ;

   _snprintf( Url,sizeof(Url)-1, "%s&file_size=%d", URL, c_file.size ) ;
   curl_easy_setopt(m_pcurl, CURLOPT_URL, Url);
   EC_LOG( TestMessageFile, (LPTSTR)(_T(Url)), result) ;
   curl_easy_setopt(m_pcurl, CURLOPT_PORT, ENS_COMM_PORT);
   curl_easy_setopt(m_pcurl,CURLOPT_SSL_VERIFYPEER, 0 );
   curl_easy_setopt(m_pcurl, CURLOPT_SSL_VERIFYHOST, 0);

   if( m_IsProxyEnabled != 0 )

   headerlist = curl_slist_append(headerlist, buf);
   curl_easy_setopt(m_pcurl, CURLOPT_HTTPHEADER, headerlist);

   CURLFORMcode result3;
   result3 = curl_formadd(&post, &last, CURLFORM_COPYNAME, "uploadedfile",
     CURLFORM_FILENAME, filename,
     //CURLFORM_CONTENTTYPE, "application/octet-stream"

   curl_easy_setopt(m_pcurl, CURLOPT_READFUNCTION, read_callback);

   curl_easy_setopt(m_pcurl, CURLOPT_HTTPPOST, post);

   EC_LOG( TestMessageFile, (LPTSTR)(_T("c_file.size:")), c_file.size) ;
   EC_LOG( TestMessageFile, (LPTSTR)(_T("before easy perform")), result) ;
   result = curl_easy_perform(m_pcurl);

   EC_LOG( TestMessageFile, (LPTSTR)(_T("Upload Result:")), result) ;
   result = curl_easy_getinfo(m_pcurl, CURLINFO_HTTP_CONNECTCODE ,
   result = curl_easy_getinfo(m_pcurl, CURLINFO_RESPONSE_CODE ,
   result = curl_easy_getinfo(m_pcurl, CURLINFO_SIZE_UPLOAD ,

   EC_LOG( TestMessageFile, (LPTSTR)(_T("HttpConnectResponse:")),
HttpConnectResponse) ;
   EC_LOG( TestMessageFile, (LPTSTR)(_T("HttpResponse:")), HttpResponse) ;
   EC_LOG( TestMessageFile, (LPTSTR)(_T("TotalUploadSize:")),
TotalUploadSize) ;

   curl_slist_free_all (headerlist);


Please Help if any. what is happening is it a buffer issue or something
else.Sometime it works and sometime fails.

Received on 2009-07-09