Search code examples
javaspringhttpspring-webfluxspring-webclient

how spring WebClient can receive stream data from spring webflux server that is using http/1.1


I have a spring webFlux server and I haven't activated the SSL for it and it's using HTTP/1.1 for request connection. on the other hand wrote a spring WebClient in another application that calls this server just fine and receive stream data as answer. but the problem is that I have read that http/1.1 protocol is not designed for streaming and it is used for simple request and response connection and for streaming HTTP/2 can be used. I was wondering how spring webclient is receiving stream data over http/1.1 protocol? and is there any other webFlux client that works over http in other programming languages?(other than RSocket that works over TCP, WebSocket and UDP).


Solution

  • When you are looking for streaming and back pressure support , you are right HTTP 2.0 is more suited. Especially if it is for internal communication and you have control over clients, then would strongly suggest to use HTTP 2.0/RSocket mechanisms.

    Coming to the questions In HTTP 1.1, it can be achieved via Chunked Transfer Encoding mechanism (it is a standard mechanism , more details can be looked over the net )

    Chunked transfer encoding is a streaming data transfer mechanism available in version 1.1 of the Hypertext Transfer Protocol (HTTP). In chunked transfer encoding, the data stream is divided into a series of non-overlapping "chunks". The chunks are sent out and received independently of one another. No knowledge of the data stream outside the currently-being-processed chunk is necessary for both the sender and the receiver at any given time.

    Spring Webflux implementation of the HTTP 1.1 would have its nuances in terms of implementation of the mechanism.