2

I'm using curlpp in an application and need to get the URL I was redirected to. Apparently there are two ways: track the Location headers (ugly) or use curlpp::InfoGetter (the c++ counterpart of curl_easy_getinfo()).

But how do I use curlpp::InfoGetter? I cant't find any examples. Does anyone have a short snippet?

4

1 回答 1

2

好的,我自己发现的:

#include <curlpp/cURLpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Infos.hpp>

curlpp::Easy request;
request.setOpt(new curlpp::options::Url("http://www.example.com/"));
request.perform();
std::string effective_url = curlpp::infos::EffectiveUrl::get(request);

您可以使用http://bitbucket.org/jpbarrette/curlpp/src/tip/include/curlpp/Infos.hppcurl::Info中找到的任何其他子类,而不是.curlpp::infos::EffectiveUrl

于 2010-09-07T15:01:03.553 回答