static size_t geturl_callback( void *ptr, size_t size, size_t nmemb, void *stream )
{
    int nsize = size * nmemb;
    std::string *strdata = (std::string*) stream;
    if (strdata)
    {
        strdata->append( (const char*)ptr, nsize );
    }

    return nsize;
}

若不返回每次接收的数据大小,回调函数只会执行一次,然后直接跳出回调函数,导致HTTP接收失败。

不过奇怪的是,如果将接收的数据写入文件,那么在回调函数中不返回值也一样能接收成功

相关文章:

  • 2021-07-31
  • 2021-10-22
  • 2021-11-18
  • 2021-12-05
  • 2021-09-04
  • 2021-06-27
  • 2021-08-15
  • 2022-02-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2021-08-10
  • 2021-06-02
  • 2021-09-03
相关资源
相似解决方案