cURL / Mailing Lists / curl-library / Single Mail


Wrong http request size calculation when uploading /proc/cpuinfo

From: Florian Pritz <>
Date: Thu, 09 Aug 2012 21:06:58 +0200


When using curl to upload files to a pastebin, I noticed that `curl -v
-F "file=@/proc/cpuinfo" http://...` will send an http request stating
that the file is empty, but it reads the contents anyway and the server
(apache in my case) returns "400 Bad Request" because it didn't expect
the content.

AFAICT the problem is that stat() on files like this returns 0 in
st_size and AddFormData() doesn't handle this case in any special way.

Right now I'm using this code[1] to work around the problem. Basically I
just load the file into memory in case st_size is 0 and pass it as

I hope this is enough for someone with more knowledge about libcurl
internals to fix this properly.


Florian Pritz

List admin:

Received on 2012-08-09