문제

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?

도움이 되었습니까?

해결책

Ok, just found it out by myself:

#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);

You may use any other subclass of curl::Info found in http://bitbucket.org/jpbarrette/curlpp/src/tip/include/curlpp/Infos.hpp instead of curlpp::infos::EffectiveUrl.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top