lua-http
lua-http copied to clipboard
Support `get_next_active_stream` on client connections
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).
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)
Yes, but that's a different semantics (retrieving new streams). I was thinking about retrieving "activity" on established streams.
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...
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)?