Send updates about the state of a running HTTP request to the client
I would like to send updates of a running HTTP request to the client to tell it at what stage the request-triggered process currently is.
The process behind the request does currently the following things (in this order):
- Client sends an HTTP Request (upload of a file) to the server
- Takes the uploaded file
- Encrypt it
- Upload it to an archive storage
- Return response to the client (Meanwhile, the client does not know what currently happens)
- Get response and show it to the user
I want to tell the client at what stage the process is, like “Uploading done. Encrypting…” and so on.
Is there a way to realize that, or am I missing something? Is it even possible to do?
Frameworks I'm using:
- Client: Next.js
- Server: Hapi.dev for API development
You can send non-final 1xx header responses for your http request as described here.