Search code examples
phpcurlchunked-encodingfsockopen

CURL vs fsockopen chunking


This may seem kind of weird.. but I need to evaluate/parse chunks being sent over HTTP with PHP.

It's of note to say that the HTTP stream may never end. Is there any way I can parse chunks as I get them with CURL?

Or do I have to resort to some home-brewed fsockopen() solution?


Solution

  • Take a look at the option CURLOPT_WRITEFUNCTION. You can define a callback that will be called when there's new data in the response. See the manual.