-1

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

asked Mar 2, 2020 at 4:57
7
  • This was discussed on SO, perhaps you can check that out. Commented Mar 2, 2020 at 8:35
  • thanks that's about right, I think the answer is unclear though, you can stream the response body not just the response headers Commented Mar 2, 2020 at 10:08
  • I'm not sure what you're aiming for here, I think you need to clarify the question a bit more, is there a specific reason why you'd want to 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. Commented Mar 2, 2020 at 10:20
  • I want to send a header 30 seconds before I send other headers + body. by send header, I mean I want the client to receive that header 30 seconds before any trailing headers + body. Commented Mar 2, 2020 at 11:52
  • 1
    Don't send a preliminary response. You don't know what to send yet. You are just a proxy. If you are worried about timeout, simply make the client send the request with a longer timeout window. If you are worried about confirmation that the request was received, TCP is already doing that, it has already sent an 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. Commented Mar 3, 2020 at 0:12

1 Answer 1

0

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.

answered Mar 2, 2020 at 8:46
5
  • not really, I believe you can write headers, wait 30 seconds, then write some more headers, and it will stream Commented Mar 2, 2020 at 9:42
  • stackoverflow.com/questions/53231492/… Commented 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. Commented 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. Commented Mar 2, 2020 at 10:16
  • see updated OP including this Q: gist.github.com/ORESoftware/97d12e44af1fd7706468fff2eeb2add6 Commented Mar 2, 2020 at 18:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.