Written by

Senior Development Manager at InterSystems Corporation
Question Timothy Leavitt · Mar 10, 2023

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!

Product version: IRIS 2022.3
$ZV: IRIS for Windows (x86-64) 2022.3 (Build 606U) Mon Jan 30 2023 09:12:22 EST

Comments

Timothy Leavitt · Apr 4, 2023

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...

0
Ben Spead  Apr 4, 2023 to Timothy Leavitt

Thank you for circling back on this and sharing your solution Tim :)

0