swiftasynchronousserverbackendkitura

Can I send asynchronous response with Kitura


Is it possible to send a response to the client and do some work on other thread, then send another response to the client, the that work is done?

Current state: until I call next() block in my async callback method, user doesn't get any data. Expected: get first response, then append the second response to the first response. Is it possible? Or it doesn't even make sense?


Solution

  • I don't think the HTTP standard allows for server to respond multiple times per request. Several Stack Overflow answers mention this:

    https://stackoverflow.com/a/2966735

    https://stackoverflow.com/a/31224172

    https://stackoverflow.com/a/29529139

    Your use case sounds more like client-server messaging; I suggest looking into Kitura-Websocket and see if that can solve your issue.