Brad Parks Brad Parks - 9 months ago 33
HTTP Question

Can http send a streamed response without it being a "Range" response/request?

Can an http server respond with data bit by bit - without it being in response to a "Range" request?

For example, say I want to continually stream text data back to a client - an almost never ending http stream of textual data, which is received by the client as the result of a single http request.

Can I do this without the client sending me a "Range" request in response to me sending an "Accept-Ranges" header?

And I do see code examples of servers streaming data back to clients, but are those clients expected to have sent a range header?


A range request asks for a specific range of bytes for a resource. It's safe to expect that the request ends in a reasonable time. However nothing stops you from pushing data from the server without closing/ending the connection in a regular request. It just means the request will take a long time and possibly waste resources on the server.

This is sometimes called "long polling", especially when the connection is idle (but still alive) for most of the time, sending data only when something happens on the server. An example would be a web based chat, although websockets would be more suitable than HTTP in these modern times.