1

我无法使 cURLpp 与以下简单示例一起使用,它一直告诉我No URL set!。这是简化的代码:

          curlpp::initialize(CURL_GLOBAL_ALL);

          curlpp::Easy easyhandle;
          easyhandle.setOpt(new curlpp::options::Url(std::string("http://example.com")));
          easyhandle.perform();

          curlpp::terminate();

如果我尝试通过以下方式取回 Url 选项:

          curlpp::options::Url o;
          easyhandle.getOpt(o);

那么这个对象o看起来非常好:

      o @0x7ffeefbfed78 curlpp::options::Url
          [curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >]  @0x7ffeefbfed78 curlpp::Option<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >
              [curlpp::OptionBase]  @0x7ffeefbfed78 curlpp::OptionBase
                  mOption   CURLOPT_URL (10002) CURLoption
              mContainer    @0x101837be0    curlpp::internal::OptionContainer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >
                  mValue    "http://example.com"    curlpp::internal::OptionContainer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::ValueType
                      [0]   'h'     104     0x68    char
                      [1]   't'     116     0x74    char
                      [2]   't'     116     0x74    char
                      [3]   'p'     112     0x70    char
                      [4]   ':'     58      0x3a    char
                      [5]   '/'     47      0x2f    char
                      [6]   '/'     47      0x2f    char
                      [7]   'e'     101     0x65    char
                      [8]   'x'     120     0x78    char
                      [9]   'a'     97      0x61    char
                      [10]  'm'     109     0x6d    char
                      [11]  'p'     112     0x70    char
                      [12]  'l'     108     0x6c    char
                      [13]  'e'     101     0x65    char
                      [14]  '.'     46      0x2e    char
                      [15]  'c'     99      0x63    char
                      [16]  'o'     111     0x6f    char
                      [17]  'm'     109     0x6d    char

我的环境是:

  • macOS 大苏尔
  • libcurlpp 0.8.1_1
  • 库卷曲 7.80.0
4

0 回答 0