Crow icon indicating copy to clipboard operation
Crow copied to clipboard

how to response a large data?

Open sinnren opened this issue 2 years ago • 2 comments

CROW_ROUTE(app, "/data")([&](const crow::request& req, crow::response& res) {

	while (res.is_alive())
	{
		res.write(some_data_);
		res.write(more_data_);

                    if (finished_)
			break;
	}
	//data mayby 5-10GB
	
	res.end();

});

but i find res.write is cached to "body" and send utill res.end() called.

emmm... how to response a large data without cached and send to the socket directly?

sinnren avatar May 16 '23 10:05 sinnren

I believe Crow only does what you want currently with static files. It may be worthwhile to allow Crow to use a reference or pointer to a string as opposed to just a string as a body..

The-EDev avatar May 19 '23 11:05 The-EDev

Unfortunately, until Crow's handlers become asynchronous, allowing the user direct access to the TCP connection is not a good idea...

The-EDev avatar May 19 '23 11:05 The-EDev