curl-library
Wrong http request size calculation when uploading /proc/cpuinfo
Date: Thu, 09 Aug 2012 21:06:58 +0200
Hi,
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
CURLFORM_BUFFER{,PTR} instead of CURLFORM_FILE.
I hope this is enough for someone with more knowledge about libcurl
internals to fix this properly.
[1]: http://git.server-speed.net/users/flo/fb/tree/fb-helper.c?h=master#n270
-- Florian Pritz
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
- application/pgp-signature attachment: OpenPGP digital signature