cURL / Mailing Lists / curl-library / Single Mail


Re: Issue With curl_easy_perform

From: Saikat Kanjilal <>
Date: Tue, 04 Apr 2006 09:00:32 -0700

Hi Daniel:
Thanks for responding, I have a dll that uses CreateProcessW to make a call
to an exe, this exe does an HTTP_POST with libcurl, also I have no code in
libcurl that is writing to stdout, I created a callback function using
CURLOPT_WRITEFUNCTION so that I can read some of the data that the server
sends back. I am attaching the code again here, let me know if the code
below in any case should create a popup window.

extern "C" size_t write_data(void *source,size_t size,size_t nmemb,void
    return size * nmemb;

int Myclass::uploadFile(std::string receiverURL,std::string path,int
    CURL *curl;
    CURLcode res;

    struct curl_httppost *formpost=NULL;
    struct curl_httppost *lastptr=NULL;
    struct curl_slist *headerlist=NULL;
    char buf[] = "Expect:";
    bool delFile = false;
    int numAttemptsToUpload=0;


    /* Fill in the file upload field */
                 CURLFORM_COPYNAME, "sendfile",
         CURLFORM_FILE, path.c_str(),

    /* Fill in the filename field */
                 CURLFORM_COPYNAME, "filename",
         CURLFORM_COPYCONTENTS, path.c_str(),

    /* Fill in the submit field too, even if this is rarely needed */
                 CURLFORM_COPYNAME, "submit",
                 CURLFORM_COPYCONTENTS, "send",

    curl = curl_easy_init();

    /* initalize custom header list (stating that Expect: 100-continue is
       wanted */
    headerlist = curl_slist_append(headerlist, buf);

   /* if we have a handle proceed with the transaction */
          curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);

          /* what URL that receives this POST */
         curl_easy_setopt(curl, CURLOPT_URL, receiverURL.c_str());
         curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
         res = curl_easy_perform(curl);

          /* if we are here we wait
              and try the upload again till we are successful
               for now we set this to 2 minutes
                later it will be configurable
          if ( (numAttempts<=defaultMaxAttempts) && (res!=CURLE_OK) )

          /* cleanup */

         /* then cleanup the formpost chain */

         /* free slist */
         curl_slist_free_all (headerlist);
   return res;

This is the code that gets called from the dll, the dll itself gets put
inside a windows application

Let me know if you see anything obvious

>From: Daniel Stenberg <>
>Reply-To: libcurl development <>
>To: libcurl development <>
>Subject: Re: Issue With curl_easy_perform
>Date: Tue, 4 Apr 2006 10:26:33 +0200 (CEST)
>On Mon, 3 Apr 2006, Saikat Kanjilal wrote:
>>noticed that when I put my dll inside a windows app and call it from there
>>it opens up a command window every time, I am guessing this is for
>>libcurl, is there any way to remove this.
>libcurl certainly has no code that pops up windows. I guess your
>environment is such that it opens a window if your program writes to stdout
>(or similar) and you have code in libcurl callback that does this.
>You could very easily verify this yourself with the use of a debugger.
> Commercial curl and libcurl Technical Support:
Received on 2006-04-04