本文整理汇总了C++中std::tr1::shared_ptr::getBytesReceived方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::getBytesReceived方法的具体用法?C++ shared_ptr::getBytesReceived怎么用?C++ shared_ptr::getBytesReceived使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::tr1::shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::getBytesReceived方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request_finished
void MeerkatNameHandler::request_finished(std::tr1::shared_ptr<HttpManager::HttpResponse> response,
HttpManager::ERR_TYPE error, const boost::system::error_code& boost_error,
std::tr1::shared_ptr<MetadataRequest> request, NameCallback callback) {
mStats.resolved++;
mStats.bytesTransferred += (response->getBytesSent() + response->getBytesReceived());
std::tr1::shared_ptr<RemoteFileMetadata> bad;
if (error == Transfer::HttpManager::REQUEST_PARSING_FAILED) {
SILOG(transfer, error, "Request parsing failed during an HTTP name lookup (" << request->getURI() << ")");
callback(bad);
return;
} else if (error == Transfer::HttpManager::RESPONSE_PARSING_FAILED) {
SILOG(transfer, error, "Response parsing failed during an HTTP name lookup (" << request->getURI() << ")");
callback(bad);
return;
} else if (error == Transfer::HttpManager::BOOST_ERROR) {
SILOG(transfer, error, "A boost error happened during an HTTP name lookup (" << request->getURI() << "). Boost error = " << boost_error.message());
callback(bad);
return;
} else if (error != HttpManager::SUCCESS) {
SILOG(transfer, error, "An unknown error happened during an HTTP name lookup. (" << request->getURI() << ")");
callback(bad);
return;
}
if (response->getHeaders().size() == 0) {
SILOG(transfer, error, "There were no headers returned during an HTTP name lookup (" << request->getURI() << ")");
callback(bad);
return;
}
HttpManager::Headers::const_iterator it;
it = response->getHeaders().find("Content-Length");
if (it != response->getHeaders().end()) {
SILOG(transfer, error, "Content-Length header was present when it shouldn't be during an HTTP name lookup (" << request->getURI() << ")");
callback(bad);
return;
}
if (response->getStatusCode() != 200) {
SILOG(transfer, error, "HTTP status code = " << response->getStatusCode() << " instead of 200 during an HTTP name lookup (" << request->getURI() << ")");
callback(bad);
return;
}
it = response->getHeaders().find("File-Size");
if (it == response->getHeaders().end()) {
SILOG(transfer, error, "Expected File-Size header not present during an HTTP name lookup (" << request->getURI() << ")");
callback(bad);
return;
}
std::string file_size_str = it->second;
it = response->getHeaders().find("Hash");
if (it == response->getHeaders().end()) {
SILOG(transfer, error, "Expected Hash header not present during an HTTP name lookup (" << request->getURI() << ")");
callback(bad);
return;
}
std::string hash = it->second;
if (response->getData()) {
SILOG(transfer, error, "Body present during an HTTP name lookup (" << request->getURI() << ")");
callback(bad);
return;
}
Fingerprint fp;
try {
fp = Fingerprint::convertFromHex(hash);
} catch(std::invalid_argument e) {
SILOG(transfer, error, "Hash header didn't contain a valid Fingerprint string (" << request->getURI() << ")");
callback(bad);
return;
}
std::istringstream istream(file_size_str);
uint64 file_size;
istream >> file_size;
std::ostringstream ostream;
ostream << file_size;
if(ostream.str() != file_size_str) {
SILOG(transfer, error, "Error converting File-Size header string to integer (" << request->getURI() << ")");
callback(bad);
return;
}
//Just treat everything as a single chunk for now
Range whole(0, file_size, LENGTH, true);
Chunk chunk(fp, whole);
ChunkList chunkList;
chunkList.push_back(chunk);
std::tr1::shared_ptr<RemoteFileMetadata> met(new RemoteFileMetadata(fp, request->getURI(),
file_size, chunkList, response->getRawHeaders()));
callback(met);
SILOG(transfer, detailed, "done http name handler request_finished");
//.........这里部分代码省略.........