Our use case senario is like this:

  1. We have a server that receives browser requests.

  2. For each browser request, we have to send them to mulitple remote servers (about 10~20 of them), by using HttpClient

  3. When all of the remote servers sends a reply back, or a timeout occurs, we need to put together the replies we get so far, and do some computation on them.

  4. a response is generated by the computation and send back to the browser.

In step 3, if the timeout occurs before all replies are sent back, those that are not back should be ignored, or better aborted.

The remote servers are fairly stable, so we'd like to make an HttpClient for each of them.

For each browser request, all HttpClients are used to send a client request.

But looking at httpClient sample code:

auto res = requestHttp("http://google.com", (req){/* could e.g. add headers here before sending*/});
logInfo("Response: %s", res.bodyReader.readAllUtf8());

I have no idea of how I could write the logic of 'Whoever comes first will be served and those later than the timeout will be aborted'.

Could you shed some light on that, Sönke?

Thanks :-)