本文整理汇总了C++中nsRefPtr::GetResource方法的典型用法代码示例。如果您正苦于以下问题:C++ nsRefPtr::GetResource方法的具体用法?C++ nsRefPtr::GetResource怎么用?C++ nsRefPtr::GetResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsRefPtr
的用法示例。
在下文中一共展示了nsRefPtr::GetResource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: relative
already_AddRefed<MediaResource>
ServeResourceEvent::GetMediaResource(nsCString const& aHTTPRequest)
{
// Check that the HTTP method is GET
const char* HTTP_METHOD = "GET ";
if (strncmp(aHTTPRequest.get(), HTTP_METHOD, strlen(HTTP_METHOD)) != 0) {
return nullptr;
}
const char* url_start = strchr(aHTTPRequest.get(), ' ');
if (!url_start) {
return nullptr;
}
const char* url_end = strrchr(++url_start, ' ');
if (!url_end) {
return nullptr;
}
// The path extracted from the HTTP request is used as a key in hash
// table. It is not related to retrieving data from the filesystem so
// we don't need to do any sanity checking on ".." paths and similar
// exploits.
nsCString relative(url_start, url_end - url_start);
nsRefPtr<MediaResource> resource =
mServer->GetResource(mServer->GetURLPrefix() + relative);
return resource.forget();
}