Ejemplo n.º 1
0
// virtual
void LLHTTPNode::get(LLHTTPNode::ResponsePtr response, const LLSD& context) const
{
	try
	{
		response->result(simpleGet());
	}
	catch (NotImplemented)
	{
		response->methodNotAllowed();
	}
}
Ejemplo n.º 2
0
// virtual
void LLHTTPNode::post(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const
{
	try
	{
		response->result(simplePost(input));
	}
	catch (NotImplemented)
	{
		response->methodNotAllowed();
	}
}
Ejemplo n.º 3
0
	virtual void get(
		LLHTTPNode::ResponsePtr response,
		const LLSD& context) const
	{
		std::string name = context["request"]["wildcard"]["option-name"];
		response->result(LLApp::instance()->getOption(name));
	}
Ejemplo n.º 4
0
	virtual void get(
		LLHTTPNode::ResponsePtr response,
		const LLSD& context) const
	{
		response->result(LLApp::instance()->getOptionData(
			(LLApp::OptionPriority)PRIORITY));
	}
Ejemplo n.º 5
0
		std::string makeRequest(
			const std::string& name,
			const std::string& httpRequest,
			bool timeout = false)
		{
			LLPipeStringInjector* injector = new LLPipeStringInjector(httpRequest);
			LLPipeStringExtractor* extractor = new LLPipeStringExtractor();
			
			apr_pool_t* pool;
			apr_pool_create(&pool, NULL);

			LLPumpIO* pump;
			pump = new LLPumpIO(pool);

			LLPumpIO::chain_t chain;
			LLSD context;

			chain.push_back(LLIOPipe::ptr_t(injector));
			LLIOHTTPServer::createPipe(chain, mRoot, LLSD());
			chain.push_back(LLIOPipe::ptr_t(extractor));

			pump->addChain(chain, DEFAULT_CHAIN_EXPIRY_SECS);

			pumpPipe(pump, 10);
			if(mResponse.notNull() && (! timeout)) 
			{
				mResponse->result(mResult);
				mResponse = NULL;
			}
			pumpPipe(pump, 10);
			
			std::string httpResult = extractor->string();

			chain.clear();
			delete pump;
			apr_pool_destroy(pool);

			if(mResponse.notNull() && timeout)
			{
				mResponse->result(mResult);
				mResponse = NULL;
			}
			
			return httpResult;
		}
Ejemplo n.º 6
0
	virtual void get(
		LLHTTPNode::ResponsePtr response,
		const LLSD& context) const
	{
		std::string name = context["request"]["wildcard"]["option-name"];
		LLSD options = LLApp::instance()->getOptionData(
			LLApp::PRIORITY_RUNTIME_OVERRIDE);
		response->result(options[name]);
	}
Ejemplo n.º 7
0
	virtual void post(
		LLHTTPNode::ResponsePtr response,
		const LLSD& context,
		const LLSD& input) const
	{
		LLSD result = LLApp::instance()->getOptionData(
			LLApp::PRIORITY_RUNTIME_OVERRIDE);
		LLSD::map_const_iterator iter = input.beginMap();
		LLSD::map_const_iterator end = input.endMap();
		for(; iter != end; ++iter)
		{
			result[(*iter).first] = (*iter).second;
		}
		LLApp::instance()->setOptionData(
			LLApp::PRIORITY_RUNTIME_OVERRIDE,
			result);
		response->result(result);
	}
Ejemplo n.º 8
0
void LLTrustedMessageService::post(LLHTTPNode::ResponsePtr response,
								   const LLSD& context,
								   const LLSD& input) const
{
	std::string name = context["request"]["wildcard"]["message-name"];
	std::string senderIP = context["request"]["remote-host"];
	std::string senderPort = context["request"]["headers"]
		["x-GIS-udp-listen-port"];

	LLSD message_data;
	std::string sender = senderIP + ":" + senderPort;
	message_data["sender"] = sender;
	message_data["body"] = input;
	
	// untrusted senders should not have access to the trusted message
	// service, but this can happen in development, so check and warn
	LLMessageConfig::SenderTrust trust =
		LLMessageConfig::getSenderTrustedness(name);
	if ((trust == LLMessageConfig::TRUSTED ||
		 (trust == LLMessageConfig::NOT_SET &&
		  gMessageSystem->isTrustedMessage(name)))
		 && !gMessageSystem->isTrustedSender(LLHost(sender)))
	{
		LL_WARNS("Messaging") << "trusted message POST to /trusted-message/" 
				<< name << " from unknown or untrusted sender "
				<< sender << llendl;
		response->status(403, "Unknown or untrusted sender");
	}
	else
	{
		gMessageSystem->receivedMessageFromTrustedSender();
		if (input.has("binary-template-data"))
		{
			llinfos << "Dispatching template: " << input << llendl;
			// try and send this message using udp dispatch
			LLMessageSystem::dispatchTemplate(name, message_data, response);
		}
		else
		{
			llinfos << "Dispatching without template: " << input << llendl;
			LLMessageSystem::dispatch(name, message_data, response);
		}
	}
}
Ejemplo n.º 9
0
	virtual void get(
		LLHTTPNode::ResponsePtr response,
		const LLSD& context) const
	{
		LLSD result;
		LLApp* app = LLApp::instance();
		LLSD::map_const_iterator iter;
		LLSD::map_const_iterator end;
		for(int ii = LLApp::PRIORITY_COUNT - 1; ii >= 0; --ii)
		{
			LLSD options = app->getOptionData((LLApp::OptionPriority)ii);
			iter = options.beginMap();
			end = options.endMap();
			for(; iter != end; ++iter)
			{
				result[(*iter).first] = (*iter).second;
			}
		}
		response->result(result);
	}