curl --data slow with big file
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