0

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?

denis631
  • 1,765
  • 3
  • 17
  • 38

2 Answers2

1

Kitura RouterResponse buffers the response till end() is called. So there is not currently a way to do what you want. That may change in future releases of Kitura.

Navneet
  • 81
  • 3
1

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.

Youming Lin
  • 334
  • 2
  • 4