Corvusoft / restbed

Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.
http://www.corvusoft.co.uk
Other
1.93k stars 377 forks source link

ask for help:: How to send the main body content multiple times? #535

Open gaowanlu opened 2 years ago

gaowanlu commented 2 years ago

For example, if I want to send a file to the client, each time I call the read function, I will read 1024 bytes from the file. How to send it only once without using Bytes, but send it every read. Looking forward to your help.

gaowanlu commented 2 years ago
    session->yield(OK, "8\r\nrestbed \r\n", {{"Transfer-Encoding", "chunked"}}, [](const shared_ptr<Session> session)
                   { session->yield("10\r\nchunked encoding\r\n", [](const shared_ptr<Session> session)
                                    { session->close("0\r\n\r\n"); }); });

Maybe the size of a file is relatively large. Is it possible that a large number of callbacks may cause the stack to be too large? The correct way should be how to use it!