限制 libcurl 响应数据
我试图通过设置使用 libcurl 从源获取一些字节数:
curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 100); //get 100 bytes from source
但我每次都会得到不同大小的数据,甚至有时只有 22 个字节。这有用吗?
i'm trying to get some number of bytes from source using libcurl by setting:
curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 100); //get 100 bytes from source
But I get different size of data each time, not even close sometimes only 22 bytes. does this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从文档中:
所以实际上没有任何简单的方法可以立即获得 100 字节。您需要记录收到的字节数,一旦收到 100 字节就停止读取。
From the documentation:
So there isn't really any easy way to get 100 bytes right away. You would need to keep track of how many bytes you have received and just stop reading once you've got 100.