curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

curl --data slow with big file

From: Gilles Vollant via curl-library <curl-library_at_cool.haxx.se>
Date: Thu, 12 Sep 2019 08:17:50 +0200

 

Hello,

The option curl -data (or -d) is slow with big file

 

Example of command

curl -H "Content-Type: application/json; charset=utf-8" -X POST
http://127.0.0.1:8080/ -o res_req.json -d @req.json

 

With a 100 MB file req.json file

 

In src/tool_getparam.c (line 1418 in curl 7.66.0), the function file2string
is called

And in src/tool_paramhlp.c, the function file2string does very often realloc

 

For me, the option is using --data-binary wich uses file2memory, calling
less realloc and far faster for big file.

 

But I suppose a lot of user don't know this is better and uses -d / --data
just because the file is a text file.

 

So I suggest modifying file2string to call realloc less often, like
file2memory.

 

Regards

Gilles Vollant

 

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-09-12