本文整理汇总了C++中buffer_ptr_t::get方法的典型用法代码示例。如果您正苦于以下问题:C++ buffer_ptr_t::get方法的具体用法?C++ buffer_ptr_t::get怎么用?C++ buffer_ptr_t::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer_ptr_t
的用法示例。
在下文中一共展示了buffer_ptr_t::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fstream
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
{
llifstream fstream(mFilename, std::ios::binary);
if (!fstream.is_open())
throw AICurlNoBody(llformat("Failed to open \"%s\".", mFilename.c_str()));
LLBufferStream ostream(channels, buffer.get());
char tmpbuf[4096];
#ifdef SHOW_ASSERT
size_t total_len = 0;
fstream.seekg(0, std::ios::end);
size_t file_size = fstream.tellg();
fstream.seekg(0, std::ios::beg);
#endif
while (fstream)
{
fstream.read(tmpbuf, sizeof(tmpbuf));
std::streamsize len = fstream.gcount();
if (len > 0)
{
ostream.write(tmpbuf, len);
#ifdef SHOW_ASSERT
total_len += len;
#endif
}
}
if (fstream.bad())
throw AICurlNoBody(llformat("An error occured while reading \"%s\".", mFilename.c_str()));
fstream.close();
ostream << std::flush;
llassert(total_len == file_size && total_len == ostream.count_out());
return ostream.count_out();
}
示例2: completedRaw
void EmeraldDicDownloader::completedRaw(U32 status, const std::string& reason, const LLChannelDescriptors& channels, const buffer_ptr_t& buffer)
{
if (status < 200 || status >= 300)
{
return;
}
LLBufferStream istr(channels, buffer.get());
std::string dicpath(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "dictionaries", name.c_str()));
llofstream ostr(dicpath, std::ios::binary);
while (istr.good() && ostr.good())
{
ostr << istr.rdbuf();
}
ostr.close();
if (panel)
{
if (panel->empanel)
{
panel->empanel->refresh();
}
else
{
llinfos << "completedRaw(): No empanel to refresh()!" << llendl;
}
panel->close();
}
}
示例3: ostream
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
{
LLBufferStream ostream(channels, buffer.get());
ostream.write(mData, mSize);
ostream << std::flush; // Always flush a LLBufferStream when done writing to it.
return mSize;
}
示例4: process_impl
EStatus process_impl(const LLChannelDescriptors &channels,
buffer_ptr_t &buffer, bool &eos,
LLSD &context, LLPumpIO *pump)
{
LLBufferStream ostream(channels, buffer.get());
ostream.write(mData.data(), mData.size());
eos = true;
return STATUS_DONE;
}
示例5: t
// virtual
LLIOPipe::EStatus LLFilterSD2XMLRPCResponse::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
LLFastTimer t(FTM_PROCESS_SD2XMLRPC_RESPONSE);
PUMP_DEBUG;
// This pipe does not work if it does not have everyting. This
// could be addressed by making a stream parser for llsd which
// handled partial information.
if(!eos)
{
return STATUS_BREAK;
}
PUMP_DEBUG;
// we have everyting in the buffer, so turn the structure data rpc
// response into an xml rpc response.
LLBufferStream stream(channels, buffer.get());
stream << XML_HEADER << XMLRPC_METHOD_RESPONSE_HEADER << std::flush; // Flush, or buffer->count() returns too much!
LLSD sd;
LLSDSerialize::fromNotation(sd, stream, buffer->count(channels.in()));
PUMP_DEBUG;
LLIOPipe::EStatus rv = STATUS_ERROR;
if(sd.has("response"))
{
PUMP_DEBUG;
// it is a normal response. pack it up and ship it out.
stream.precision(DEFAULT_PRECISION);
stream << XMLRPC_RESPONSE_HEADER;
streamOut(stream, sd["response"]);
stream << XMLRPC_RESPONSE_FOOTER << XMLRPC_METHOD_RESPONSE_FOOTER;
rv = STATUS_DONE;
}
else if(sd.has("fault"))
{
PUMP_DEBUG;
// it is a fault.
stream << XMLRPC_FAULT_1 << sd["fault"]["code"].asInteger()
<< XMLRPC_FAULT_2
<< xml_escape_string(sd["fault"]["description"].asString())
<< XMLRPC_FAULT_3 << XMLRPC_METHOD_RESPONSE_FOOTER;
rv = STATUS_DONE;
}
else
{
llwarns << "Unable to determine the type of LLSD response." << llendl;
}
PUMP_DEBUG;
return rv;
}
示例6: AICurlNoBody
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
{
int requestTextSize;
mRequestText = XMLRPC_REQUEST_ToXML(mRequest, &requestTextSize);
if (!mRequestText)
throw AICurlNoBody("XMLRPC_REQUEST_ToXML returned NULL.");
LLBufferStream ostream(channels, buffer.get());
ostream.write(mRequestText, requestTextSize);
ostream << std::flush; // Always flush a LLBufferStream when done writing to it.
return requestTextSize;
}
示例7: markBad
void LLHTTPResponder::markBad(
const LLChannelDescriptors& channels,
buffer_ptr_t buffer)
{
LLMemType m1(LLMemType::MTYPE_IO_HTTP_SERVER);
mState = STATE_SHORT_CIRCUIT;
LLBufferStream out(channels, buffer.get());
out << HTTP_VERSION_STR << " 400 Bad Request\r\n\r\n<html>\n"
<< "<title>Bad Request</title>\n<body>\nBad Request.\n"
<< "</body>\n</html>\n";
}
示例8: process_impl
virtual EStatus process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
if(!eos) return STATUS_BREAK;
LLSD sd = "yo!";
LLBufferStream ostr(channels, buffer.get());
ostr << LLSDXMLStreamer(sd);
return STATUS_DONE;
}
示例9: istr
/*virtual*/ void completedRaw(
U32 status,
const std::string& reason,
const LLChannelDescriptors& channels,
const buffer_ptr_t& buffer)
{
LLBufferStream istr(channels, buffer.get());
std::stringstream strstrm;
strstrm << istr.rdbuf();
const std::string body = strstrm.str();
if (status != 200)
{
llwarns << "Failed to get upload config (" << status << ")" << llendl;
LLWebProfile::reportImageUploadStatus(false);
return;
}
Json::Value root;
Json::Reader reader;
if (!reader.parse(body, root))
{
llwarns << "Failed to parse upload config: " << reader.getFormatedErrorMessages() << llendl;
LLWebProfile::reportImageUploadStatus(false);
return;
}
// *TODO: 404 = not supported by the grid
// *TODO: increase timeout or handle 499 Expired
// Convert config to LLSD.
const Json::Value data = root["data"];
const std::string upload_url = root["url"].asString();
LLSD config;
config["acl"] = data["acl"].asString();
config["AWSAccessKeyId"] = data["AWSAccessKeyId"].asString();
config["Content-Type"] = data["Content-Type"].asString();
config["key"] = data["key"].asString();
config["policy"] = data["policy"].asString();
config["success_action_redirect"] = data["success_action_redirect"].asString();
config["signature"] = data["signature"].asString();
config["add_loc"] = data.get("add_loc", "0").asString();
config["caption"] = data.get("caption", "").asString();
// Do the actual image upload using the configuration.
LL_DEBUGS("Snapshots") << "Got upload config, POSTing image to " << upload_url << ", config=[" << config << "]" << LL_ENDL;
LLWebProfile::post(mImagep, config, upload_url);
}
示例10: istr
/*virtual*/ void completedRaw(LLChannelDescriptors const& channels, buffer_ptr_t const& buffer)
{
if (mStatus != HTTP_OK)
{
LL_WARNS() << "Failed to upload image: " << mStatus << " " << mReason << LL_ENDL;
LLWebProfile::reportImageUploadStatus(false);
return;
}
LLBufferStream istr(channels, buffer.get());
std::stringstream strstrm;
strstrm << istr.rdbuf();
const std::string body = strstrm.str();
LL_INFOS() << "Image uploaded." << LL_ENDL;
LL_DEBUGS("Snapshots") << "Uploading image succeeded. Response: [" << body << "]" << LL_ENDL;
LLWebProfile::reportImageUploadStatus(true);
}
示例11: process_impl
// virtual
LLIOPipe::EStatus LLIOSleeper::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
if(!mRespond)
{
LL_DEBUGS() << "LLIOSleeper::process_impl() sleeping." << LL_ENDL;
mRespond = true;
static const F64 SLEEP_TIME = 2.0;
pump->sleepChain(SLEEP_TIME);
return STATUS_BREAK;
}
LL_DEBUGS() << "LLIOSleeper::process_impl() responding." << LL_ENDL;
LLBufferStream ostr(channels, buffer.get());
ostr << "huh? sorry, I was sleeping." << std::endl;
return STATUS_DONE;
}
示例12: process_impl
LLIOPipe::EStatus LLHTTPPipe::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
PUMP_DEBUG;
lldebugs << "LLSDHTTPServer::process_impl" << llendl;
// Once we have all the data, We need to read the sd on
// the the in channel, and respond on the out channel
if(!eos) return STATUS_BREAK;
if(!pump || !buffer) return STATUS_PRECONDITION_NOT_MET;
PUMP_DEBUG;
if (mState == STATE_INVOKE)
{
PUMP_DEBUG;
mState = STATE_DELAYED;
// assume deferred unless mResponse does otherwise
mResponse = Response::create(this);
// *TODO: Babbage: Parameterize parser?
// *TODO: We should look at content-type and do the right
// thing. Phoenix 2007-12-31
LLBufferStream istr(channels, buffer.get());
static LLTimer timer;
timer.reset();
std::string verb = context[CONTEXT_REQUEST][CONTEXT_VERB];
if(verb == HTTP_VERB_GET)
{
LLPerfBlock getblock("http_get");
mNode.get(LLHTTPNode::ResponsePtr(mResponse), context);
}
else if(verb == HTTP_VERB_PUT)
{
LLPerfBlock putblock("http_put");
LLSD input;
LLSDSerialize::fromXML(input, istr);
mNode.put(LLHTTPNode::ResponsePtr(mResponse), context, input);
}
else if(verb == HTTP_VERB_POST)
{
LLPerfBlock postblock("http_post");
LLSD input;
LLSDSerialize::fromXML(input, istr);
mNode.post(LLHTTPNode::ResponsePtr(mResponse), context, input);
}
else if(verb == HTTP_VERB_DELETE)
{
LLPerfBlock delblock("http_delete");
mNode.del(LLHTTPNode::ResponsePtr(mResponse), context);
}
else if(verb == HTTP_VERB_OPTIONS)
{
mNode.options(LLHTTPNode::ResponsePtr(mResponse), context);
}
else
{
mResponse->methodNotAllowed();
}
F32 delta = timer.getElapsedTimeF32();
if (sTimingCallback)
{
LLHTTPNode::Description desc;
mNode.describe(desc);
LLSD info = desc.getInfo();
std::string timing_name = info["description"];
timing_name += " ";
timing_name += verb;
sTimingCallback(timing_name.c_str(), delta, sTimingCallbackData);
}
// Log all HTTP transactions.
// TODO: Add a way to log these to their own file instead of indra.log
// It is just too spammy to be in indra.log.
lldebugs << verb << " " << context[CONTEXT_REQUEST]["path"].asString()
<< " " << mStatusCode << " " << mStatusMessage << " " << delta
<< "s" << llendl;
// Log Internal Server Errors
//if(mStatusCode == 500)
//{
// llwarns << "LLHTTPPipe::process_impl:500:Internal Server Error"
// << llendl;
//}
}
PUMP_DEBUG;
switch (mState)
{
case STATE_DELAYED:
lockChain(pump);
mState = STATE_LOCKED;
return STATUS_BREAK;
//.........这里部分代码省略.........
示例13: process_impl
// virtual
LLIOPipe::EStatus LLURLRequest::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
//llinfos << "LLURLRequest::process_impl()" << llendl;
if (!buffer) return STATUS_ERROR;
// we're still waiting or prcessing, check how many
// bytes we have accumulated.
const S32 MIN_ACCUMULATION = 100000;
if(pump && (mDetail->mByteAccumulator > MIN_ACCUMULATION))
{
// This is a pretty sloppy calculation, but this
// tries to make the gross assumption that if data
// is coming in at 56kb/s, then this transfer will
// probably succeed. So, if we're accumlated
// 100,000 bytes (MIN_ACCUMULATION) then let's
// give this client another 2s to complete.
const F32 TIMEOUT_ADJUSTMENT = 2.0f;
mDetail->mByteAccumulator = 0;
pump->adjustTimeoutSeconds(TIMEOUT_ADJUSTMENT);
lldebugs << "LLURLRequest adjustTimeoutSeconds for request: " << mDetail->mURL << llendl;
if (mState == STATE_INITIALIZED)
{
llinfos << "LLURLRequest adjustTimeoutSeconds called during upload" << llendl;
}
}
switch(mState)
{
case STATE_INITIALIZED:
{
PUMP_DEBUG;
// We only need to wait for input if we are uploading
// something.
if(((HTTP_PUT == mAction) || (HTTP_POST == mAction)) && !eos)
{
// we're waiting to get all of the information
return STATUS_BREAK;
}
// *FIX: bit of a hack, but it should work. The configure and
// callback method expect this information to be ready.
mDetail->mResponseBuffer = buffer.get();
mDetail->mChannels = channels;
if(!configure())
{
return STATUS_ERROR;
}
mState = STATE_WAITING_FOR_RESPONSE;
// *FIX: Maybe we should just go to the next state now...
return STATUS_BREAK;
}
case STATE_WAITING_FOR_RESPONSE:
case STATE_PROCESSING_RESPONSE:
{
PUMP_DEBUG;
LLIOPipe::EStatus status = STATUS_BREAK;
mDetail->mCurlRequest->perform();
while(1)
{
CURLcode result;
bool newmsg = mDetail->mCurlRequest->getResult(&result);
if(!newmsg)
{
// keep processing
break;
}
mState = STATE_HAVE_RESPONSE;
context[CONTEXT_REQUEST][CONTEXT_TRANSFERED_BYTES] = mRequestTransferedBytes;
context[CONTEXT_RESPONSE][CONTEXT_TRANSFERED_BYTES] = mResponseTransferedBytes;
lldebugs << this << "Setting context to " << context << llendl;
switch(result)
{
case CURLE_OK:
case CURLE_WRITE_ERROR:
// NB: The error indication means that we stopped the
// writing due the body limit being reached
if(mCompletionCallback && pump)
{
LLURLRequestComplete* complete = NULL;
complete = (LLURLRequestComplete*)
mCompletionCallback.get();
complete->responseStatus(
result == CURLE_OK
? STATUS_OK : STATUS_STOP);
LLPumpIO::links_t chain;
LLPumpIO::LLLinkInfo link;
link.mPipe = mCompletionCallback;
link.mChannels = LLBufferArray::makeChannelConsumer(
channels);
chain.push_back(link);
//.........这里部分代码省略.........
示例14: process_impl
// virtual
LLIOPipe::EStatus LLSDRPCClient::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
if((STATE_NONE == mState) || (!pump))
{
// You should have called the call() method already.
return STATUS_PRECONDITION_NOT_MET;
}
EStatus rv = STATUS_DONE;
switch(mState)
{
case STATE_READY:
{
PUMP_DEBUG;
// lldebugs << "LLSDRPCClient::process_impl STATE_READY" << llendl;
buffer->append(
channels.out(),
(U8*)mRequest.c_str(),
mRequest.length());
context[CONTEXT_DEST_URI_SD_LABEL] = mURI;
mState = STATE_WAITING_FOR_RESPONSE;
break;
}
case STATE_WAITING_FOR_RESPONSE:
{
PUMP_DEBUG;
// The input channel has the sd response in it.
//lldebugs << "LLSDRPCClient::process_impl STATE_WAITING_FOR_RESPONSE"
// << llendl;
LLBufferStream resp(channels, buffer.get());
LLSD sd;
LLSDSerialize::fromNotation(sd, resp, buffer->count(channels.in()));
LLSDRPCResponse* response = (LLSDRPCResponse*)mResponse.get();
if (!response)
{
mState = STATE_DONE;
break;
}
response->extractResponse(sd);
if(EPBQ_PROCESS == mQueue)
{
LLPumpIO::chain_t chain;
chain.push_back(mResponse);
pump->addChain(chain, DEFAULT_CHAIN_EXPIRY_SECS);
}
else
{
pump->respond(mResponse.get());
}
mState = STATE_DONE;
break;
}
case STATE_DONE:
default:
PUMP_DEBUG;
llinfos << "invalid state to process" << llendl;
rv = STATUS_ERROR;
break;
}
return rv;
}
示例15: process_impl
LLIOPipe::EStatus LLHTTPPipe::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
PUMP_DEBUG;
lldebugs << "LLSDHTTPServer::process_impl" << llendl;
// Once we have all the data, We need to read the sd on
// the the in channel, and respond on the out channel
if(!eos) return STATUS_BREAK;
if(!pump || !buffer) return STATUS_PRECONDITION_NOT_MET;
PUMP_DEBUG;
if (mState == STATE_INVOKE)
{
PUMP_DEBUG;
mState = STATE_DELAYED;
// assume deferred unless mResponse does otherwise
mResponse = Response::create(this);
// TODO: Babbage: Parameterize parser?
LLBufferStream istr(channels, buffer.get());
static LLTimer timer;
if (sTimingCallback)
{
timer.reset();
}
std::string verb = context[CONTEXT_REQUEST]["verb"];
if(verb == HTTP_VERB_GET)
{
mNode.get(LLHTTPNode::ResponsePtr(mResponse), context);
}
else if(verb == HTTP_VERB_PUT)
{
LLSD input;
LLSDSerialize::fromXML(input, istr);
mNode.put(LLHTTPNode::ResponsePtr(mResponse), context, input);
}
else if(verb == HTTP_VERB_POST)
{
LLSD input;
LLSDSerialize::fromXML(input, istr);
mNode.post(LLHTTPNode::ResponsePtr(mResponse), context, input);
}
else if(verb == HTTP_VERB_DELETE)
{
mNode.del(LLHTTPNode::ResponsePtr(mResponse), context);
}
else
{
mResponse->methodNotAllowed();
}
if (sTimingCallback)
{
LLHTTPNode::Description desc;
mNode.describe(desc);
LLSD info = desc.getInfo();
std::string timing_name = info["description"];
timing_name += " ";
timing_name += verb;
F32 delta = timer.getElapsedTimeF32();
sTimingCallback(timing_name.c_str(), delta, sTimingCallbackData);
}
// Log Internal Server Errors
if(mStatusCode == 500)
{
llwarns << "LLHTTPPipe::process_impl:500:Internal Server Error"
<< llendl;
}
}
PUMP_DEBUG;
switch (mState)
{
case STATE_DELAYED:
lockChain(pump);
mState = STATE_LOCKED;
return STATUS_BREAK;
case STATE_LOCKED:
// should never ever happen!
return STATUS_ERROR;
case STATE_GOOD_RESULT:
{
context["response"]["contentType"] = "application/xml";
LLBufferStream ostr(channels, buffer.get());
LLSDSerialize::toXML(mGoodResult, ostr);
return STATUS_DONE;
//.........这里部分代码省略.........