restbed icon indicating copy to clipboard operation
restbed copied to clipboard

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

Open gaowanlu opened this issue 2 years ago • 1 comments

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 avatar Nov 08 '22 19:11 gaowanlu

    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!

gaowanlu avatar Nov 08 '22 19:11 gaowanlu