CURL与fsockopen分块 [英] CURL vs fsockopen chunking

查看:81
本文介绍了CURL与fsockopen分块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎有点奇怪。.但我需要评估/解析使用PHP通过HTTP发送的块。

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

值得注意的是,HTTP流可能永远不会结束。我可以通过CURL解析获取它们时的任何方法吗?

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?

还是我不得不求助于一些自制的 fsockopen()解决方案?

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

推荐答案

看看选项 CURLOPT_WRITEFUNCTION 。您可以定义一个回调,当响应中有新数据时将调用该回调。参见手册

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.

这篇关于CURL与fsockopen分块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆