Closed i-am-justin-dick closed 3 years ago
Hi!
I don't see anything wrong with RESTinio's behavior. When you call sleep_for
you block the thread that is using for serving I/O operations related to the request. So RESTinio actually performs write operations only when you return the control by exiting your request handler. More about RESTinio's threading model could be found here.
An example of using RESTinio's chunked_output and timer can be found here.
Ah, thank you for the info. I had looked at the function make_resp_for_large_count()
in the compression example which was using chunked output and it seemed to indicate you could alternate append_chunk()
and flush()
calls. Which I suppose technically you can - the chunks just won't be sent until the end. :)
Anyway, thanks for the clarification and docs. I'll switch to a dispatch model of some kind. Thanks for your great work on this open source project!!!
I am using the test program below and restinio v. 0.6.13. When calling flush on a chunked response builder, and using curl -N as a test client, only the first flush() is honored. The rest of the data isn't actually sent until done() is called. This seems to defeat the purpose of a chunked response. Furthermore, the data sent as part of the final write is garbage, because the original object is out of scope.
The problem seems to be that although the first chunk is sent when flush() is called, restinio is not properly notified that this has completed and continues to believe it is in the middle of a write. That is,
m_write_output_ctx.transmitting()
is always true even when the data has been sent. You can see this behavior in that curl reports the data was received right after the flush(), but the log line[2021-06-15 09:25:19.661] TRACE: [connection:1] outgoing data was sent: 185 bytes
isn't printed until after done() is called.Logs:
CURL Client command: