pistacheio / pistache

A high-performance REST toolkit written in C++
https://pistacheio.github.io/pistache/
Apache License 2.0
3.12k stars 690 forks source link

Sending multiple responses to a single request #1110

Open sorinluc opened 1 year ago

sorinluc commented 1 year ago

Hello !

This question might be as related to HTTP as it is to Pistache itself but here we are : Some operations performed by our server (built with Pistache :heart:) are long (several minutes before completion), so they trigger a client-side timeout.

I came across the 102 PROCESSING status code, that might be used to indicate "wait a bit more", but I am not sure it can be used with Pistache as following:

void onRequest(const Http::Request& request, Http::ResponseWriter response) {
    sleep(2);  // simulate long task
    response.send(Http::Code::Processing);
    sleep(2);  // a bit more of that long task
    response.send(Http::Code::Ok);
}

This produces the following TCP trace: image

2 remarks:

I, honestly, cannot point at the culprit :

Thanks for the hard work on the library by the way !