I have a proxy server that waits for another server to come online. A client sends a request to the proxy server - is there a way for the proxy server to send a preliminary response to the client to let the client know it has to wait for the other server to come online? Maybe a header that the browser can display?
For example, it seems possible for one header to be sent by the server and received by the client 30 seconds before subsequent headers, but with my testing with Node.js, all the headers are buffered and sent after the first line of the body is written:
https://gist.github.com/ORESoftware/97d12e44af1fd7706468fff2eeb2add6
1 Answer 1
What you are suggesting is Client Request> Server Response> Server Response.
This is an inversion of REST, which is Request> Response.
By that definition you may require a Streaming API.
-
not really, I believe you can write headers, wait 30 seconds, then write some more headers, and it will streamOlegzandr Denman– Olegzandr Denman2020年03月02日 09:42:19 +00:00Commented Mar 2, 2020 at 9:42
-
stackoverflow.com/questions/53231492/…Olegzandr Denman– Olegzandr Denman2020年03月02日 09:43:58 +00:00Commented Mar 2, 2020 at 9:43
-
1@OlegzandrDenman Yes, you can chunk encoding and send headers singularly before the main body, but that is still a single response aggregate (happy to be corrected on that). In the OPs situation that would mean having a full end response with a header value of waiting or something. That felt hacky to me (even though the OP specifically mentioned it), hence my answer.K Mo– K Mo2020年03月02日 10:12:45 +00:00Commented Mar 2, 2020 at 10:12
-
from my brief testing, with "transfer-encoding": chunked, the headers are buffered, but the body is streamed line-by-line. so I guess headers cannot be easily streamed, idk.Olegzandr Denman– Olegzandr Denman2020年03月02日 10:16:59 +00:00Commented Mar 2, 2020 at 10:16
-
see updated OP including this Q: gist.github.com/ORESoftware/97d12e44af1fd7706468fff2eeb2add6Olegzandr Denman– Olegzandr Denman2020年03月02日 18:59:21 +00:00Commented Mar 2, 2020 at 18:59
stream
headers? I think that HTTP/2 is still a relatively solid option, you don't need bidirectional comms so TCP (WS) is not really needed here.ack
. If you are worried about the perception of speed, that is a UI trick, provide an immediate visual "response" to signal processing. If you are worried about total time, instead have a quicker to respond task service. Then allow the task to be monitored at a designated url.