本文整理汇总了C++中SimpleHttpResult::setResultType方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleHttpResult::setResultType方法的具体用法?C++ SimpleHttpResult::setResultType怎么用?C++ SimpleHttpResult::setResultType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleHttpResult
的用法示例。
在下文中一共展示了SimpleHttpResult::setResultType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request
SimpleHttpResult* SimpleHttpClient::request (
int method,
const std::string& location,
const char* body,
size_t bodyLength,
const map<string, string>& headerFields) {
SimpleHttpResult* result = new SimpleHttpResult();
SimpleHttpResult::resultTypes type = SimpleHttpResult::UNKNOWN;
size_t retries = 0;
// build request
stringstream requestBuffer;
fillRequestBuffer(requestBuffer, method, location, body, bodyLength, headerFields);
LOGGER_TRACE << "Request: " << requestBuffer.str();
double start = now();
double runtime = 0.0;
// TODO requestTimeout
while (++retries < _retries && runtime < _requestTimeout) {
// check connection
if (!checkConnection()) {
type = SimpleHttpResult::COULD_NOT_CONNECT;
// LOGGER_WARNING << "could not connect to '" << _connection->getHostname() << ":" << _connection->getPort() << "'";
}
// write
else if (!write(requestBuffer, _requestTimeout - runtime)) {
closeConnection();
type = SimpleHttpResult::WRITE_ERROR;
// LOGGER_WARNING << "write error";
}
// read
else if (!read(result, _requestTimeout - runtime)) {
closeConnection();
type = SimpleHttpResult::READ_ERROR;
// LOGGER_WARNING << "read error";
}
else {
type = SimpleHttpResult::COMPLETE;
break;
}
runtime = now() - start;
}
result->setResultType(type);
return result;
}