2

How do popular HTTP servers or frameworks use HTTP protocol to implement asynchronous streams of data from HTTP server to HTTP client? (client could be browser or non-browser)

[client] ----request for data----> [server]

[client] <-------xxx------[server]
[---delay---]
[client] <-------xxxxxx---[server]
[---delay---]
[client] <-------x--------[server]
[---delay---]
[client] <-------xxx------[server]
[---delay---]
[client] <-------xxxx-----[server]

delay can be non deterministic

x is say individual data object that makes sense to server & client.

Just to emphasize, I am not looking for implementation of streams (ex. reactive streams, RxJava etc..), but I would like to know details of how HTTP protocol is used to implement this asynchronous streaming of data (not video streaming, but say, json streaming). For ex, which HTTP headers they use, what kind of connection is used etc.

Jatin
  • 667
  • 8
  • 16

1 Answers1

1

Basically, the HTTP headers of interest here are:

header-name: header-value (comment)

connection: keep-alive (keep the connection open)

transfer-encoding: chunked (data is sent in a series of chunks)

accept: application/stream+json (or other similar streaming media type)

content-type: application/stream+json (or other similar streaming media type)

this information is gathered from observing http traffic between postman/curl and simple spring webflux service.

for complete description of these headers and their values:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers

Jatin
  • 667
  • 8
  • 16