1 //! \file CurlUrlCreator.cpp
5 #include "CurlUrlCreator.h"
9 CurlUrlCreator::CurlUrlCreator(std::string baseUrl
)
10 : baseUrl_(std::move(baseUrl
))
12 curl_global_init(CURL_GLOBAL_ALL
);
13 handle_
= curl_easy_init();
16 CurlUrlCreator::~CurlUrlCreator()
18 curl_easy_cleanup(handle_
);
19 curl_global_cleanup();
22 CurlUrlCreator
& CurlUrlCreator::addParameter(const std::string
& param
,
23 const std::string
& value
)
26 char* eval
= curl_easy_escape(handle_
, value
.c_str(), 0);
32 CurlUrlCreator
& CurlUrlCreator::addParameter(
33 const std::map
<const std::string
, const std::string
>& params
)
35 /* we need to escape the values, so doing a direct ranged insert isn't
37 for(auto& paramterPair
: params
) {
38 addParameter(paramterPair
.first
, paramterPair
.second
);
43 std::string
CurlUrlCreator::buildUrl() const
45 std::string ret
= baseUrl_
;
48 for(auto parpair
: args_
) {
49 ret
.append(parpair
.first
).append("=").append(parpair
.second
).append("&");
57 void CurlUrlCreator::reset()
61 } // namespace WikiWalker