cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Wrong http request size calculation when uploading /proc/cpuinfo

From: Florian Pritz <bluewind_at_xinu.at>
Date: Thu, 09 Aug 2012 23:13:13 +0200

On 09.08.2012 22:50, Daniel Stenberg wrote:
> On Thu, 9 Aug 2012, Florian Pritz wrote:
>
>> 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.
>> [..]
>> I hope this is enough for someone with more knowledge about libcurl
>> internals to fix this properly.
>
> Sorry, but what exactly would a "proper" fix be to this problem you think?

So far I have only seen this happen for files read from some pseudo file
system like /proc and those tend to be small.

I think you could load the file into ram and add a (configurable) upper
limit. The default could be something like 50MiB. The user can increase
as they see fit and 0 could mean "unlimited". If you hit the limit you
throw an error.

It won't be perfect, but at least the error will give users a clue about
what's going on.

-- 
Florian Pritz

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2012-08-09