Reading a chunked HTTP response in chunks
I'm trying to read the response to a long (indefinitely) running HTTP response with Transfer-Encoding: chunked. Ideally I'd be able to read the individual chunks from the response and do something with them as they arrive rather than needing to wait for the response to finish (because it never will) - ultimately I'm thinking to wrap these back up over a WebSocket connection which seems cleaner from an API perspective.
So far it looks like my options are:
- Extend %Net.HttpRequest, override the Read method, and add support for read of individual chunks from an ongoing request (similar to what is already supported for WebSockets, but also on an HTTP 200 response with Transfer-Encoding: chunked).
- Use TCP and reinvent all the HTTP stuff that %Net.HttpRequest makes "just work"
- Find some existing class in IRIS that does exactly what I want (no luck yet, hence asking here)
Is this a novel problem in ObjectScript? Is there some out-of-the-box support I'm just missing?
Thanks in advance!
Comments
Calling @Chris Munt or @Chris Munt (not sure which is the right handle)
I ended up going with:
"Extend %Net.HttpRequest, override the Read method, and add support for read of individual chunks from an ongoing request (similar to what is already supported for WebSockets, but also on an HTTP 200 response with Transfer-Encoding: chunked)."
Hoping to get my example use case out on the Open Exchange at some point...
Thank you for circling back on this and sharing your solution Tim :)