1

I have a Zend_Http_Client which connects to a HTTP-Server that streams its data in chunks.

I want to handle each received chunk directly as it is received.

None of the existing Http_Adapter in the Zend Framework seem to not provide a chunk-based-handling.

So far I have tried two different (working) solutions:

  1. Creating my own Http_Client_Adapter with my own read function that includes the handling
  2. Registering my own stream schema (myHandler://) and let the Http_Client write its streaming data directly my handler

… but I would like to stick as close as possible to existing functions.

Therefore is my question:
Is there a Zend-Framework "native" solution with which I can go in a loop to receive chunk-by-chunk or define a user_function to be called with each chunk?

favo
  • 5,426
  • 9
  • 42
  • 61
  • 1
    I feel like you already answered your own question.... – blockhead Jan 21 '12 at 20:37
  • There isn't a native way to do what you want as far as I can see. The socket adapter dechunks chunked responses, but gives you no way to inject a callback, or change the way it processes the chunked data. You will have to create your own adapter which you could probably copy completely from Zend_Http_Client_Adapter_Stream except add in a way to call a user function as it reads each chunk. – drew010 Jan 21 '12 at 20:52
  • @blockhead, I hope not, because that would mean that there is no streaming handling support in the framework at the moment.Both solutions I mentioned feel more like a workaround, not like a solid solution. – favo Jan 21 '12 at 20:54
  • @drew010, thank you for your feedback. Implementing an own adapter is the way I would like to go if there is no built-in-solution. – favo Jan 21 '12 at 20:57
  • [This reference](http://framework.zend.com/manual/en/zend.http.client.advanced.html#zend.http.client.streaming) may be of help to you, but I haven't tried it so I don't know how much HTTP parsing you will end up having to do or if it will even work for what you want. – drew010 Jan 21 '12 at 21:05

0 Answers0