Bugs item #1930028, was opened at 2008-03-31 11:55
Message generated for change (Settings changed) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1930028&group_id=976
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: libcurl
Group: hang
>Status: Pending
>Resolution: Works For Me
Priority: 5
Private: No
Submitted By: Balakrishnan (balakrishnan84)
Assigned to: Daniel Stenberg (bagder)
Summary: HTTP POST hangs on zero-sized file upload.
Initial Comment:
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);
}
}
}
----------------------------------------------------------------------
>Comment By: Daniel Stenberg (bagder)
Date: 2008-04-01 23:18
Message:
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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1930028&group_id=976
Received on 2008-04-01