lua-http icon indicating copy to clipboard operation
lua-http copied to clipboard

Support `get_next_active_stream` on client connections

Open vavrusa opened this issue 8 years ago • 4 comments

It's a bit cumbersome right now to receive from multiple streams on a same connection, as it basically requires a nested cq for each stream. Not sure what would be ideal interface to this, but I quite liked get_next_incoming_stream() on server connections. It'd be nice to have a similar concept for client connection, a function to retrieve next active stream (receiving chunk or any other event).

vavrusa avatar Oct 29 '17 08:10 vavrusa

get_next_incoming_stream() already works on client connections (where the client connection is a http2 connection, and it will return when you get a pushed stream from the server)

daurnimator avatar Oct 29 '17 08:10 daurnimator

Yes, but that's a different semantics (retrieving new streams). I was thinking about retrieving "activity" on established streams.

vavrusa avatar Oct 29 '17 08:10 vavrusa

I was thinking about retrieving "activity" on established streams.

Hrm, so that would be a :pollfd() on stream objects that would return when a stream was maybe-ready? I think that would work...

daurnimator avatar Oct 29 '17 08:10 daurnimator

I haven't tested it, but I think the simple solution of a :pollfd() on a stream that simply polls the underlying connection would work here? This will result in extraneous wakeups if there are many streams on one connection, but we could leave the optimisation for later?

The question I have is: how do you envision using this? e.g. you poll several streams and want to find the one that has more body to be read? And you are reading these with (e.g.) :get_body_chars(5, 0)?

daurnimator avatar Jun 16 '18 20:06 daurnimator