XMPP over BOSH (HTTP long polling) - real time stream interception

I’m dealing with XMPP with slightly unusual transport layer: BOSH (Bidirectional-streams Over Synchronous HTTP), as described in XEP-0124 and [XEP-0206] and I have a question before diving into it.

XML traffic I am going to deal with, has quite long pooling time ( usually over 20 seconds ) but I need to react for some xml patterns as fast as they appear on the wire. Because of that I plan to parse XML incrementally, as described here: lxml: incremental event parsing.

Is it currently possible using mitmproxy?

You can try to use http://docs.mitmproxy.org/en/stable/features/responsestreaming.html#modifying-streamed-data, but I honestly would not recommend it.