#1 2022-04-13 04:07:19

assistant
Member
Registered: 2022-04-12
Posts: 4

Is it possible to respond outside OnRequest event for THttpApiServer?

Hi all,
I used a THttpApiServer to build an http server.
In most of demos, we write Ctxt.OutContent to respond within OnRequest event handle.
But now, I would like to do something like these steps:
1. Exit OnRequest event handle (of cause taking some needed params of this Ctxt).
2. Do something that will take a long time, and prepare something to be responded. (e.g. ask for data from another server)
3. Respond something via the Ctxt.

Is it possible?
(As I knew, ICS is able to do these things, of cause ICS is a single thread component)

Thanks
Regards

Last edited by assistant (2022-04-13 04:23:22)

Offline

#2 2022-04-13 07:03:19

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Is it possible to respond outside OnRequest event for THttpApiServer?

No, it is not possible: THttpApiServer.Execute has its own loop running the pending requests in a raw.
You could increase the number of threads.

Anyway, I would switch to polling or WebSockets if the request is blocking for a long time.

Offline

#3 2022-04-13 07:34:10

assistant
Member
Registered: 2022-04-12
Posts: 4

Re: Is it possible to respond outside OnRequest event for THttpApiServer?

Hi Administrator,
I got your point.
Thanks
Regards

Offline

Board footer

Powered by FluxBB