本文整理汇总了C++中request函数的典型用法代码示例。如果您正苦于以下问题:C++ request函数的具体用法?C++ request怎么用?C++ request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: request_method
static SLVAL
request_method(sl_vm_t* vm)
{
return request(vm)->method;
}
示例2: main
int main(int argc, char *argv[])
{
int interactive;
int raw = 0;
int warning_displayed = 0;
int c;
int ret = 0;
for (;;) {
c = getopt(argc, argv, "hvrR");
if (c < 0)
break;
switch (c) {
case 'h':
usage();
return 0;
case 'r':
if (raw) {
usage();
return -1;
}
raw = SHOW_RAW;
break;
case 'R':
if (raw) {
usage();
return -1;
}
raw = (SHOW_RAW | SHOW_RAW_ONLY);
break;
case 'v':
printf("%s\n", cli_version);
return 0;
default:
usage();
return -1;
}
}
show_raw = raw;
interactive = argc == optind;
if (interactive) {
printf("%s\n\n%s\n\n", cli_version,
cli_license);
}
for (;;) {
clif_conn = clif_open();
if (clif_conn) {
if (warning_displayed)
printf("Connection established.\n");
break;
}
if (!interactive) {
perror("Failed to connect to lldpad - clif_open");
return -1;
}
if (!warning_displayed) {
printf("Could not connect to lldpad - re-trying\n");
warning_displayed = 1;
}
sleep(1);
continue;
}
signal(SIGINT, cli_terminate);
signal(SIGTERM, cli_terminate);
signal(SIGALRM, cli_alarm);
if (interactive) {
if (clif_attach(clif_conn, NULL) == 0)
cli_attached = 1;
else
printf("Warning: Failed to attach to lldpad.\n");
cli_interactive(raw);
} else
ret = request(clif_conn, argc - optind, &argv[optind], raw);
cli_close_connection();
return ret;
}
示例3: process_command
//.........这里部分代码省略.........
/* news */
Matched("news");
do_news(player, arg1, arg2);
break;
case 'p':
case 'P':
switch (command[1]) {
case 'a':
case 'A':
case '\0':
Matched("page");
do_page(descr, player, arg1, arg2);
break;
case 'o':
case 'O':
Matched("pose");
do_pose(descr, player, full_command);
break;
case 'u':
case 'U':
Matched("put");
do_drop(descr, player, arg1, arg2);
break;
default:
goto bad;
}
break;
case 'r':
case 'R':
switch (command[1]) {
case 'e':
case 'E':
if(command[2] == 'q' || command[2] == 'Q'){
Matched("request");
request(player, NULL, commandline);
} else {
Matched("read"); /* undocumented alias for look */
do_look_at(descr, player, arg1, arg2);
}
break;
default:
goto bad;
}
break;
case 's':
case 'S':
/* say, "score" */
switch (command[1]) {
case 'a':
case 'A':
Matched("say");
do_say(descr, player, full_command);
break;
case 'c':
case 'C':
case '\0':
if( command[1] &&
(command[2] == 'a' || command[2] == 'A' )) {
Matched("scan");
do_sweep(descr, player, arg1);
} else {
Matched("score");
do_score(player, 1);
}
break;
default:
示例4: element
void ImageLoader::updateFromElement()
{
// If we're not making renderers for the page, then don't load images. We don't want to slow
// down the raw HTML parsing case by loading images we don't intend to display.
Document& document = element().document();
if (!document.hasLivingRenderTree())
return;
AtomicString attr = element().imageSourceURL();
if (attr == m_failedLoadURL)
return;
// Do not load any image if the 'src' attribute is missing or if it is
// an empty string.
CachedResourceHandle<CachedImage> newImage = 0;
if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
CachedResourceRequest request(ResourceRequest(document.completeURL(sourceURI(attr))));
request.setInitiator(&element());
String crossOriginMode = element().fastGetAttribute(HTMLNames::crossoriginAttr);
if (!crossOriginMode.isNull()) {
StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
updateRequestForAccessControl(request.mutableResourceRequest(), document.securityOrigin(), allowCredentials);
}
if (m_loadManually) {
bool autoLoadOtherImages = document.cachedResourceLoader()->autoLoadImages();
document.cachedResourceLoader()->setAutoLoadImages(false);
newImage = new CachedImage(request.resourceRequest(), m_element.document().page()->sessionID());
newImage->setLoading(true);
newImage->setOwningCachedResourceLoader(document.cachedResourceLoader());
document.cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage.get());
document.cachedResourceLoader()->setAutoLoadImages(autoLoadOtherImages);
} else
newImage = document.cachedResourceLoader()->requestImage(request);
// If we do not have an image here, it means that a cross-site
// violation occurred, or that the image was blocked via Content
// Security Policy, or the page is being dismissed. Trigger an
// error event if the page is not being dismissed.
if (!newImage && !pageIsBeingDismissed(document)) {
m_failedLoadURL = attr;
m_hasPendingErrorEvent = true;
errorEventSender().dispatchEventSoon(*this);
} else
clearFailedLoadURL();
} else if (!attr.isNull()) {
// Fire an error event if the url is empty.
m_failedLoadURL = attr;
m_hasPendingErrorEvent = true;
errorEventSender().dispatchEventSoon(*this);
}
CachedImage* oldImage = m_image.get();
if (newImage != oldImage) {
if (m_hasPendingBeforeLoadEvent) {
beforeLoadEventSender().cancelEvent(*this);
m_hasPendingBeforeLoadEvent = false;
}
if (m_hasPendingLoadEvent) {
loadEventSender().cancelEvent(*this);
m_hasPendingLoadEvent = false;
}
// Cancel error events that belong to the previous load, which is now cancelled by changing the src attribute.
// If newImage is null and m_hasPendingErrorEvent is true, we know the error event has been just posted by
// this load and we should not cancel the event.
// FIXME: If both previous load and this one got blocked with an error, we can receive one error event instead of two.
if (m_hasPendingErrorEvent && newImage) {
errorEventSender().cancelEvent(*this);
m_hasPendingErrorEvent = false;
}
m_image = newImage;
m_hasPendingBeforeLoadEvent = !document.isImageDocument() && newImage;
m_hasPendingLoadEvent = newImage;
m_imageComplete = !newImage;
if (newImage) {
if (!document.isImageDocument()) {
if (!document.hasListenerType(Document::BEFORELOAD_LISTENER))
dispatchPendingBeforeLoadEvent();
else
beforeLoadEventSender().dispatchEventSoon(*this);
} else
updateRenderer();
// If newImage is cached, addClient() will result in the load event
// being queued to fire. Ensure this happens after beforeload is
// dispatched.
newImage->addClient(this);
}
if (oldImage)
oldImage->removeClient(this);
}
if (RenderImageResource* imageResource = renderImageResource())
imageResource->resetAnimation();
//.........这里部分代码省略.........
示例5: imageSourceToKURL
void ImageLoader::doUpdateFromElement(UpdateFromElementBehavior updateBehavior)
{
// FIXME: According to
// http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content.html#the-img-element:the-img-element-55
// When "update image" is called due to environment changes and the load fails, onerror should not be called.
// That is currently not the case.
//
// We don't need to call clearLoader here: Either we were called from the
// task, or our caller updateFromElement cleared the task's loader (and set
// m_pendingTask to null).
m_pendingTask.clear();
// Make sure to only decrement the count when we exit this function
OwnPtr<IncrementLoadEventDelayCount> loadDelayCounter;
loadDelayCounter.swap(m_loadDelayCounter);
Document& document = m_element->document();
if (!document.isActive())
return;
AtomicString imageSourceURL = m_element->imageSourceURL();
KURL url = imageSourceToKURL(imageSourceURL);
ResourcePtr<ImageResource> newImage = 0;
if (!url.isNull()) {
// Unlike raw <img>, we block mixed content inside of <picture> or <img srcset>.
ResourceLoaderOptions resourceLoaderOptions = ResourceFetcher::defaultResourceOptions();
ResourceRequest resourceRequest(url);
if (!element()->getAttribute(HTMLNames::srcsetAttr).isNull())
resourceRequest.setRequestContext(WebURLRequest::RequestContextImageSet);
FetchRequest request(ResourceRequest(url), element()->localName(), resourceLoaderOptions);
newImage = document.fetcher()->fetchImage(request);
if (!newImage && !pageIsBeingDismissed(&document))
crossSiteOrCSPViolationOccured(imageSourceURL);
else
clearFailedLoadURL();
} else if (!imageSourceURL.isNull()) {
// Fire an error event if the url string is not empty, but the KURL is.
m_hasPendingErrorEvent = true;
errorEventSender().dispatchEventSoon(this);
}
ImageResource* oldImage = m_image.get();
if (newImage != oldImage) {
sourceImageChanged();
if (m_hasPendingLoadEvent) {
loadEventSender().cancelEvent(this);
m_hasPendingLoadEvent = false;
}
// Cancel error events that belong to the previous load, which is now cancelled by changing the src attribute.
// If newImage is null and m_hasPendingErrorEvent is true, we know the error event has been just posted by
// this load and we should not cancel the event.
// FIXME: If both previous load and this one got blocked with an error, we can receive one error event instead of two.
if (m_hasPendingErrorEvent && newImage) {
errorEventSender().cancelEvent(this);
m_hasPendingErrorEvent = false;
}
m_image = newImage;
m_hasPendingLoadEvent = newImage;
m_imageComplete = !newImage;
updateRenderer();
// If newImage exists and is cached, addClient() will result in the load event
// being queued to fire. Ensure this happens after beforeload is dispatched.
if (newImage)
newImage->addClient(this);
if (oldImage)
oldImage->removeClient(this);
} else if (updateBehavior == UpdateSizeChanged && m_element->renderer() && m_element->renderer()->isImage()) {
toRenderImage(m_element->renderer())->intrinsicSizeChanged();
}
if (RenderImageResource* imageResource = renderImageResource())
imageResource->resetAnimation();
// Only consider updating the protection ref-count of the Element immediately before returning
// from this function as doing so might result in the destruction of this ImageLoader.
updatedHasPendingEvent();
}
示例6: msg
void CentralServerConnection::onReceive(const Archive::ByteStream & message)
{
Archive::ReadIterator ri = message.begin();
GameNetworkMessage msg(ri);
ri = message.begin();
if(msg.isType("ConGenericMessage"))
{
// dispatch to CentralCommandParser
ConGenericMessage con(ri);
Unicode::String wideResult;
m_centralCommandParser->parse(NetworkId(static_cast<NetworkId::NetworkIdType>(con.getMsgId())), Unicode::narrowToWide(con.getMsg()), wideResult);
ConGenericMessage response(Unicode::wideToNarrow(wideResult), con.getMsgId());
send(response, true);
}
else if(msg.isType("CharacterTransferStatusMessage"))
{
CharacterTransferStatusMessage c(ri);
CreatureObject * character = safe_cast<CreatureObject *>(NetworkIdManager::getObjectById(c.getToCharacterId()));
if(character)
{
if(character->getClient())
{
character->receiveCharacterTransferStatusMessage(c.getStatusMessage());
}
}
}
else if(msg.isType("TransferRequestNameValidation"))
{
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferRequestNameValidation from CentralServer : %s", requestNameValidation.getValue().toString().c_str()));
std::string name = requestNameValidation.getValue().getDestinationCharacterName();
if(name.empty())
{
name = requestNameValidation.getValue().getSourceCharacterName();
}
// call the same name validation code that gets called for normal character creation
std::string templateName = requestNameValidation.getValue().getObjectTemplateName();
if (templateName.empty())
{
uint32 const templateCrc = requestNameValidation.getValue().getObjectTemplateCrc();
if (templateCrc != 0)
{
templateName = ObjectTemplateList::lookUp(templateCrc).getString();
}
}
VerifyAndLockNameRequest const verifyRequest(requestNameValidation.getValue().getDestinationStationId(), NetworkId::cms_invalid, templateName, Unicode::narrowToWide(name), 0xFFFFFFFF);
StringId const verifyResult = GameServer::getInstance().handleVerifyAndLockNameRequest(verifyRequest, false, false);
TransferCharacterData replyData(requestNameValidation.getValue());
replyData.setIsValidName(verifyResult == NameErrors::nameApproved);
GenericValueTypeMessage<std::pair<std::string, TransferCharacterData> > reply("TransferReplyNameValidation", std::make_pair(std::string("@") + verifyResult.getCanonicalRepresentation(), replyData));
send(reply, true);
}
else if(msg.isType("TransferReplyCharacterList"))
{
const TransferReplyCharacterList reply(ri);
const AvatarList & oldAl = reply.getAvatarList();
// remove any characters from the list that would qualify for free CTS; characters that
// qualify for free CTS should/must use the in-game free CTS to transfer the character;
AvatarList newAl;
std::string const & clusterName = GameServer::getInstance().getClusterName();
for (AvatarList::const_iterator iter = oldAl.begin(); iter != oldAl.end(); ++iter)
{
if (!FreeCtsDataTable::getFreeCtsInfoForCharacter(static_cast<time_t>(NameManager::getInstance().getPlayerCreateTime(iter->m_networkId)), clusterName, false))
newAl.push_back(*iter);
else
LOG("CustomerService", ("CharacterTransfer: removing (%s, %s, %s) from paid CTS character list for station id %u because the character qualifies for free CTS", clusterName.c_str(), Unicode::wideToNarrow(iter->m_name).c_str(), iter->m_networkId.getValueString().c_str(), reply.getStationId()));
}
// send updated character list back to CentralServer
const TransferReplyCharacterList updatedReply(reply.getTrack(), reply.getStationId(), newAl);
send(updatedReply, true);
}
else if(msg.isType("CtsCompletedForcharacter"))
{
const GenericValueTypeMessage<std::pair<std::string, NetworkId> > msg(ri);
MessageToQueue::getInstance().sendMessageToJava(msg.getValue().second, "ctsCompletedForCharacter", std::vector<int8>(), 0, false);
}
else if( msg.isType( "GameServerCSRequest" ) )
{
GameServerCSRequestMessage request( ri );
GameServer::getInstance().handleCSRequest( request );
}
else if( msg.isType( "CSFindAuthObject" ) )
{
// see if we have the object.
GenericValueTypeMessage< std::pair<NetworkId, unsigned int> > msg( ri );
ServerObject * object = safe_cast<ServerObject *>( NetworkIdManager::getObjectById( msg.getValue().first ) );
// return an appropriate response.
if( object && object->isAuthoritative() )
{
GenericValueTypeMessage< std::pair< unsigned int, bool > > rmsg( "CSFindAuthObjectReply", std::make_pair( msg.getValue().second, true ) );
GameServer::getInstance().sendToCentralServer( rmsg );
}
//.........这里部分代码省略.........
示例7: if
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SeparationsMatrixFacility::makeRequests(){
for (vector<string>::iterator iter = in_commod_.begin();
iter != in_commod_.end();
iter ++){
// The separations facility should ask for at least as much SNF as it is
// already committed to using this month.
double requestAmt;
// In a constrained market, it happily accepts amounts no matter how small
double minAmt = 0;
// check how full its inventory is
double inv = this->checkInventory();
// and how much is already in its stocks
double sto = this->checkStocks();
// subtract inv and sto from inventory max size to get total empty space
// the request cannot exceed the space available
double space = inventory_size_ - inv - sto;
// Currently, no pricing information included for Separations Facility
double commod_price = 0;
// spotCapacity represents unaccounted for capacity
double spotCapacity = capacity_ - outstMF_;
if (space == 0){
// don't request anything
}
else if (space < capacity_){
int total = checkStocks();
Communicator* recipient = dynamic_cast<Communicator*>(MarketModel::marketForCommod(*iter));
// if empty space is less than monthly acceptance capacity
requestAmt = space;
// request a generic resource
GenericResource* request_res = new GenericResource((*iter), "kg", requestAmt);
// build the transaction and message
Transaction trans;
trans.commod = (*iter);
trans.minfrac = minAmt/requestAmt;
trans.is_offer = false;
trans.price = commod_price;
trans.resource = request_res;
msg_ptr request(new Message(this, recipient, trans));
request->setNextDest(facInst());
request->sendOn();
}
// otherwise, the upper bound is the monthly acceptance capacity
// minus the amount in stocks.
else if (space >= capacity_){
Communicator* recipient = dynamic_cast<Communicator*>(MarketModel::marketForCommod(*iter));
// if empty space is more than monthly acceptance capacity
requestAmt = capacity_ - sto;
// request a generic resource
GenericResource* request_res = new GenericResource((*iter), "kg", requestAmt);
// build the transaction and message
Transaction trans;
trans.commod = (*iter);
trans.minfrac = minAmt/requestAmt;
trans.is_offer = false;
trans.price = commod_price;
trans.resource = request_res;
msg_ptr request(new Message(this, recipient, trans));
request->setNextDest(facInst());
request->sendOn();
}
} // <- for leop
}
示例8: warning
//.........这里部分代码省略.........
TargetedWriteBatch* nextBatch = *it;
// If the batch is NULL, we sent it previously, so skip
if ( nextBatch == NULL ) continue;
// Figure out what host we need to dispatch our targeted batch
ConnectionString shardHost;
Status resolveStatus = _resolver->chooseWriteHost( nextBatch->getEndpoint()
.shardName,
&shardHost );
if ( !resolveStatus.isOK() ) {
++numResolveFailures;
// Record a resolve failure
// TODO: It may be necessary to refresh the cache if stale, or maybe just
// cancel and retarget the batch
BatchedErrorDetail error;
buildErrorFrom( resolveStatus, &error );
batchOp.noteBatchError( *nextBatch, error );
// We're done with this batch
*it = NULL;
continue;
}
// If we already have a batch for this host, wait until the next time
HostBatchMap::iterator pendingIt = pendingBatches.find( shardHost );
if ( pendingIt != pendingBatches.end() ) continue;
//
// We now have all the info needed to dispatch the batch
//
BatchedCommandRequest request( clientRequest.getBatchType() );
batchOp.buildBatchRequest( *nextBatch, &request );
// Internally we use full namespaces for request/response, but we send the
// command to a database with the collection name in the request.
NamespaceString nss( request.getNS() );
request.setNS( nss.coll() );
_dispatcher->addCommand( shardHost, nss.db(), request );
// Indicate we're done by setting the batch to NULL
// We'll only get duplicate hostEndpoints if we have broadcast and non-broadcast
// endpoints for the same host, so this should be pretty efficient without
// moving stuff around.
*it = NULL;
// Recv-side is responsible for cleaning up the nextBatch when used
pendingBatches.insert( make_pair( shardHost, nextBatch ) );
}
// Send them all out
_dispatcher->sendAll();
numSent += pendingBatches.size();
//
// Recv side
//
while ( _dispatcher->numPending() > 0 ) {
// Get the response
ConnectionString shardHost;
BatchedCommandResponse response;
示例9: QObject
//.........这里部分代码省略.........
while (match.hasNext()){
QStandardItem *item = new QStandardItem;
QString part = match.next().captured();
QRegularExpression r;
r.setPattern("(?<=>)[^>]+?(?=</a>)");
item->setData(Utils::decodeXml(r.match(part).captured()), Qt::EditRole);
r.setPattern("(?<=data-vid=\").+?(?=\")");
QString next("http://static.comment.%1/V2/%2?pageSize=1000&pageNo=1");
next = next.arg(Utils::customUrl(Utils::AcFun)).arg(r.match(part).captured());
item->setData(next, UrlRole);
item->setData((task.code + "#%1").arg(d->model->rowCount() + 1), StrRole);
item->setData(File, NxtRole);
d->model->appendRow(item);
}
if (sharp == -1 && d->model->rowCount() >= 2){
emit stateChanged(task.state = Part);
}
else{
int i = sharp == -1 ? 0 : task.code.mid(sharp + 1).toInt() - 1;
if (i >= 0 && i < d->model->rowCount()){
forward(QNetworkRequest(d->model->item(i)->data(UrlRole).toUrl()), File);
}
else{
emit stateChanged(203);
dequeue();
}
}
break;
}
case File:
{
QByteArray data = reply->readAll();
if (data != "[[],[],[]]"){
QNetworkRequest &request = task.request;
QUrl url = request.url();
int page = QUrlQuery(url).queryItemValue("pageNo").toInt();
url.setQuery(QString());
request.setUrl(url);
dumpDanmaku(data, Utils::AcFun, false);
QUrlQuery query;
query.addQueryItem("pageSize", "1000");
query.addQueryItem("pageNo", QString::number(page + 1));
url.setQuery(query);
request.setUrl(url);
forward(request, File);
}
else{
emit stateChanged(task.state = None);
dequeue();
}
break;
}
}
};
auto acRegular = getRegular(QRegularExpression("a(c(\\d+([#_])?(\\d+)?)?)?", QRegularExpression::CaseInsensitiveOption));
d->pool.append({ acRegular, 0, acProcess });
auto abProcess = [this, acProcess](QNetworkReply *reply){
Q_D(Load);
Task &task = d->queue.head();
int sharp = task.code.indexOf(QRegularExpression("[#_]"));
switch (task.state){
case None:
{
QString url("http://www.%1/bangumi/video/page?bangumiId=%2&pageSize=30&pageNo=%3&order=2");
url = url.arg(Utils::customUrl(Utils::AcFun)).arg(task.code.mid(2, sharp - 2));
示例10: request_remote_addr
static SLVAL
request_remote_addr(sl_vm_t* vm)
{
return request(vm)->remote_addr;
}
示例11: request_index
static SLVAL
request_index(sl_vm_t* vm, SLVAL self, SLVAL name)
{
(void)self;
return sl_dict_get(vm, request(vm)->params, name);
}
示例12: request_query_string
static SLVAL
request_query_string(sl_vm_t* vm)
{
return request(vm)->query_string;
}
示例13: request_path_info
static SLVAL
request_path_info(sl_vm_t* vm)
{
return request(vm)->path_info;
}
示例14: request_uri
static SLVAL
request_uri(sl_vm_t* vm)
{
return request(vm)->uri;
}
示例15: request
void UpdateWorker::check() const
{
QNetworkRequest request(Url::VERSION);
http->get(request);
}