drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.62k stars 1.12k forks source link

Getting chunks of PUT data #1027

Closed siddhya closed 6 months ago

siddhya commented 3 years ago

I am sending large data ~1GB using a PUT request to the drogon server. In my PUT handler I want to received the data as it arrives (instead of waiting for the whole 1GB) and write to a file. How do I do that?

template <> inline Params drogon::fromRequest(const HttpRequest &req) { params.body = req.getBody(); return params; };

an-tao commented 3 years ago

Basically you can't, your controller is called only when complete requests arriving, drogon use the mmap api of files for large request, so large data requests don't occupy memory too much.

siddhya commented 3 years ago

That is too bad since it is causing performance drop. If I have to implement it in drogon any pointers about how to go about it?

an-tao commented 3 years ago

you need to modify the HttpServer class