本文整理汇总了C++中buffer_ptr_t::prepend方法的典型用法代码示例。如果您正苦于以下问题:C++ buffer_ptr_t::prepend方法的具体用法?C++ buffer_ptr_t::prepend怎么用?C++ buffer_ptr_t::prepend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer_ptr_t
的用法示例。
在下文中一共展示了buffer_ptr_t::prepend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process_impl
// virtual
LLIOPipe::EStatus LLHTTPResponseHeader::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
if(eos)
{
PUMP_DEBUG;
//mGotEOS = true;
std::ostringstream ostr;
std::string message = context[CONTEXT_RESPONSE]["statusMessage"];
int code = context[CONTEXT_RESPONSE]["statusCode"];
if (code < 200)
{
code = 200;
message = "OK";
}
ostr << HTTP_VERSION_STR << " " << code << " " << message << "\r\n";
S32 content_length = buffer->countAfter(channels.in(), NULL);
if(0 < content_length)
{
ostr << "Content-Length: " << content_length << "\r\n";
}
// *NOTE: This guard can go away once the LLSD static map
// iterator is available. Phoenix. 2008-05-09
LLSD headers = context[CONTEXT_RESPONSE][CONTEXT_HEADERS];
if(headers.isDefined())
{
LLSD::map_iterator iter = headers.beginMap();
LLSD::map_iterator end = headers.endMap();
for(; iter != end; ++iter)
{
ostr << (*iter).first << ": " << (*iter).second.asString()
<< "\r\n";
}
}
ostr << "\r\n";
LLChangeChannel change(channels.in(), channels.out());
std::for_each(buffer->beginSegment(), buffer->endSegment(), change);
std::string header = ostr.str();
buffer->prepend(channels.out(), (U8*)header.c_str(), header.size());
PUMP_DEBUG;
return STATUS_DONE;
}
PUMP_DEBUG;
return STATUS_OK;
}
示例2: process_impl
// virtual
LLIOPipe::EStatus LLHTTPResponseHeader::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
if(eos)
{
PUMP_DEBUG;
//mGotEOS = true;
std::ostringstream ostr;
std::string message = context["response"]["statusMessage"];
int code = context["response"]["statusCode"];
if (code < 200)
{
code = 200;
message = "OK";
}
ostr << HTTP_VERSION_STR << " " << code << " " << message << "\r\n";
std::string type = context["response"]["contentType"].asString();
if (!type.empty())
{
ostr << "Content-Type: " << type << "\r\n";
}
S32 content_length = buffer->countAfter(channels.in(), NULL);
if(0 < content_length)
{
ostr << "Content-Length: " << content_length << "\r\n";
}
ostr << "\r\n";
LLChangeChannel change(channels.in(), channels.out());
std::for_each(buffer->beginSegment(), buffer->endSegment(), change);
std::string header = ostr.str();
buffer->prepend(channels.out(), (U8*)header.c_str(), header.size());
PUMP_DEBUG;
return STATUS_DONE;
}
PUMP_DEBUG;
return STATUS_OK;
}