Menu

#733 HTTP POST hangs on zero-sized file upload.

closed-works-for-me
libcurl (356)
5
2013-06-21
2008-03-31
No

Hello All,

The following is the function which I am using to uplaod a file to my web server. If I try to upload a zero-sized file, it hangs. So, I manually verified the file size then it works. Please check.

Thanks and Regards,
Bala

void upload_file (char *filename)
{
CURL *curl;
CURLcode res;
struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
struct curl_slist *headerlist=NULL;
static const char buf[] = "Expect:";
// struct stat buffer;
// stat(filename, &buffer);
// if(buffer.st_size>0)
{
curl_global_init(CURL_GLOBAL_ALL);
curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "filename", CURLFORM_FILE, filename, CURLFORM_END);
curl = curl_easy_init();
headerlist = curl_slist_append(headerlist, buf);
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://10.40.10.217/racs/upload.cgi");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
curl_formfree(formpost);
curl_slist_free_all (headerlist);
}
}
}

Discussion

  • Daniel Stenberg

    Daniel Stenberg - 2008-04-01

    Logged In: YES
    user_id=1110
    Originator: NO

    Sorry, but I don't think this is the client-side hanging, it seems to be your server.

    I tried this code against both my Apache localhost and curl's test suite server, and it worked fine against both. Then I tried a command line curl like "curl -Ffoo=@zerobytes [URL]" on both servers and they too worked fine.

     
  • Daniel Stenberg

    Daniel Stenberg - 2008-04-01
    • status: open --> pending-works-for-me
     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending-works-for-me --> closed-works-for-me
     
MongoDB Logo MongoDB