本文整理汇总了C++中HttpClient::Apply方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpClient::Apply方法的具体用法?C++ HttpClient::Apply怎么用?C++ HttpClient::Apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::Apply方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(HttpClient, SslNoVerification)
{
HttpClient c;
c.SetHttpsVerifyPeers(false);
c.SetUrl("https://bitbucket.org/sjodogne/orthanc/raw/Orthanc-0.9.3/Resources/Configuration.json");
Json::Value v;
c.Apply(v);
ASSERT_TRUE(v.isMember("LuaScripts"));
}
示例2: Apply
bool StorePeerCommand::Apply(ListOfStrings& outputs,
const ListOfStrings& inputs)
{
// Configure the HTTP client
HttpClient client;
client.SetProxy(Configuration::GetGlobalStringParameter("HttpProxy", ""));
if (peer_.GetUsername().size() != 0 &&
peer_.GetPassword().size() != 0)
{
client.SetCredentials(peer_.GetUsername().c_str(),
peer_.GetPassword().c_str());
}
client.SetUrl(peer_.GetUrl() + "instances");
client.SetMethod(HttpMethod_Post);
for (ListOfStrings::const_iterator
it = inputs.begin(); it != inputs.end(); ++it)
{
LOG(INFO) << "Sending resource " << *it << " to peer \""
<< peer_.GetUrl() << "\"";
try
{
context_.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom);
std::string answer;
if (!client.Apply(answer))
{
LOG(ERROR) << "Unable to send resource " << *it << " to peer \"" << peer_.GetUrl() << "\"";
throw OrthancException(ErrorCode_NetworkProtocol);
}
// Only chain with other commands if this command succeeds
outputs.push_back(*it);
}
catch (OrthancException& e)
{
LOG(ERROR) << "Unable to forward to an Orthanc peer in a Lua script (instance "
<< *it << ", peer " << peer_.GetUrl() << "): " << e.What();
if (!ignoreExceptions_)
{
throw;
}
}
}
return true;
}